From 7d608377b8d0e40a58edcfbfe62232c0c5b31efe Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Fri, 15 Jun 2018 14:51:59 -0700 Subject: [PATCH] muxavformat: use alternate API to initialize out context avformat_alloc_output_context2 does several things for us that we were doing in separate steps. It also allocates AVFormatContext.url for us so we do not have a case where we alloc something that ffmpeg frees. --- libhb/muxavformat.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c index f8a0ab984..f92777097 100644 --- a/libhb/muxavformat.c +++ b/libhb/muxavformat.c @@ -132,16 +132,8 @@ static int avformatInit( hb_mux_object_t * m ) max_tracks = 1 + hb_list_count( job->list_audio ) + hb_list_count( job->list_subtitle ); - m->tracks = calloc(max_tracks, sizeof(hb_mux_data_t*)); - m->oc = avformat_alloc_context(); - if (m->oc == NULL) - { - hb_error( "Could not initialize avformat context." ); - goto error; - } - AVDictionary * av_opts = NULL; switch (job->mux) { @@ -176,13 +168,14 @@ static int avformatInit( hb_mux_object_t * m ) goto error; } } - m->oc->oformat = av_guess_format(muxer_name, NULL, NULL); - if(m->oc->oformat == NULL) + + ret = avformat_alloc_output_context2(&m->oc, NULL, muxer_name, job->file); + if (ret < 0) { - hb_error("Could not guess output format %s", muxer_name); + hb_error( "Could not initialize avformat context." ); goto error; } - m->oc->url = av_strdup(job->file); + ret = avio_open2(&m->oc->pb, job->file, AVIO_FLAG_WRITE, &m->oc->interrupt_callback, NULL); if( ret < 0 ) -- 2.40.0