Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7379 closed defect (fixed)

Matroska regression after ff_isom_write_avcc() changes

Reported by: Andrii Owned by:
Priority: important Component: avformat
Version: git-master Keywords: h264 regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:

I have found the issue after moving from ffmpeg version 3.4.1 to 4.0.2.
I use ffmpeg to grab video from USB camera.
I use codec copy flag to just avoid video transcoding.
Saving stream into matroska container worked fine on ffmpeg 3.4.1, but on 4.0.2 it is failed with following error - "Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input".
I have saved the stream into flv container. Attempt to save this flv to mkv is failed with the same error.
I have made my own investigation and figured out that the issue it related to changes in ff_isom_write_avcc() call. In 4.0.2 it returns error if data size is zero, while on ffmpeg 3.4.1 it returns 0. So I have created the patch to just ignore that error for now.
Anyway I should understand that is regression, or maybe my camera generates some unsupported/inconsistent stream format?

Thanks a lot for your support.

How to reproduce:

$ ./ffmpeg.exe -v trace -i matroska_and_ff_isom_write_avcc.flv -vcodec copy test.mkv > matroska_and_ff_isom_write_avcc.log 2>&1

Attachments (4)

matroska_and_ff_isom_write_avcc.flv (1.7 MB ) - added by Andrii 6 years ago.
matroska_and_ff_isom_write_avcc.log (12.1 KB ) - added by Andrii 6 years ago.
matroska_and_ff_isom_write_avcc.mkv (387 bytes ) - added by Andrii 6 years ago.
matroska_and_ff_isom_write_avcc_v4l2.log (9.0 KB ) - added by Andrii 6 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Carl Eugen Hoyos, 6 years ago

Keywords: regression added; mkv ff_isom_write_avcc removed
Priority: normalimportant
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

comment:2 by James, 6 years ago

You can't write avcC data to CodecPrivate without at least an sps in AVCodecParameters->extradata. And without it you get invalid output.

Either the flv source is broken, or the flv demuxer broken. I see this file reports an extradata of size 0. It should instead not try to set extradata at all in that case and let libavformat generic code handle it.

Last edited 6 years ago by James (previous) (diff)

comment:3 by James, 6 years ago

Resolution: fixed
Status: openclosed

comment:4 by Andrii, 6 years ago

I do not understand how your fix should help.
As I understand main issue is related to no extradata in codec parameters on input h264 stream.
I attached flv file just for example.
Main issue is when I read v4l2 device and have same error as on example flv:

$ ffmpeg -v trace -f v4l2 -i /dev/video1 -vcodec copy -t 2 matroska_and_ff_isom_write_avcc.mkv > matroska_and_ff_isom_write_avcc_v4l2.log 2>&1

Please, take a look into new attachment.

comment:5 by James, 6 years ago

The example to reproduce the issue you mentioned in the ticket was using an flv as source to remux into matroska. That's what i fixed.

Muxing h264 streams into Matroska without filling CodecPrivate is not allowed. It wouldn't generate valid files, and that's why the behavior of ff_isom_write_avcc() was changed.

comment:6 by Andrii, 6 years ago

I understood. Thanks.

Note: See TracTickets for help on using tickets.