Opened 6 days ago

Last modified 6 days ago

#6957 new defect

avformat fails to identify intact MJPEG stream if file contains exactly 2 frames

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

Description

Attached are exactly three JPEG frames for a MJPEG stream, the MJPEG stream files are generated by concatenating them with

cat frame1.jpg > stream1.mjpg
cat frame1.jpg frame2.jpg > stream2.mjpg
cat frame1.jpg frame2.jpg frame3.jpg > stream3.mjpg

Problems persist through all binaries (ffmpeg, ffprobe and ffplay tested)

ffmpeg version:

ffmpeg version N-89662-g0e1f771d22-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.4.0 (Debian 6.4.0-11) 20171206
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      56.  7.100 / 56.  7.100
  libavcodec     58.  9.100 / 58.  9.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  8.100 /  7.  8.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100

-loglevel trace stream1.mjpg (1 frame):

[NULL @ 0x571a580] Opening 'stream1.mjpg' for reading
[file @ 0x571ae80] Setting default whitelist 'file,crypto'
Probing jpeg_pipe score:25 size:2048
Probing jpeg_pipe score:25 size:4096
Probing jpeg_pipe score:25 size:8192
Probing jpeg_pipe score:25 size:16384
Probing jpeg_pipe score:25 size:32768
Probing jpeg_pipe score:25 size:65536
Probing jpeg_pipe score:25 size:131072
Probing jpeg_pipe score:51 size:258716
[jpeg_pipe @ 0x571a580] Format jpeg_pipe probed with size=262144 and score=51
[jpeg_pipe @ 0x571a580] Before avformat_find_stream_info() pos: 0 bytes read:258716 seeks:0 nb_streams:1
[mjpeg @ 0x571c080] marker=d8 avail_size_in_buf=258714
[mjpeg @ 0x571c080] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x571c080] marker=db avail_size_in_buf=258712
[mjpeg @ 0x571c080] index=0
[mjpeg @ 0x571c080] qscale[0]: 1
[mjpeg @ 0x571c080] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x571c080] marker=db avail_size_in_buf=258643
[mjpeg @ 0x571c080] index=1
[mjpeg @ 0x571c080] qscale[1]: 1
[mjpeg @ 0x571c080] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x571c080] marker=c0 avail_size_in_buf=258574
[mjpeg @ 0x571c080] Changing bps from 0 to 8
[mjpeg @ 0x571c080] sof0: picture: 1920x1080
[mjpeg @ 0x571c080] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x571c080] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x571c080] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x571c080] pix fmt id 21111100
[mjpeg @ 0x571c080] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x571c080] marker=c4 avail_size_in_buf=258555
[mjpeg @ 0x571c080] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x571c080] marker=c4 avail_size_in_buf=258522
[mjpeg @ 0x571c080] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x571c080] marker=c4 avail_size_in_buf=258339
[mjpeg @ 0x571c080] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x571c080] marker=c4 avail_size_in_buf=258306
[mjpeg @ 0x571c080] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x571c080] escaping removed 337 bytes
[mjpeg @ 0x571c080] marker=da avail_size_in_buf=258123
[mjpeg @ 0x571c080] marker parser used 257786 bytes (2062288 bits)
[mjpeg @ 0x571c080] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x571c080] decode frame unused 0 bytes
[jpeg_pipe @ 0x571a580] stream 0: start_time: -368934881474191040.000 duration: -368934881474191040.000
[jpeg_pipe @ 0x571a580] format: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=0 kb/s
[jpeg_pipe @ 0x571a580] After avformat_find_stream_info() pos: 258716 bytes read:258716 seeks:0 frames:1
Input #0, jpeg_pipe, from 'stream1.mjpg':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: mjpeg, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 1920x1080, 0/1, 25 tbr, 25 tbn, 25 tbc
[AVIOContext @ 0x57232c0] Statistics: 258716 bytes read, 0 seeks

-loglevel trace stream3.mjpg (3 frames):

[NULL @ 0x46da580] Opening 'stream3.mjpg' for reading
[file @ 0x46dae80] Setting default whitelist 'file,crypto'
Probing jpeg_pipe score:25 size:2048
Probing jpeg_pipe score:25 size:4096
Probing jpeg_pipe score:25 size:8192
Probing jpeg_pipe score:25 size:16384
Probing jpeg_pipe score:25 size:32768
Probing jpeg_pipe score:25 size:65536
Probing jpeg_pipe score:25 size:131072
Probing mjpeg score:12 size:524288
Probing mjpeg score:12 size:774426
[mjpeg @ 0x46da580] Format mjpeg detected only with low score of 12, misdetection possible!
[mjpeg @ 0x46da580] Before avformat_find_stream_info() pos: 0 bytes read:774426 seeks:0 nb_streams:1
[mjpeg @ 0x46dbc40] marker=d8 avail_size_in_buf=258714
[mjpeg @ 0x46dbc40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x46dbc40] marker=db avail_size_in_buf=258712
[mjpeg @ 0x46dbc40] index=0
[mjpeg @ 0x46dbc40] qscale[0]: 1
[mjpeg @ 0x46dbc40] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x46dbc40] marker=db avail_size_in_buf=258643
[mjpeg @ 0x46dbc40] index=1
[mjpeg @ 0x46dbc40] qscale[1]: 1
[mjpeg @ 0x46dbc40] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x46dbc40] marker=c0 avail_size_in_buf=258574
[mjpeg @ 0x46dbc40] Changing bps from 0 to 8
[mjpeg @ 0x46dbc40] sof0: picture: 1920x1080
[mjpeg @ 0x46dbc40] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x46dbc40] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x46dbc40] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x46dbc40] pix fmt id 21111100
[mjpeg @ 0x46dbc40] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x46dbc40] marker=c4 avail_size_in_buf=258555
[mjpeg @ 0x46dbc40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x46dbc40] marker=c4 avail_size_in_buf=258522
[mjpeg @ 0x46dbc40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x46dbc40] marker=c4 avail_size_in_buf=258339
[mjpeg @ 0x46dbc40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x46dbc40] marker=c4 avail_size_in_buf=258306
[mjpeg @ 0x46dbc40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x46dbc40] escaping removed 337 bytes
[mjpeg @ 0x46dbc40] marker=da avail_size_in_buf=258123
[mjpeg @ 0x46dbc40] marker parser used 257786 bytes (2062288 bits)
[mjpeg @ 0x46dbc40] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x46dbc40] decode frame unused 0 bytes
[mjpeg @ 0x46da580] All info found
[mjpeg @ 0x46da580] stream 0: start_time: -7686143364045.646 duration: -7686143364045.646
[mjpeg @ 0x46da580] format: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=0 kb/s
[mjpeg @ 0x46da580] After avformat_find_stream_info() pos: 259072 bytes read:774426 seeks:0 frames:1
Input #0, mjpeg, from 'stream3.mjpg':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/1200000: Video: mjpeg, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 1920x1080, 0/1, 25 tbr, 1200k tbn, 25 tbc
[AVIOContext @ 0x46e32c0] Statistics: 774426 bytes read, 0 seeks

-loglevel trace stream2.mjpg (2 frames):

[NULL @ 0x58df580] Opening 'stream2.mjpg' for reading
[file @ 0x58dfe80] Setting default whitelist 'file,crypto'
Probing jpeg_pipe score:25 size:2048
Probing jpeg_pipe score:25 size:4096
Probing jpeg_pipe score:25 size:8192
Probing jpeg_pipe score:25 size:16384
Probing jpeg_pipe score:25 size:32768
Probing jpeg_pipe score:25 size:65536
Probing jpeg_pipe score:25 size:131072
[AVIOContext @ 0x58e82c0] Statistics: 516330 bytes read, 0 seeks
stream2.mjpg: Invalid data found when processing input

-loglevel trace -f mjpeg stream2.mjpg (2 frames with "mjpeg" format forced):

[mjpeg @ 0x4e66580] Opening 'stream2.mjpg' for reading
[file @ 0x4e66e80] Setting default whitelist 'file,crypto'
[mjpeg @ 0x4e66580] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0x4e6fe40] marker=d8 avail_size_in_buf=258714
[mjpeg @ 0x4e6fe40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x4e6fe40] marker=db avail_size_in_buf=258712
[mjpeg @ 0x4e6fe40] index=0
[mjpeg @ 0x4e6fe40] qscale[0]: 1
[mjpeg @ 0x4e6fe40] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x4e6fe40] marker=db avail_size_in_buf=258643
[mjpeg @ 0x4e6fe40] index=1
[mjpeg @ 0x4e6fe40] qscale[1]: 1
[mjpeg @ 0x4e6fe40] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x4e6fe40] marker=c0 avail_size_in_buf=258574
[mjpeg @ 0x4e6fe40] Changing bps from 0 to 8
[mjpeg @ 0x4e6fe40] sof0: picture: 1920x1080
[mjpeg @ 0x4e6fe40] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x4e6fe40] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x4e6fe40] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x4e6fe40] pix fmt id 21111100
[mjpeg @ 0x4e6fe40] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x4e6fe40] marker=c4 avail_size_in_buf=258555
[mjpeg @ 0x4e6fe40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x4e6fe40] marker=c4 avail_size_in_buf=258522
[mjpeg @ 0x4e6fe40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x4e6fe40] marker=c4 avail_size_in_buf=258339
[mjpeg @ 0x4e6fe40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x4e6fe40] marker=c4 avail_size_in_buf=258306
[mjpeg @ 0x4e6fe40] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x4e6fe40] escaping removed 337 bytes
[mjpeg @ 0x4e6fe40] marker=da avail_size_in_buf=258123
[mjpeg @ 0x4e6fe40] marker parser used 257786 bytes (2062288 bits)
[mjpeg @ 0x4e6fe40] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x4e6fe40] decode frame unused 0 bytes
[mjpeg @ 0x4e66580] All info found
[mjpeg @ 0x4e66580] stream 0: start_time: -7686143364045.646 duration: -7686143364045.646
[mjpeg @ 0x4e66580] format: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=0 kb/s
[mjpeg @ 0x4e66580] After avformat_find_stream_info() pos: 259072 bytes read:262144 seeks:0 frames:1
Input #0, mjpeg, from 'stream2.mjpg':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/1200000: Video: mjpeg, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 1920x1080, 0/1, 25 tbr, 1200k tbn, 25 tbc
[AVIOContext @ 0x4e6f2c0] Statistics: 262144 bytes read, 0 seeks

Attachments (3)

frame1.jpg (252.7 KB) - added by Fusl 6 days ago.
frame2.jpg (251.6 KB) - added by Fusl 6 days ago.
frame3.jpg (252.0 KB) - added by Fusl 6 days ago.

Download all attachments as: .zip

Change History (6)

Changed 6 days ago by Fusl

Changed 6 days ago by Fusl

Changed 6 days ago by Fusl

comment:1 Changed 6 days ago by Fusl

  • Component changed from undetermined to avformat

comment:2 Changed 6 days ago by Fusl

  • Summary changed from ffmpeg fails to identify intact MJPEG stream if file contains exactly 2 frames to avformat fails to identify intact MJPEG stream if file contains exactly 2 frames

comment:3 Changed 6 days ago by cehoyos

  • Keywords mjpeg added
Note: See TracTickets for help on using tickets.