Update avformat.c

Modifications in av_format.c:

s->url should be created by av_strdup instead of strdup, because ffmpeg's util.c uses av_freep(&s->url); to free it. Currently it can cause a crash.

If codec_id is AV_CODEC_IP_MPEG4 (which is choosen by ffmpeg if the file extension is mp4), timebase denominator should be 48000 instead of 90000: "timebase 1/90000 not supported by MPEG 4 standard, the maximum admitted value for the timebase denominator is 65535"
This commit is contained in:
Piroska Gabor 2020-04-28 13:59:02 +02:00
parent ae0444e9cb
commit ab2a9691c4
1 changed files with 4 additions and 4 deletions

View File

@ -382,7 +382,7 @@ static int mod_avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputF
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,7,100)) #if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,7,100))
av_strlcpy(s->filename, filename, sizeof(s->filename)); av_strlcpy(s->filename, filename, sizeof(s->filename));
#else #else
s->url = strdup(filename); s->url = av_strdup(filename);
switch_assert(s->url); switch_assert(s->url);
#endif #endif
} }
@ -500,10 +500,10 @@ GCC_DIAG_ON(deprecated-declarations)
c->width = mst->width; c->width = mst->width;
c->height = mst->height; c->height = mst->height;
c->bit_rate = mm->vb * 1024; c->bit_rate = mm->vb * 1024;
mst->st->time_base.den = 90000; mst->st->time_base.den = (codec_id == AV_CODEC_ID_MPEG4 ? 48000 : 90000);
mst->st->time_base.num = 1; mst->st->time_base.num = 1;
c->time_base.den = 90000; c->time_base.den = mst->st->time_base.den;
c->time_base.num = 1; c->time_base.num = mst->st->time_base.num;
c->gop_size = fps * 10; /* emit one intra frame every 10 frames at most */ c->gop_size = fps * 10; /* emit one intra frame every 10 frames at most */
c->pix_fmt = AV_PIX_FMT_YUV420P; c->pix_fmt = AV_PIX_FMT_YUV420P;
//c->thread_count = threads; //c->thread_count = threads;