Opened 6 years ago

Last modified 5 years ago

#7121 open defect

Changing framerate of an MJPEG stream with piping drops malformed images

Reported by: firesharker Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: mjpeg regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
Changing framerate of an MJPEG stream with piping drops malformed images.

How to reproduce:

% ffmpeg -i test.avi -c copy -f image2pipe - | ffmpeg -f image2pipe -framerate 10 -i - -c copy out.avi

ffmpeg version 3.2.4 and N-45595-g5710fdaea-static
on ubuntu 16.04 or OS X 10.9.5

In test.avi and out.avi there should be equal number of frames, but with 10 fps instead of 1.

The same job done with

ffmpeg -i test.avi -c copy frames%d.jpg
ffmpeg -framerate 10 -i frames%d.jpg -c copy out.avi

works correctly.

Attachments (2)

test.avi (2.1 MB ) - added by firesharker 6 years ago.
TLC00011.AVI (1.3 MB ) - added by firesharker 6 years ago.
Original file recorded with Brinno TLC200 PRO

Change History (11)

by firesharker, 6 years ago

Attachment: test.avi added

comment:1 by firesharker, 6 years ago

Version: unspecified3.2.4

comment:2 by Carl Eugen Hoyos, 6 years ago

Version: 3.2.4unspecified

To make this a valid ticket, please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output.

comment:3 by Gyan, 6 years ago

I tested with current git using same commands when this was asked at SE and it reproduces.

Of note is the following from first command in pipe with -v 48. The salient parts are the buffer sizes reported

[avi @ 0000000000498340] Before avformat_find_stream_info() pos: 5678 bytes read:130312 seeks:4 nb_streams:1
[mjpeg @ 0000000002904400] marker=d8 avail_size_in_buf=87542
[mjpeg @ 0000000002904400] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904400] marker=db avail_size_in_buf=87540
[mjpeg @ 0000000002904400] index=0
[mjpeg @ 0000000002904400] qscale[0]: 4
[mjpeg @ 0000000002904400] marker parser used 67 bytes (536 bits)
[mjpeg @ 0000000002904400] marker=db avail_size_in_buf=87471
[mjpeg @ 0000000002904400] index=1
[mjpeg @ 0000000002904400] qscale[1]: 9
[mjpeg @ 0000000002904400] marker parser used 67 bytes (536 bits)
[mjpeg @ 0000000002904400] marker=c0 avail_size_in_buf=87402
[mjpeg @ 0000000002904400] Changing bps from 0 to 8
[mjpeg @ 0000000002904400] sof0: picture: 1280x720
[mjpeg @ 0000000002904400] component 0 2:2 id: 0 quant:0
[mjpeg @ 0000000002904400] component 1 1:1 id: 1 quant:1
[mjpeg @ 0000000002904400] component 2 1:1 id: 2 quant:1
[mjpeg @ 0000000002904400] pix fmt id 22111100
[mjpeg @ 0000000002904400] Format yuvj420p chosen by get_format().
[mjpeg @ 0000000002904400] marker parser used 17 bytes (136 bits)
[mjpeg @ 0000000002904400] marker=c4 avail_size_in_buf=87383
[mjpeg @ 0000000002904400] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904400] marker=c4 avail_size_in_buf=87350
[mjpeg @ 0000000002904400] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904400] marker=c4 avail_size_in_buf=87167
[mjpeg @ 0000000002904400] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904400] marker=c4 avail_size_in_buf=87134
[mjpeg @ 0000000002904400] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904400] marker=ef avail_size_in_buf=86951
[mjpeg @ 0000000002904400] marker parser used 152 bytes (1216 bits)
[mjpeg @ 0000000002904400] escaping removed 816 bytes
[mjpeg @ 0000000002904400] marker=da avail_size_in_buf=86796
[mjpeg @ 0000000002904400] marker parser used 85980 bytes (687840 bits)
[mjpeg @ 0000000002904400] marker=d9 avail_size_in_buf=576
[mjpeg @ 0000000002904400] decode frame unused 576 bytes
[avi @ 0000000000498340] max_analyze_duration 5000000 reached at 5000000 microseconds st:0

And in the receiving command,

[image2pipe @ 00000000028f2f00] Opening 'pipe:' for reading
[pipe @ 00000000028f3b40] Setting default whitelist 'crypto'
[image2pipe @ 00000000028f2f00] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0000000002904d80] marker=d8 avail_size_in_buf=2003270
[mjpeg @ 0000000002904d80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904d80] marker=db avail_size_in_buf=2003268
[mjpeg @ 0000000002904d80] index=0
[mjpeg @ 0000000002904d80] qscale[0]: 4
[mjpeg @ 0000000002904d80] marker parser used 67 bytes (536 bits)
[mjpeg @ 0000000002904d80] marker=db avail_size_in_buf=2003199
[mjpeg @ 0000000002904d80] index=1
[mjpeg @ 0000000002904d80] qscale[1]: 9
[mjpeg @ 0000000002904d80] marker parser used 67 bytes (536 bits)
[mjpeg @ 0000000002904d80] marker=c0 avail_size_in_buf=2003130
[mjpeg @ 0000000002904d80] Changing bps from 0 to 8
[mjpeg @ 0000000002904d80] sof0: picture: 1280x720
[mjpeg @ 0000000002904d80] component 0 2:2 id: 0 quant:0
[mjpeg @ 0000000002904d80] component 1 1:1 id: 1 quant:1
[mjpeg @ 0000000002904d80] component 2 1:1 id: 2 quant:1
[mjpeg @ 0000000002904d80] pix fmt id 22111100
[mjpeg @ 0000000002904d80] Format yuvj420p chosen by get_format().
[mjpeg @ 0000000002904d80] marker parser used 17 bytes (136 bits)
[mjpeg @ 0000000002904d80] marker=c4 avail_size_in_buf=2003111
[mjpeg @ 0000000002904d80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904d80] marker=c4 avail_size_in_buf=2003078
[mjpeg @ 0000000002904d80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904d80] marker=c4 avail_size_in_buf=2002895
[mjpeg @ 0000000002904d80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904d80] marker=c4 avail_size_in_buf=2002862
[mjpeg @ 0000000002904d80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000002904d80] marker=ef avail_size_in_buf=2002679
[mjpeg @ 0000000002904d80] marker parser used 152 bytes (1216 bits)
[mjpeg @ 0000000002904d80] escaping removed 1916544 bytes
[mjpeg @ 0000000002904d80] marker=da avail_size_in_buf=2002524
[mjpeg @ 0000000002904d80] marker parser used 85980 bytes (687840 bits)
[mjpeg @ 0000000002904d80] marker=d9 avail_size_in_buf=1916304
[mjpeg @ 0000000002904d80] decode frame unused 1916304 bytes
[image2pipe @ 00000000028f2f00] Probe buffer size limit of 5000000 bytes reached

comment:4 by firesharker, 6 years ago

Tested with the 20180402 nightly build and 3.2.4

$ ffmpeg -i test.avi -c copy -f image2pipe - | ffmpeg -f image2pipe -framerate 10 -i - -c copy out.avi
ffmpeg version N-45595-g5710fdaea-static https://johnvansickle.com/ffmpeg/ ffmpeg version N-45595-g5710fdaea-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
 Copyright (c) 2000-2018 the FFmpeg developers  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516

  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-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --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
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  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-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --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. 12.100 / 56. 12.100
  libavcodec     58. 17.100 / 58. 17.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavutil      56. 12.100 / 56. 12.100
  libavfilter     7. 14.100 /  7. 14.100
  libavcodec     58. 17.100 / 58. 17.100
  libswscale      5.  0.102 /  5.  0.102
  libavformat    58. 10.100 / 58. 10.100
  libswresample   3.  0.101 /  3.  0.101
  libavdevice    58.  2.100 / 58.  2.100
  libpostproc    55.  0.100 / 55.  0.100
  libavfilter     7. 14.100 /  7. 14.100
  libswscale      5.  0.102 /  5.  0.102
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, avi, from 'test.avi':
  Metadata:
    encoder         : Lavf57.56.101
  Duration: 00:00:25.00, start: 0.000000, bitrate: 699 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 726 kb/s, 1 fps, 1 tbr, 1 tbn, 1 tbc
Output #0, image2pipe, to 'pipe:':
  Metadata:
    encoder         : Lavf58.10.100
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, q=2-31, 726 kb/s, 1 fps, 1 tbr, 1 tbn, 1 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   25 fps=0.0 q=-1.0 Lsize=    2128kB time=00:00:25.00 bitrate= 697.4kbits/s speed=9.12e+03x    
video:2128kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Input #0, image2pipe, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 10 fps, 10 tbr, 10 tbn, 10 tbc
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf58.10.100
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, q=2-31, 10 fps, 10 tbr, 10 tbn, 10 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
frame=    3 fps=0.0 q=-1.0 Lsize=    2134kB time=00:00:00.30 bitrate=58270.5kbits/s speed= 341x    
video:2128kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.264203%

(My original SE question)

comment:5 by Carl Eugen Hoyos, 6 years ago

Component: undeterminedavcodec
Keywords: mjpeg regression added
Version: unspecifiedgit-master

How was the input file created? There is a lot of garbage at the end of each frame.

comment:6 by firesharker, 6 years ago

The video was recorded with a Brinno TLC200 Pro time lapse camera. I used ffmpeg -i original.avi -c copy -vframes 25 test.avi to create the sample file.

comment:7 by Carl Eugen Hoyos, 6 years ago

Please provide the original file.

by firesharker, 6 years ago

Attachment: TLC00011.AVI added

Original file recorded with Brinno TLC200 PRO

comment:8 by firesharker, 6 years ago

Sorry, I can't share the original file (and its quite large), but I recorded this test file. According to my tests, it reproduces the problem.

comment:9 by Carl Eugen Hoyos, 5 years ago

Priority: normalimportant
Reproduced by developer: set
Status: newopen

This is a regression since 1af3571e05522df4e71a5b33de05bdb9e953a6c4

Note: See TracTickets for help on using tickets.