Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#8014 closed defect (invalid)

Piping mjpeg drops frames

Reported by: Sig Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


It seems switching output from jpeg image files to a pipe results in frames not being outputted to the pipe.

Attached is 100-frames.mp4 which is a video of 100 sequentially numbered frames.

As expected running the below outputs all 100 frames correctly.

ffmpeg -i 100-frames.mp4 -f image2 -vcodec mjpeg "out%05d.jpg"

However running this next command results in only 53 frames being detected:

ffmpeg -i 100-frames.mp4 -f image2 -vcodec mjpeg -update 1 pipe:1 | xxd | grep "ffd8" | wc -l

This one uses xxd to convert the outputted binary into hex then uses grep to search for the jpeg start bytes ("ffd8"). Finally wc counts the search hits and prints the total at the end. So the number output at the end is the number of JPEGs seen in the stream.

Attachments (3)

100-frames.mp4 (159.5 KB ) - added by Sig 2 years ago.
Sample video containing 100 frames
ffmpeg-20190712-195906-write-images-to-file.log (45.6 KB ) - added by Sig 2 years ago.
output from -report
ffmpeg-20190712-200111-write-image-to-pipe.log (44.6 KB ) - added by Sig 2 years ago.
output from -report

Download all attachments as: .zip

Change History (7)

by Sig, 2 years ago

Attachment: 100-frames.mp4 added

Sample video containing 100 frames

by Sig, 2 years ago

output from -report

by Sig, 2 years ago

output from -report

comment:1 by Sig, 2 years ago

Tested on ffmpeg version N-94271-g2601eef850 and 4.1.4
Mac OS X 10.14.4

comment:2 by mkver, 2 years ago

Resolution: invalid
Status: newclosed
  1. Your video actually contains 101 frames.
  2. You have not really shown that this is a bug in FFmpeg. It could also be in your other software or in your handling of the other software.
  3. It is actually your handling of the other software. The output of xxd looks like this:
    00000000: ffd8 ffe0 0010 4a46 4946 0001 0200 0001  ......JFIF......
    00000010: 0001 0000 fffe 0010 4c61 7663 3538 2e35  ........Lavc58.5
    00000020: 332e 3130 3100 ffdb 0043 0008 0808 0908  3.101....C......
    The ffd8 at the beginning will of course be found by grep. But this non-word-aligned occurence will not:
    0000bf90: 0c88 bad3 4591 65bf ebd6 0b42 e188 5865  ....E.e....B..Xe
    0000bfa0: 6e9f 0877 4dd7 a2ff d9ff d8ff e000 104a  n..wM..........J
    0000bfb0: 4649 4600 0102 0000 0100 0100 00ff fe00  FIF.............
    This happens 41 times; and there are a further eight times where ff and d8 are in different lines. 41 + 8 + 52 = 101; notice that one of your 53 matches is actually a false match:
    000ffd80: 19a1 1985 04e0 8ad4 d3c5 4944 7074 0386  ..........IDpt..
Last edited 2 years ago by mkver (previous) (diff)

comment:3 by Sig, 2 years ago

Thanks, I see where I've gone wrong now.

Very much appreciate the thorough (and prompt!) response.

comment:4 by Carl Eugen Hoyos, 2 years ago

Component: ffmpegundetermined
Keywords: h264 mjpeg pipe dropped frames removed
Note: See TracTickets for help on using tickets.