Message ID | e0dd2cd7-07c3-06bd-e21a-98195bc5d801@noa-archive.com |
---|---|
State | Accepted |
Headers | show |
On 20.01.2017 15:56, Tobias Rapp wrote: > On 19.01.2017 18:32, Michael Niedermayer wrote: >> On Wed, Jan 18, 2017 at 10:27:02AM +0100, Tobias Rapp wrote: >>> Allows the user to reserve space for the ODML master index. A sufficient >>> sized master index in the AVI header avoids storing follow-up master >>> indexes within the 'movi' data later. >>> >>> If the option is omitted or zero the index size is estimated from output >>> duration and bitrate. A worst-case bitrate for video streams is assumed >>> in case it is not available. >>> >>> Note: fate reference files changed because the video stream had zero >>> bitrate before and is guessed now. >>> >>> Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com> >>> --- >>> libavformat/avi.h | 1 - >>> libavformat/avienc.c | 77 >>> ++++++++++++++++++++++++++++++--- >>> libavformat/version.h | 2 +- >>> tests/ref/fate/mpeg4-bsf-unpack-bframes | 2 +- >>> tests/ref/lavf-fate/avi_cram | 2 +- >>> 5 files changed, 74 insertions(+), 10 deletions(-) >> >> this breaks segment: >> ./ffmpeg -i lena.pnm -f segment test%d.avi >> >> possibly related to avi_init() > > Yes, I can reproduce the problem when going back to Git master and just > adding a dummy init (see attached diff). Not sure how to fix this, other > muxers also have an init but seem to work fine (mkv) ... Apparently the codec_tag is cleared in seg_write_header() around line 811: [...] if (!oc->oformat->codec_tag || av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == opar->codec_id || av_codec_get_tag(oc->oformat->codec_tag, ipar->codec_id) <= 0) { opar->codec_tag = ipar->codec_tag; } else { opar->codec_tag = 0; } [...] See http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/segment.c;hb=HEAD#l811 If .init is unset, the header is written before the codec_tag is cleared. If .init is set, it is written after these lines. Regards, Tobias
On Fri, Jan 20, 2017 at 05:06:59PM +0100, Tobias Rapp wrote: > On 20.01.2017 15:56, Tobias Rapp wrote: > >On 19.01.2017 18:32, Michael Niedermayer wrote: > >>On Wed, Jan 18, 2017 at 10:27:02AM +0100, Tobias Rapp wrote: > >>>Allows the user to reserve space for the ODML master index. A sufficient > >>>sized master index in the AVI header avoids storing follow-up master > >>>indexes within the 'movi' data later. > >>> > >>>If the option is omitted or zero the index size is estimated from output > >>>duration and bitrate. A worst-case bitrate for video streams is assumed > >>>in case it is not available. > >>> > >>>Note: fate reference files changed because the video stream had zero > >>>bitrate before and is guessed now. > >>> > >>>Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com> > >>>--- > >>> libavformat/avi.h | 1 - > >>> libavformat/avienc.c | 77 > >>>++++++++++++++++++++++++++++++--- > >>> libavformat/version.h | 2 +- > >>> tests/ref/fate/mpeg4-bsf-unpack-bframes | 2 +- > >>> tests/ref/lavf-fate/avi_cram | 2 +- > >>> 5 files changed, 74 insertions(+), 10 deletions(-) > >> > >>this breaks segment: > >>./ffmpeg -i lena.pnm -f segment test%d.avi > >> > >>possibly related to avi_init() > > > >Yes, I can reproduce the problem when going back to Git master and just > >adding a dummy init (see attached diff). Not sure how to fix this, other > >muxers also have an init but seem to work fine (mkv) ... > > Apparently the codec_tag is cleared in seg_write_header() around line 811: > > [...] > if (!oc->oformat->codec_tag || > av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == > opar->codec_id || > av_codec_get_tag(oc->oformat->codec_tag, ipar->codec_id) <= 0) { > opar->codec_tag = ipar->codec_tag; > } else { > opar->codec_tag = 0; > } > [...] > > See http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/segment.c;hb=HEAD#l811 > > If .init is unset, the header is written before the codec_tag is > cleared. If .init is set, it is written after these lines. the return code of your init function is wrong i think also this patch causes a 1 byte difference in the output of: ./ffmpeg -i ~/tickets/1116/AVI-RLE_MP3.avi -vcodec copy -an out2.avi is that intended ? [...]
diff --git a/libavformat/avienc.c b/libavformat/avienc.c index fd16fff..fb78300 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -134,6 +134,12 @@ static int avi_add_ientry(AVFormatContext *s, int stream_index, char *tag, return 0; } + +static int avi_init(struct AVFormatContext *s) +{ + return 0; +} + static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb, const char *riff_tag, const char *list_tag) { @@ -927,6 +933,7 @@ AVOutputFormat ff_avi_muxer = { .priv_data_size = sizeof(AVIContext), .audio_codec = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_AC3, .video_codec = AV_CODEC_ID_MPEG4, + .init = avi_init, .write_header = avi_write_header, .write_packet = avi_write_packet, .write_trailer = avi_write_trailer,