Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#7379 closed defect (fixed)

Matroska regression after ff_isom_write_avcc() changes

Reported by: gontandre 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 gontandre 10 months ago.
matroska_and_ff_isom_write_avcc.log (12.1 KB) - added by gontandre 10 months ago.
matroska_and_ff_isom_write_avcc.mkv (387 bytes) - added by gontandre 10 months ago.
matroska_and_ff_isom_write_avcc_v4l2.log (9.0 KB) - added by gontandre 10 months ago.

Download all attachments as: .zip

Change History (10)

Changed 10 months ago by gontandre

Changed 10 months ago by gontandre

comment:1 Changed 10 months ago by cehoyos

  • Keywords regression added; mkv ff_isom_write_avcc removed
  • Priority changed from normal to important
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

comment:2 Changed 10 months ago by jamrial

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 10 months ago by jamrial (previous) (diff)

comment:3 Changed 10 months ago by jamrial

  • Resolution set to fixed
  • Status changed from open to closed

Changed 10 months ago by gontandre

Changed 10 months ago by gontandre

comment:4 Changed 10 months ago by gontandre

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 Changed 10 months ago by jamrial

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 Changed 10 months ago by gontandre

I understood. Thanks.

Note: See TracTickets for help on using tickets.