void end_ffmpeg(void) { unsigned int i; fprintf(stderr, "Closing ffmpeg...\n"); /* if (audio_stream) { SEE UPPER write_audio_frames(); }*/ #ifdef WITH_AUDASPACE if(audio_mixdown_device) { AUD_closeReadDevice(audio_mixdown_device); audio_mixdown_device = 0; } #endif if (video_stream && video_stream->codec) { fprintf(stderr, "Flushing delayed frames...\n"); flush_ffmpeg (); } if (outfile) { av_write_trailer(outfile); } /* Close the video codec */ if (video_stream && video_stream->codec) { avcodec_close(video_stream->codec); printf("zero video stream %p\n", video_stream); video_stream = 0; } /* Close the output file */ if (outfile) { for (i = 0; i < outfile->nb_streams; i++) { if (&outfile->streams[i]) { av_freep(&outfile->streams[i]); } } } /* free the temp buffer */ if (current_frame) { delete_picture(current_frame); current_frame = 0; } if (outfile && outfile->oformat) { if (!(outfile->oformat->flags & AVFMT_NOFILE)) { avio_close(outfile->pb); } } if (outfile) { av_free(outfile); outfile = 0; } if (video_buffer) { MEM_freeN(video_buffer); video_buffer = 0; } if (audio_output_buffer) { av_free(audio_output_buffer); audio_output_buffer = 0; } if (audio_input_buffer) { av_free(audio_input_buffer); audio_input_buffer = 0; } if (img_convert_ctx) { sws_freeContext(img_convert_ctx); img_convert_ctx = 0; } }
static void end_ffmpeg_impl(int is_autosplit) { unsigned int i; PRINT("Closing ffmpeg...\n"); #if 0 if (audio_stream) { /* SEE UPPER */ write_audio_frames(); } #endif #ifdef WITH_AUDASPACE if (is_autosplit == false) { if (audio_mixdown_device) { AUD_closeReadDevice(audio_mixdown_device); audio_mixdown_device = 0; } } #endif if (video_stream && video_stream->codec) { PRINT("Flushing delayed frames...\n"); flush_ffmpeg(); } if (outfile) { av_write_trailer(outfile); } /* Close the video codec */ if (video_stream && video_stream->codec) { avcodec_close(video_stream->codec); PRINT("zero video stream %p\n", video_stream); video_stream = 0; } /* Close the output file */ if (outfile) { for (i = 0; i < outfile->nb_streams; i++) { if (&outfile->streams[i]) { av_freep(&outfile->streams[i]); } } } /* free the temp buffer */ if (current_frame) { delete_picture(current_frame); current_frame = 0; } if (outfile && outfile->oformat) { if (!(outfile->oformat->flags & AVFMT_NOFILE)) { avio_close(outfile->pb); } } if (outfile) { av_free(outfile); outfile = 0; } if (audio_input_buffer) { av_free(audio_input_buffer); audio_input_buffer = 0; } #ifndef FFMPEG_HAVE_ENCODE_AUDIO2 if (audio_output_buffer) { av_free(audio_output_buffer); audio_output_buffer = 0; } #endif if (audio_deinterleave_buffer) { av_free(audio_deinterleave_buffer); audio_deinterleave_buffer = 0; } if (img_convert_ctx) { sws_freeContext(img_convert_ctx); img_convert_ctx = 0; } }