void ffmpeglib_close(ffmpeglib_t *lib) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); #ifdef HAVE_FFMPEG_SWSCALE free_swscale(lib); #endif }
void ffmpeglib_close(ffmpeglib_t *lib) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); free_swscale(lib); #ifndef HAVE_FFMPEG_AVRESAMPLE free_swresample(lib); #else free_avresample(lib); #endif }
int ffmpeglib_open(ffmpeglib_t *lib) { int result; result = load_avformat(lib); if (result != 0) { free_avformat(lib); return result; } result = load_avcodec(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); return result; } result = load_avutil(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); return result; } result = load_swscale(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); free_swscale(lib); return result; } #ifndef HAVE_FFMPEG_AVRESAMPLE result = load_swresample(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); free_swscale(lib); free_swresample(lib); return result; } #else result = load_avresample(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); free_swscale(lib); free_avresample(lib); return result; } #endif return 0; }
int ffmpeglib_open(ffmpeglib_t *lib) { int result; result = load_avformat(lib); if (result != 0) { free_avformat(lib); return result; } result = load_avcodec(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); return result; } result = load_avutil(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); return result; } #ifdef HAVE_FFMPEG_SWSCALE result = load_swscale(lib); if (result != 0) { free_avformat(lib); free_avcodec(lib); free_avutil(lib); free_swscale(lib); return result; } #endif return 0; }
static int ffmpeg_mux_init_context(struct ffmpeg_mux *ffm) { AVOutputFormat *output_format; int ret; output_format = av_guess_format(NULL, ffm->params.file, NULL); if (output_format == NULL) { printf("Couldn't find an appropriate muxer for '%s'\n", ffm->params.file); return FFM_ERROR; } ret = avformat_alloc_output_context2(&ffm->output, output_format, NULL, NULL); if (ret < 0) { printf("Couldn't initialize output context: %s\n", av_err2str(ret)); return FFM_ERROR; } ffm->output->oformat->video_codec = AV_CODEC_ID_NONE; ffm->output->oformat->audio_codec = AV_CODEC_ID_NONE; if (!init_streams(ffm)) { free_avformat(ffm); return FFM_ERROR; } ret = open_output_file(ffm); if (ret != FFM_SUCCESS) { free_avformat(ffm); return ret; } return FFM_SUCCESS; }
static void ffmpeg_mux_free(struct ffmpeg_mux *ffm) { if (ffm->initialized) { av_write_trailer(ffm->output); } free_avformat(ffm); header_free(&ffm->video_header); if (ffm->audio_header) { for (int i = 0; i < ffm->params.tracks; i++) { header_free(&ffm->audio_header[i]); } free(ffm->audio_header); } if (ffm->audio) { free(ffm->audio); } memset(ffm, 0, sizeof(*ffm)); }