Opened 15 months ago

Last modified 13 months ago

#8967 open defect

FFmpeg fails with image2pipe while image2 works

Reported by: fritsch Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: mjpeg regression kodi
Cc: candrews@integralblue.com, jdieter@gmail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffmpeg -loglevel trace -f image2pipe -i ~/schurz/5gOk0JtwjdIv.jpg hurz2.jpg
3.4.1
built on x86_43

Working:

% ffmpeg -loglevel trace -f image2 -i ~/schurz/5gOk0JtwjdIv.jpg hurz2.jpg

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Output of failure:
fritsch@L380:~/Desktop/FFmpeg$ ./ffmpeg -loglevel trace -f image2pipe -i ~/schurz/5gOk0JtwjdIv.jpg hurz2.jpg
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration:
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'image2pipe'.
Reading option '-i' ... matched as input url with argument '/home/fritsch/schurz/5gOk0JtwjdIv.jpg'.
Reading option 'hurz2.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
Applying option f (force format) with argument image2pipe.
Successfully parsed a group of options.
Opening an input file: /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
[image2pipe @ 0x55986b9f0780] Opening '/home/fritsch/schurz/5gOk0JtwjdIv.jpg' for reading
[file @ 0x55986b9f1300] Setting default whitelist 'file,crypto,data'
[image2pipe @ 0x55986b9f0780] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0x55986b9faac0] marker=d8 avail_size_in_buf=56310
[mjpeg @ 0x55986b9faac0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9faac0] marker=e0 avail_size_in_buf=56308
[mjpeg @ 0x55986b9faac0] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x55986b9faac0] marker=e1 avail_size_in_buf=56290
[mjpeg @ 0x55986b9faac0] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x55986b9faac0] marker parser used 2 bytes (16 bits)
[mjpeg @ 0x55986b9faac0] marker=d9 avail_size_in_buf=24334
[mjpeg @ 0x55986b9faac0] Found EOI before any SOF, ignoring
[mjpeg @ 0x55986b9faac0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9faac0] No JPEG data found in image
[mjpeg @ 0x55986b9faac0] marker=d8 avail_size_in_buf=163491
[mjpeg @ 0x55986b9faac0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9faac0] marker=db avail_size_in_buf=163489
[mjpeg @ 0x55986b9faac0] index=0
[mjpeg @ 0x55986b9faac0] qscale[0]: 6
[mjpeg @ 0x55986b9faac0] index=1
[mjpeg @ 0x55986b9faac0] qscale[1]: 13
[mjpeg @ 0x55986b9faac0] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x55986b9faac0] marker=c4 avail_size_in_buf=163355
[mjpeg @ 0x55986b9faac0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9faac0] marker=c0 avail_size_in_buf=162935
[mjpeg @ 0x55986b9faac0] Changing bps from 0 to 8
[mjpeg @ 0x55986b9faac0] sof0: picture: 160x120
[mjpeg @ 0x55986b9faac0] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x55986b9faac0] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x55986b9faac0] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x55986b9faac0] pix fmt id 21111100
[mjpeg @ 0x55986b9faac0] Format yuvj422p chosen by get_format().
[mjpeg @ 0x55986b9faac0] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x55986b9faac0] escaping removed 159672 bytes
[mjpeg @ 0x55986b9faac0] marker=da avail_size_in_buf=162916
[mjpeg @ 0x55986b9faac0] marker parser used 3244 bytes (25952 bits)
[mjpeg @ 0x55986b9faac0] marker=d9 avail_size_in_buf=159663
[mjpeg @ 0x55986b9faac0] decode frame unused 159663 bytes
[image2pipe @ 0x55986b9f0780] stream 0: start_time: NOPTS duration: NOPTS
[image2pipe @ 0x55986b9f0780] format: start_time: NOPTS duration: NOPTS (estimate from bit rate) bitrate=0 kb/s
[image2pipe @ 0x55986b9f0780] After avformat_find_stream_info() pos: 219805 bytes read:219805 seeks:0 frames:2
Input #0, image2pipe, from '/home/fritsch/schurz/5gOk0JtwjdIv.jpg':

Duration: N/A, bitrate: N/A

Stream #0:0, 2, 1/25: Video: mjpeg (Baseline), 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 160x120 [SAR 72:72 DAR 4:3], 0/1, 25 tbr, 25 tbn, 25 tbc

Successfully opened the file.
Parsing a group of options: output url hurz2.jpg.
Successfully parsed a group of options.
Opening an output file: hurz2.jpg.
Successfully opened the file.
Stream mapping:

Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))

Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x55986b9f2740] marker=d8 avail_size_in_buf=56310
[mjpeg @ 0x55986b9f2740] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9f2740] marker=e0 avail_size_in_buf=56308
[mjpeg @ 0x55986b9f2740] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x55986b9f2740] marker=e1 avail_size_in_buf=56290
[mjpeg @ 0x55986b9f2740] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x55986b9f2740] marker parser used 2 bytes (16 bits)
[mjpeg @ 0x55986b9f2740] marker=d9 avail_size_in_buf=24334
[mjpeg @ 0x55986b9f2740] Found EOI before any SOF, ignoring
[mjpeg @ 0x55986b9f2740] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9f2740] No JPEG data found in image
Error while decoding stream #0:0: Invalid data found when processing input
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x55986b9f2740] marker=d8 avail_size_in_buf=163491
[mjpeg @ 0x55986b9f2740] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55986b9f2740] marker=db avail_size_in_buf=163489
[mjpeg @ 0x55986b9f2740] index=0
[mjpeg @ 0x55986b9f2740] qscale[0]: 6
[mjpeg @ 0x55986b9f2740] index=1
[mjpeg @ 0x55986b9f2740] qscale[1]: 13
[mjpeg @ 0x55986b9f2740] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x55986b9f2740] marker=c4 avail_size_in_buf=163355
[mjpeg @ 0x55986b9f2740] class=0 index=0 nb_codes=12
[mjpeg @ 0x55986b9f2740] class=1 index=0 nb_codes=251
[mjpeg @ 0x55986b9f2740] class=0 index=1 nb_codes=12
[mjpeg @ 0x55986b9f2740] class=1 index=1 nb_codes=251
[mjpeg @ 0x55986b9f2740] marker parser used 418 bytes (3344 bits)
[mjpeg @ 0x55986b9f2740] marker=c0 avail_size_in_buf=162935
[mjpeg @ 0x55986b9f2740] sof0: picture: 160x120
[mjpeg @ 0x55986b9f2740] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x55986b9f2740] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x55986b9f2740] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x55986b9f2740] pix fmt id 21111100
[mjpeg @ 0x55986b9f2740] Format yuvj422p chosen by get_format().
[mjpeg @ 0x55986b9f2740] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x55986b9f2740] escaping removed 159672 bytes
[mjpeg @ 0x55986b9f2740] marker=da avail_size_in_buf=162916
[mjpeg @ 0x55986b9f2740] component: 0
[mjpeg @ 0x55986b9f2740] component: 1
[mjpeg @ 0x55986b9f2740] component: 2
[mjpeg @ 0x55986b9f2740] marker parser used 3243 bytes (25944 bits)
[mjpeg @ 0x55986b9f2740] marker=d9 avail_size_in_buf=159663
[mjpeg @ 0x55986b9f2740] decode frame unused 159663 bytes
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x55986ba49780] Setting 'video_size' to value '160x120'
[graph 0 input from stream 0:0 @ 0x55986ba49780] Setting 'pix_fmt' to value '13'
[graph 0 input from stream 0:0 @ 0x55986ba49780] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x55986ba49780] Setting 'pixel_aspect' to value '72/72'
[graph 0 input from stream 0:0 @ 0x55986ba49780] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x55986ba49780] w:160 h:120 pixfmt:yuvj422p tb:1/25 fr:25/1 sar:72/72
[format @ 0x55986ba49bc0] Setting 'pix_fmts' to value 'yuvj420p|yuvj422p|yuvj444p'
[AVFilterGraph @ 0x55986b9f9000] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[mjpeg @ 0x55986b9f4b80] Forcing thread count to 1 for MJPEG encoding, use -thread_type slice or a constant quantizer if you want to use multiple cpu cores
[mjpeg @ 0x55986b9f4b80] intra_quant_bias = 96 inter_quant_bias = 0
Output #0, image2, to 'hurz2.jpg':

Metadata:

encoder : Lavf58.45.100
Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj422p(pc, center), 160x120 [SAR 72:72 DAR 4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:

encoder : Lavc58.91.100 mjpeg

Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

Not duplicating 1 initial frames
[image2 @ 0x55986b9f2b80] Opening 'hurz2.jpg' for writing
[file @ 0x55986baca4c0] Setting default whitelist 'file,crypto,data'
[AVIOContext @ 0x55986bad0840] Statistics: 0 seeks, 1 writeouts
[out_0_0 @ 0x55986ba4a300] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=3.1 Lsize=N/A time=00:00:00.08 bitrate=N/A speed=25.1x
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/fritsch/schurz/5gOk0JtwjdIv.jpg):

Input stream #0:0 (video): 2 packets read (219805 bytes); 1 frames decoded;
Total: 2 packets (219805 bytes) demuxed

Output file #0 (hurz2.jpg):

Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (4306 bytes);
Total: 1 packets (4306 bytes) muxed

1 frames successfully decoded, 1 decoding errors
[AVIOContext @ 0x55986b9f9700] Statistics: 219805 bytes read, 0 seeks

We use the image pipe functionality in kodi, via:

https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/FFmpegImage.cpp#L199

Attachments (1)

5gOk0JtwjdIv.jpg (214.7 KB ) - added by fritsch 15 months ago.
Image producing the issue

Download all attachments as: .zip

Change History (17)

by fritsch, 15 months ago

Attachment: 5gOk0JtwjdIv.jpg added

Image producing the issue

comment:1 by fritsch, 15 months ago

With ffmpeg 4.2.4 and image pipe:

Clipping frame in rate conversion by 0.000008
[image2 @ 0x561a6578da40] Opening 'hurz2.jpg' for writing
[file @ 0x561a65a3d9c0] Setting default whitelist 'file,crypto'
[AVIOContext @ 0x561a65a29500] Statistics: 0 seeks, 1 writeouts
[out_0_0 @ 0x561a657a8a80] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=5.4 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=1.62x
video:68kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/fritsch/schurz/5gOk0JtwjdIv.jpg):

Input stream #0:0 (video): 1 packets read (219805 bytes); 1 frames decoded;
Total: 1 packets (219805 bytes) demuxed

Output file #0 (hurz2.jpg):

Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (69576 bytes);
Total: 1 packets (69576 bytes) muxed

1 frames successfully decoded, 0 decoding errors

comment:2 by Carl Eugen Hoyos, 14 months ago

Keywords: mjpeg regression added; 4.3.1 removed
Version: unspecified

Please test with current FFmpeg git head - the only version supported on this bug tracker - to make this a valid ticket and please find out which change introduced the regression.

comment:3 by fritsch, 14 months ago

ffmpeg -loglevel trace -f image2pipe -i ~/schurz/5gOk0JtwjdIv.jpg hurzmaster.jpg

fritsch@L380:~/Desktop/FFmpeg$ ./ffmpeg -loglevel trace -f image2pipe -i ~/schurz/5gOk0JtwjdIv.jpg hurzmaster.jpg
ffmpeg version N-99888-g5c7823ff1c Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration:
libavutil 56. 60.100 / 56. 60.100
libavcodec 58.112.101 / 58.112.101
libavformat 58. 64.100 / 58. 64.100
libavdevice 58. 11.102 / 58. 11.102
libavfilter 7. 89.100 / 7. 89.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'image2pipe'.
Reading option '-i' ... matched as input url with argument '/home/fritsch/schurz/5gOk0JtwjdIv.jpg'.
Reading option 'hurzmaster.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
Applying option f (force format) with argument image2pipe.
Successfully parsed a group of options.
Opening an input file: /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
[image2pipe @ 0x55e967aa9780] Opening '/home/fritsch/schurz/5gOk0JtwjdIv.jpg' for reading
[file @ 0x55e967aaa300] Setting default whitelist 'file,crypto,data'
[image2pipe @ 0x55e967aa9780] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0x55e967ab3b80] marker=d8 avail_size_in_buf=56310
[mjpeg @ 0x55e967ab3b80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967ab3b80] marker=e0 avail_size_in_buf=56308
[mjpeg @ 0x55e967ab3b80] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x55e967ab3b80] marker=e1 avail_size_in_buf=56290
[mjpeg @ 0x55e967ab3b80] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x55e967ab3b80] marker parser used 2 bytes (16 bits)
[mjpeg @ 0x55e967ab3b80] marker=d9 avail_size_in_buf=24334
[mjpeg @ 0x55e967ab3b80] Found EOI before any SOF, ignoring
[mjpeg @ 0x55e967ab3b80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967ab3b80] No JPEG data found in image
[mjpeg @ 0x55e967ab3b80] marker=d8 avail_size_in_buf=163491
[mjpeg @ 0x55e967ab3b80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967ab3b80] marker=db avail_size_in_buf=163489
[mjpeg @ 0x55e967ab3b80] index=0
[mjpeg @ 0x55e967ab3b80] qscale[0]: 6
[mjpeg @ 0x55e967ab3b80] index=1
[mjpeg @ 0x55e967ab3b80] qscale[1]: 13
[mjpeg @ 0x55e967ab3b80] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x55e967ab3b80] marker=c4 avail_size_in_buf=163355
[mjpeg @ 0x55e967ab3b80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967ab3b80] marker=c0 avail_size_in_buf=162935
[mjpeg @ 0x55e967ab3b80] Changing bps from 0 to 8
[mjpeg @ 0x55e967ab3b80] sof0: picture: 160x120
[mjpeg @ 0x55e967ab3b80] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x55e967ab3b80] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x55e967ab3b80] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x55e967ab3b80] pix fmt id 21111100
[mjpeg @ 0x55e967ab3b80] Format yuvj422p chosen by get_format().
[mjpeg @ 0x55e967ab3b80] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x55e967ab3b80] escaping removed 159672 bytes
[mjpeg @ 0x55e967ab3b80] marker=da avail_size_in_buf=162916
[mjpeg @ 0x55e967ab3b80] marker parser used 3244 bytes (25952 bits)
[mjpeg @ 0x55e967ab3b80] marker=d9 avail_size_in_buf=159663
[mjpeg @ 0x55e967ab3b80] decode frame unused 159663 bytes
[image2pipe @ 0x55e967aa9780] stream 0: start_time: NOPTS duration: NOPTS
[image2pipe @ 0x55e967aa9780] format: start_time: NOPTS duration: NOPTS (estimate from bit rate) bitrate=0 kb/s
[image2pipe @ 0x55e967aa9780] After avformat_find_stream_info() pos: 219805 bytes read:219805 seeks:0 frames:2
Input #0, image2pipe, from '/home/fritsch/schurz/5gOk0JtwjdIv.jpg':

Duration: N/A, bitrate: N/A

Stream #0:0, 2, 1/25: Video: mjpeg (Baseline), 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 160x120 [SAR 72:72 DAR 4:3], 0/1, 25 tbr, 25 tbn, 25 tbc

Successfully opened the file.
Parsing a group of options: output url hurzmaster.jpg.
Successfully parsed a group of options.
Opening an output file: hurzmaster.jpg.
Successfully opened the file.
Stream mapping:

Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))

Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x55e967aaba80] marker=d8 avail_size_in_buf=56310
[mjpeg @ 0x55e967aaba80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967aaba80] marker=e0 avail_size_in_buf=56308
[mjpeg @ 0x55e967aaba80] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x55e967aaba80] marker=e1 avail_size_in_buf=56290
[mjpeg @ 0x55e967aaba80] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x55e967aaba80] marker parser used 2 bytes (16 bits)
[mjpeg @ 0x55e967aaba80] marker=d9 avail_size_in_buf=24334
[mjpeg @ 0x55e967aaba80] Found EOI before any SOF, ignoring
[mjpeg @ 0x55e967aaba80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967aaba80] No JPEG data found in image
Error while decoding stream #0:0: Invalid data found when processing input

cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x55e967aaba80] marker=d8 avail_size_in_buf=163491
[mjpeg @ 0x55e967aaba80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x55e967aaba80] marker=db avail_size_in_buf=163489
[mjpeg @ 0x55e967aaba80] index=0
[mjpeg @ 0x55e967aaba80] qscale[0]: 6
[mjpeg @ 0x55e967aaba80] index=1
[mjpeg @ 0x55e967aaba80] qscale[1]: 13
[mjpeg @ 0x55e967aaba80] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x55e967aaba80] marker=c4 avail_size_in_buf=163355
[mjpeg @ 0x55e967aaba80] class=0 index=0 nb_codes=12
[mjpeg @ 0x55e967aaba80] class=1 index=0 nb_codes=162
[mjpeg @ 0x55e967aaba80] class=0 index=1 nb_codes=12
[mjpeg @ 0x55e967aaba80] class=1 index=1 nb_codes=162
[mjpeg @ 0x55e967aaba80] marker parser used 418 bytes (3344 bits)
[mjpeg @ 0x55e967aaba80] marker=c0 avail_size_in_buf=162935
[mjpeg @ 0x55e967aaba80] sof0: picture: 160x120
[mjpeg @ 0x55e967aaba80] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x55e967aaba80] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x55e967aaba80] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x55e967aaba80] pix fmt id 21111100
[mjpeg @ 0x55e967aaba80] Format yuvj422p chosen by get_format().
[mjpeg @ 0x55e967aaba80] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x55e967aaba80] escaping removed 159672 bytes
[mjpeg @ 0x55e967aaba80] marker=da avail_size_in_buf=162916
[mjpeg @ 0x55e967aaba80] component: 0
[mjpeg @ 0x55e967aaba80] component: 1
[mjpeg @ 0x55e967aaba80] component: 2
[mjpeg @ 0x55e967aaba80] marker parser used 3243 bytes (25944 bits)
[mjpeg @ 0x55e967aaba80] marker=d9 avail_size_in_buf=159663
[mjpeg @ 0x55e967aaba80] decode frame unused 159663 bytes
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x55e967b02f80] Setting 'video_size' to value '160x120'
[graph 0 input from stream 0:0 @ 0x55e967b02f80] Setting 'pix_fmt' to value '13'
[graph 0 input from stream 0:0 @ 0x55e967b02f80] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x55e967b02f80] Setting 'pixel_aspect' to value '72/72'
[graph 0 input from stream 0:0 @ 0x55e967b02f80] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x55e967b02f80] w:160 h:120 pixfmt:yuvj422p tb:1/25 fr:25/1 sar:72/72
[format @ 0x55e967b01d00] Setting 'pix_fmts' to value 'yuvj420p|yuvj422p|yuvj444p'
[AVFilterGraph @ 0x55e967b01c00] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[mjpeg @ 0x55e967ab16c0] Forcing thread count to 1 for MJPEG encoding, use -thread_type slice or a constant quantizer if you want to use multiple cpu cores
[mjpeg @ 0x55e967ab16c0] intra_quant_bias = 96 inter_quant_bias = 0
Output #0, image2, to 'hurzmaster.jpg':

Metadata:

encoder : Lavf58.64.100
Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, progressive, center), 160x120 [SAR 72:72 DAR 4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:

encoder : Lavc58.112.101 mjpeg

Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

Not duplicating 1 initial frames
[image2 @ 0x55e967aabec0] Opening 'hurzmaster.jpg' for writing
[file @ 0x55e967b83b00] Setting default whitelist 'file,crypto,data'
[AVIOContext @ 0x55e967b89c80] Statistics: 0 seeks, 1 writeouts
[out_0_0 @ 0x55e967b039c0] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=3.1 Lsize=N/A time=00:00:00.08 bitrate=N/A speed=11.6x
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/fritsch/schurz/5gOk0JtwjdIv.jpg):

Input stream #0:0 (video): 2 packets read (219805 bytes); 1 frames decoded;
Total: 2 packets (219805 bytes) demuxed

Output file #0 (hurzmaster.jpg):

Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (4307 bytes);
Total: 1 packets (4307 bytes) muxed

1 frames successfully decoded, 1 decoding errors
[AVIOContext @ 0x55e967ab2700] Statistics: 219805 bytes read, 0 seeks

Could reproduce with master from today: 5c7823ff1cffff55f25169492d263bca934880a2

Will try to bisect if I get a chance today.

comment:4 by fritsch, 14 months ago

Bisect result:

fritsch@L380:~/Desktop/FFmpeg$ git bisect good
ec3d8a0e6945fe015d16cd98a1e7dbb4be815c15 is the first bad commit
commit ec3d8a0e6945fe015d16cd98a1e7dbb4be815c15
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 10 22:23:41 2019 +0200

avcodec/mjpeg_parser: Make parser a bit more robust with unclean input


Helps: test_roman.mjpeg (note this is not really just mjpeg)


Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

libavcodec/mjpeg_parser.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

comment:5 by Nicolas George, 14 months ago

What is your issue exactly? New ffmpeg decodes one frame and tells you there is more data that it did not manage to decode. Old ffmpeg used to decode one frame and pretend everything was fine. The new behavior seems like an improvement.

comment:6 by fritsch, 14 months ago

Issue exactly:

ffmpeg before this change: Output would be a 64 KB image
ffmpeg after this change: something (a 4kb image is output) and the real image won't as decoding it results in "Invalid data found when processing input"

Which ffmpeg command would you suggest to extract the full image? And how would you workaround that in code? (e.g. use image2 demuxer to parse it away?)

And how do you explain the changed behaviour between image2pipe and image2 - one is creating an error, the other one is outputting the 64 kb frame?

comment:7 by fritsch, 14 months ago

See below my expectation using image2 instead of the pipe:

fritsch@L380:~/Desktop/FFmpeg$

./ffmpeg -loglevel trace -f image2 -i ~/schurz/5gOk0JtwjdIv.jpg hurz16.jpg

ffmpeg version N-99888-g5c7823ff1c Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration: --disable-doc
libavutil 56. 60.100 / 56. 60.100
libavcodec 58.112.101 / 58.112.101
libavformat 58. 64.100 / 58. 64.100
libavdevice 58. 11.102 / 58. 11.102
libavfilter 7. 89.100 / 7. 89.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'image2'.
Reading option '-i' ... matched as input url with argument '/home/fritsch/schurz/5gOk0JtwjdIv.jpg'.
Reading option 'hurz16.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
Applying option f (force format) with argument image2.
Successfully parsed a group of options.
Opening an input file: /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
[image2 @ 0x563e4267e780] Opening '/home/fritsch/schurz/5gOk0JtwjdIv.jpg' for reading
[file @ 0x563e42689300] Setting default whitelist 'file,crypto,data'
[AVIOContext @ 0x563e42691480] Statistics: 219805 bytes read, 0 seeks
[mjpeg @ 0x563e42680500] marker=d8 avail_size_in_buf=219803
[mjpeg @ 0x563e42680500] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x563e42680500] marker=e0 avail_size_in_buf=219801
[mjpeg @ 0x563e42680500] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x563e42680500] marker=e1 avail_size_in_buf=219783
[mjpeg @ 0x563e42680500] marker parser used 64481 bytes (515848 bits)
[mjpeg @ 0x563e42680500] marker=db avail_size_in_buf=155299
[mjpeg @ 0x563e42680500] index=0
[mjpeg @ 0x563e42680500] qscale[0]: 1
[mjpeg @ 0x563e42680500] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x563e42680500] marker=db avail_size_in_buf=155230
[mjpeg @ 0x563e42680500] index=1
[mjpeg @ 0x563e42680500] qscale[1]: 2
[mjpeg @ 0x563e42680500] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x563e42680500] marker=c0 avail_size_in_buf=155161
[mjpeg @ 0x563e42680500] Changing bps from 0 to 8
[mjpeg @ 0x563e42680500] sof0: picture: 800x600
[mjpeg @ 0x563e42680500] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x563e42680500] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x563e42680500] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x563e42680500] pix fmt id 21111100
[mjpeg @ 0x563e42680500] Format yuvj422p chosen by get_format().
[mjpeg @ 0x563e42680500] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x563e42680500] marker=c4 avail_size_in_buf=155142
[mjpeg @ 0x563e42680500] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x563e42680500] marker=c4 avail_size_in_buf=155111
[mjpeg @ 0x563e42680500] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x563e42680500] marker=c4 avail_size_in_buf=155032
[mjpeg @ 0x563e42680500] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x563e42680500] marker=c4 avail_size_in_buf=155003
[mjpeg @ 0x563e42680500] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x563e42680500] escaping removed 629 bytes
[mjpeg @ 0x563e42680500] marker=da avail_size_in_buf=154946
[mjpeg @ 0x563e42680500] marker parser used 154317 bytes (1234536 bits)
[mjpeg @ 0x563e42680500] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x563e42680500] decode frame unused 0 bytes
[image2 @ 0x563e4267e780] stream 0: start_time: 0 duration: 0.04
[image2 @ 0x563e4267e780] format: start_time: 0 duration: 0.04 (estimate from stream) bitrate=0 kb/s
Input #0, image2, from '/home/fritsch/schurz/5gOk0JtwjdIv.jpg':

Duration: 00:00:00.04, start: 0.000000, bitrate: N/A

Stream #0:0, 1, 1/25: Video: mjpeg (Baseline), 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 800x600 [SAR 72:72 DAR 4:3], 0/1, 25 tbr, 25 tbn, 25 tbc

Successfully opened the file.
Parsing a group of options: output url hurz16.jpg.
Successfully parsed a group of options.
Opening an output file: hurz16.jpg.
Successfully opened the file.
Stream mapping:

Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))

Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x563e42682140] marker=d8 avail_size_in_buf=219803
[mjpeg @ 0x563e42682140] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x563e42682140] marker=e0 avail_size_in_buf=219801
[mjpeg @ 0x563e42682140] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x563e42682140] marker=e1 avail_size_in_buf=219783
[mjpeg @ 0x563e42682140] marker parser used 64481 bytes (515848 bits)
[mjpeg @ 0x563e42682140] marker=db avail_size_in_buf=155299
[mjpeg @ 0x563e42682140] index=0
[mjpeg @ 0x563e42682140] qscale[0]: 1
[mjpeg @ 0x563e42682140] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x563e42682140] marker=db avail_size_in_buf=155230
[mjpeg @ 0x563e42682140] index=1
[mjpeg @ 0x563e42682140] qscale[1]: 2
[mjpeg @ 0x563e42682140] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x563e42682140] marker=c0 avail_size_in_buf=155161
[mjpeg @ 0x563e42682140] sof0: picture: 800x600
[mjpeg @ 0x563e42682140] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x563e42682140] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x563e42682140] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x563e42682140] pix fmt id 21111100
[mjpeg @ 0x563e42682140] Format yuvj422p chosen by get_format().
[mjpeg @ 0x563e42682140] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x563e42682140] marker=c4 avail_size_in_buf=155142
[mjpeg @ 0x563e42682140] class=0 index=0 nb_codes=10
[mjpeg @ 0x563e42682140] marker parser used 29 bytes (232 bits)
[mjpeg @ 0x563e42682140] marker=c4 avail_size_in_buf=155111
[mjpeg @ 0x563e42682140] class=1 index=0 nb_codes=58
[mjpeg @ 0x563e42682140] marker parser used 77 bytes (616 bits)
[mjpeg @ 0x563e42682140] marker=c4 avail_size_in_buf=155032
[mjpeg @ 0x563e42682140] class=0 index=1 nb_codes=8
[mjpeg @ 0x563e42682140] marker parser used 27 bytes (216 bits)
[mjpeg @ 0x563e42682140] marker=c4 avail_size_in_buf=155003
[mjpeg @ 0x563e42682140] class=1 index=1 nb_codes=36
[mjpeg @ 0x563e42682140] marker parser used 55 bytes (440 bits)
[mjpeg @ 0x563e42682140] escaping removed 629 bytes
[mjpeg @ 0x563e42682140] marker=da avail_size_in_buf=154946
[mjpeg @ 0x563e42682140] component: 0
[mjpeg @ 0x563e42682140] component: 1
[mjpeg @ 0x563e42682140] component: 2
[mjpeg @ 0x563e42682140] marker parser used 154316 bytes (1234527 bits)
[mjpeg @ 0x563e42682140] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x563e42682140] decode frame unused 0 bytes
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x563e4279a4c0] Setting 'video_size' to value '800x600'
[graph 0 input from stream 0:0 @ 0x563e4279a4c0] Setting 'pix_fmt' to value '13'
[graph 0 input from stream 0:0 @ 0x563e4279a4c0] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x563e4279a4c0] Setting 'pixel_aspect' to value '72/72'
[graph 0 input from stream 0:0 @ 0x563e4279a4c0] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x563e4279a4c0] w:800 h:600 pixfmt:yuvj422p tb:1/25 fr:25/1 sar:72/72
[format @ 0x563e4279ad80] Setting 'pix_fmts' to value 'yuvj420p|yuvj422p|yuvj444p'
[AVFilterGraph @ 0x563e42799380] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[mjpeg @ 0x563e42690d00] Forcing thread count to 1 for MJPEG encoding, use -thread_type slice or a constant quantizer if you want to use multiple cpu cores
[mjpeg @ 0x563e42690d00] intra_quant_bias = 96 inter_quant_bias = 0
Output #0, image2, to 'hurz16.jpg':

Metadata:

encoder : Lavf58.64.100
Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, progressive, center), 800x600 [SAR 72:72 DAR 4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:

encoder : Lavc58.112.101 mjpeg

Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

Clipping frame in rate conversion by 0.000008
[image2 @ 0x563e42682580] Opening 'hurz16.jpg' for writing
[file @ 0x563e429720c0] Setting default whitelist 'file,crypto,data'
[AVIOContext @ 0x563e4295df00] Statistics: 0 seeks, 1 writeouts
[out_0_0 @ 0x563e4279ab00] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=5.4 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=2.18x
video:68kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/fritsch/schurz/5gOk0JtwjdIv.jpg):

Input stream #0:0 (video): 1 packets read (219805 bytes); 1 frames decoded;
Total: 1 packets (219805 bytes) demuxed

Output file #0 (hurz16.jpg):

Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (69577 bytes);
Total: 1 packets (69577 bytes) muxed

1 frames successfully decoded, 0 decoding errors

comment:8 by Nicolas George, 14 months ago

In every console output, you have quoted 1 frames successfully decoded, and never mentioned the successfully decoded frame was wrong. It would have been helpful to start with that.

image2 reads one image per file. image2pipe reads many images concatenated together. Therefore, image2pipe, unlike image2, needs to first split the frames, which is a complex task and fragile with regard to corrupted data.

If you know you have only one image, you should be using image2 anyway.

comment:9 by fritsch, 14 months ago

Reason: In older version, there was no two images, but only the "normal one". It's still not clear to me why image2 skips a small one away. I hope that's not some progressive preview or something.

So in general you suggest, that we should be using image2 for our png / jpeg images if we only expect one image anyways, right?

Code is here: https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/FFmpegImage.cpp#L199

Reason back at the time was, that we could shorting detection and parsing (is_jpeg, is_png) by a lot and then used the pipes directly.

But if I get you right using the *_pipe was always wrong and worked by accident - we should use image2 instead?

comment:10 by Nicolas George, 14 months ago

image2 does not do anything, it just reads the file as it is.

If you want to decode a single image from a well-delimited block of data, don't use a demuxer, use the decoder directly.

comment:11 by fritsch, 14 months ago

Okay, means - I really should be using image2 instead of *_pipe correct and close this bugreport as this is not a regression but an enhancement and we used it wrong forever?

I ask that dumb, you know, cause we prepare our first alpha version of kodi v19 - and the above change, changed behaviour and now I get reports of "my jpeg does not display anymore at all".

I trust you on this and will exactly do what you suggest.

comment:12 by Nicolas George, 14 months ago

As I said, you don't need to even use image2, you don't need a demuxer at all.

As for whether the new behavior is an enhancement or a regression, I'll let somebody who knows the JPEG format better. But it does not have to affect you.

And in the future, read more carefully the console output you quote, and explain exactly your issue.

comment:13 by fritsch, 14 months ago

Thanks for your advice. Sorry, I am not an expert in reading the logs of your software, which is why I provided them uncut.

The behaviour of the decoder itself changed as well, see below:

FFmpeg 4.2.4:

  ffmpeg -loglevel trace -f mjpeg -i ~/schurz/5gOk0JtwjdIv.jpg hurz21.jpg

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'mjpeg'.
Reading option '-i' ... matched as input url with argument '/home/fritsch/schurz/5gOk0JtwjdIv.jpg'.
Reading option 'hurz21.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
Applying option f (force format) with argument mjpeg.
Successfully parsed a group of options.
Opening an input file: /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
[mjpeg @ 0x560434085240] Opening '/home/fritsch/schurz/5gOk0JtwjdIv.jpg' for reading
[file @ 0x560434085cc0] Setting default whitelist 'file,crypto'
[mjpeg @ 0x560434085240] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0x56043408ef00] marker=d8 avail_size_in_buf=219803
[mjpeg @ 0x56043408ef00] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x56043408ef00] marker=e0 avail_size_in_buf=219801
[mjpeg @ 0x56043408ef00] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x56043408ef00] marker=e1 avail_size_in_buf=219783
[mjpeg @ 0x56043408ef00] marker parser used 64481 bytes (515848 bits)
[mjpeg @ 0x56043408ef00] marker=db avail_size_in_buf=155299
[mjpeg @ 0x56043408ef00] index=0
[mjpeg @ 0x56043408ef00] qscale[0]: 1
[mjpeg @ 0x56043408ef00] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x56043408ef00] marker=db avail_size_in_buf=155230
[mjpeg @ 0x56043408ef00] index=1
[mjpeg @ 0x56043408ef00] qscale[1]: 2
[mjpeg @ 0x56043408ef00] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x56043408ef00] marker=c0 avail_size_in_buf=155161
[mjpeg @ 0x56043408ef00] Changing bps from 0 to 8
[mjpeg @ 0x56043408ef00] sof0: picture: 800x600
[mjpeg @ 0x56043408ef00] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x56043408ef00] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x56043408ef00] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x56043408ef00] pix fmt id 21111100
[mjpeg @ 0x56043408ef00] Format yuvj422p chosen by get_format().
[mjpeg @ 0x56043408ef00] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x56043408ef00] marker=c4 avail_size_in_buf=155142
[mjpeg @ 0x56043408ef00] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x56043408ef00] marker=c4 avail_size_in_buf=155111
[mjpeg @ 0x56043408ef00] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x56043408ef00] marker=c4 avail_size_in_buf=155032
[mjpeg @ 0x56043408ef00] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x56043408ef00] marker=c4 avail_size_in_buf=155003
[mjpeg @ 0x56043408ef00] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x56043408ef00] escaping removed 629 bytes
[mjpeg @ 0x56043408ef00] marker=da avail_size_in_buf=154946
[mjpeg @ 0x56043408ef00] marker parser used 154317 bytes (1234536 bits)
[mjpeg @ 0x56043408ef00] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x56043408ef00] decode frame unused 0 bytes
[mjpeg @ 0x560434085240] All info found
[mjpeg @ 0x560434085240] stream 0: start_time: -7686143364045.646 duration: -7686143364045.646
[mjpeg @ 0x560434085240] format: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=0 kb/s
[mjpeg @ 0x560434085240] After avformat_find_stream_info() pos: 219805 bytes read:219805 seeks:0 frames:1
Input #0, mjpeg, from '/home/fritsch/schurz/5gOk0JtwjdIv.jpg':

Duration: N/A, bitrate: N/A

Stream #0:0, 1, 1/1200000: Video: mjpeg (Baseline), 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 800x600 [SAR 72:72 DAR 4:3], 0/1, 25 tbr, 1200k tbn, 25 tbc

Successfully opened the file.
Parsing a group of options: output url hurz21.jpg.
Successfully parsed a group of options.
Opening an output file: hurz21.jpg.
Successfully opened the file.
Stream mapping:

Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))

Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x560434095700] marker=d8 avail_size_in_buf=219803
[mjpeg @ 0x560434095700] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x560434095700] marker=e0 avail_size_in_buf=219801
[mjpeg @ 0x560434095700] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x560434095700] marker=e1 avail_size_in_buf=219783
[mjpeg @ 0x560434095700] marker parser used 64481 bytes (515848 bits)
[mjpeg @ 0x560434095700] marker=db avail_size_in_buf=155299
[mjpeg @ 0x560434095700] index=0
[mjpeg @ 0x560434095700] qscale[0]: 1
[mjpeg @ 0x560434095700] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x560434095700] marker=db avail_size_in_buf=155230
[mjpeg @ 0x560434095700] index=1
[mjpeg @ 0x560434095700] qscale[1]: 2
[mjpeg @ 0x560434095700] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x560434095700] marker=c0 avail_size_in_buf=155161
[mjpeg @ 0x560434095700] sof0: picture: 800x600
[mjpeg @ 0x560434095700] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x560434095700] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x560434095700] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x560434095700] pix fmt id 21111100
[mjpeg @ 0x560434095700] Format yuvj422p chosen by get_format().
[mjpeg @ 0x560434095700] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x560434095700] marker=c4 avail_size_in_buf=155142
[mjpeg @ 0x560434095700] class=0 index=0 nb_codes=10
[mjpeg @ 0x560434095700] marker parser used 29 bytes (232 bits)
[mjpeg @ 0x560434095700] marker=c4 avail_size_in_buf=155111
[mjpeg @ 0x560434095700] class=1 index=0 nb_codes=242
[mjpeg @ 0x560434095700] marker parser used 77 bytes (616 bits)
[mjpeg @ 0x560434095700] marker=c4 avail_size_in_buf=155032
[mjpeg @ 0x560434095700] class=0 index=1 nb_codes=8
[mjpeg @ 0x560434095700] marker parser used 27 bytes (216 bits)
[mjpeg @ 0x560434095700] marker=c4 avail_size_in_buf=155003
[mjpeg @ 0x560434095700] class=1 index=1 nb_codes=242
[mjpeg @ 0x560434095700] marker parser used 55 bytes (440 bits)
[mjpeg @ 0x560434095700] escaping removed 629 bytes
[mjpeg @ 0x560434095700] marker=da avail_size_in_buf=154946
[mjpeg @ 0x560434095700] component: 0
[mjpeg @ 0x560434095700] component: 1
[mjpeg @ 0x560434095700] component: 2
[mjpeg @ 0x560434095700] marker parser used 154316 bytes (1234527 bits)
[mjpeg @ 0x560434095700] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x560434095700] decode frame unused 0 bytes
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x5604341a6e00] Setting 'video_size' to value '800x600'
[graph 0 input from stream 0:0 @ 0x5604341a6e00] Setting 'pix_fmt' to value '13'
[graph 0 input from stream 0:0 @ 0x5604341a6e00] Setting 'time_base' to value '1/1200000'
[graph 0 input from stream 0:0 @ 0x5604341a6e00] Setting 'pixel_aspect' to value '72/72'
[graph 0 input from stream 0:0 @ 0x5604341a6e00] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x5604341a6e00] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x5604341a6e00] w:800 h:600 pixfmt:yuvj422p tb:1/1200000 fr:25/1 sar:72/72 sws_param:flags=2
[format @ 0x560434092e00] Setting 'pix_fmts' to value 'yuvj420p|yuvj422p|yuvj444p'
[AVFilterGraph @ 0x560434092d40] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[mjpeg @ 0x560434093bc0] Forcing thread count to 1 for MJPEG encoding, use -thread_type slice or a constant quantizer if you want to use multiple cpu cores
[mjpeg @ 0x560434093bc0] intra_quant_bias = 96 inter_quant_bias = 0
Output #0, image2, to 'hurz21.jpg':

Metadata:

encoder : Lavf58.29.100
Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj422p(pc, center), 800x600 [SAR 72:72 DAR 4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:

encoder : Lavc58.54.100 mjpeg

Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1

Clipping frame in rate conversion by 0.000008
[image2 @ 0x560434095b80] Opening 'hurz21.jpg' for writing
[file @ 0x56043433a1c0] Setting default whitelist 'file,crypto'
[AVIOContext @ 0x560434325c40] Statistics: 0 seeks, 1 writeouts
[out_0_0 @ 0x5604341a7500] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=5.4 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=2.39x
video:68kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/fritsch/schurz/5gOk0JtwjdIv.jpg):

Input stream #0:0 (video): 1 packets read (219805 bytes); 1 frames decoded;
Total: 1 packets (219805 bytes) demuxed
Output file #0 (hurz21.jpg):
Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (69576 bytes);
Total: 1 packets (69576 bytes) muxed

1 frames successfully decoded, 0 decoding errors

[AVIOContext @ 0x56043408e0c0] Statistics: 219805 bytes read, 0 seeks

Master:

ffmpeg -loglevel trace -f mjpeg -i ~/schurz/5gOk0JtwjdIv.jpg hurz22.jpg

ffmpeg version N-99888-g5c7823ff1c Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration: --disable-doc
libavutil 56. 60.100 / 56. 60.100
libavcodec 58.112.101 / 58.112.101
libavformat 58. 64.100 / 58. 64.100
libavdevice 58. 11.102 / 58. 11.102
libavfilter 7. 89.100 / 7. 89.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'mjpeg'.
Reading option '-i' ... matched as input url with argument '/home/fritsch/schurz/5gOk0JtwjdIv.jpg'.
Reading option 'hurz22.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
Applying option f (force format) with argument mjpeg.
Successfully parsed a group of options.
Opening an input file: /home/fritsch/schurz/5gOk0JtwjdIv.jpg.
[mjpeg @ 0x558a7881c780] Opening '/home/fritsch/schurz/5gOk0JtwjdIv.jpg' for reading
[file @ 0x558a7881d300] Setting default whitelist 'file,crypto,data'
[mjpeg @ 0x558a7881c780] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0x558a78826780] marker=d8 avail_size_in_buf=56310
[mjpeg @ 0x558a78826780] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78826780] marker=e0 avail_size_in_buf=56308
[mjpeg @ 0x558a78826780] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x558a78826780] marker=e1 avail_size_in_buf=56290
[mjpeg @ 0x558a78826780] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x558a78826780] marker parser used 2 bytes (16 bits)
[mjpeg @ 0x558a78826780] marker=d9 avail_size_in_buf=24334
[mjpeg @ 0x558a78826780] Found EOI before any SOF, ignoring
[mjpeg @ 0x558a78826780] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78826780] No JPEG data found in image
[mjpeg @ 0x558a78826780] marker=d8 avail_size_in_buf=163491
[mjpeg @ 0x558a78826780] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78826780] marker=db avail_size_in_buf=163489
[mjpeg @ 0x558a78826780] index=0
[mjpeg @ 0x558a78826780] qscale[0]: 6
[mjpeg @ 0x558a78826780] index=1
[mjpeg @ 0x558a78826780] qscale[1]: 13
[mjpeg @ 0x558a78826780] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x558a78826780] marker=c4 avail_size_in_buf=163355
[mjpeg @ 0x558a78826780] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78826780] marker=c0 avail_size_in_buf=162935
[mjpeg @ 0x558a78826780] Changing bps from 0 to 8
[mjpeg @ 0x558a78826780] sof0: picture: 160x120
[mjpeg @ 0x558a78826780] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x558a78826780] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x558a78826780] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x558a78826780] pix fmt id 21111100
[mjpeg @ 0x558a78826780] Format yuvj422p chosen by get_format().
[mjpeg @ 0x558a78826780] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x558a78826780] escaping removed 159672 bytes
[mjpeg @ 0x558a78826780] marker=da avail_size_in_buf=162916
[mjpeg @ 0x558a78826780] marker parser used 3244 bytes (25952 bits)
[mjpeg @ 0x558a78826780] marker=d9 avail_size_in_buf=159663
[mjpeg @ 0x558a78826780] decode frame unused 159663 bytes
[mjpeg @ 0x558a7881c780] All info found
[mjpeg @ 0x558a7881c780] stream 0: start_time: NOPTS duration: NOPTS
[mjpeg @ 0x558a7881c780] format: start_time: NOPTS duration: NOPTS (estimate from bit rate) bitrate=0 kb/s
[mjpeg @ 0x558a7881c780] After avformat_find_stream_info() pos: 219805 bytes read:219805 seeks:0 frames:2
Input #0, mjpeg, from '/home/fritsch/schurz/5gOk0JtwjdIv.jpg':

Duration: N/A, bitrate: N/A

Stream #0:0, 2, 1/1200000: Video: mjpeg (Baseline), 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 160x120 [SAR 72:72 DAR 4:3], 0/1, 25 tbr, 1200k tbn, 25 tbc

Successfully opened the file.
Parsing a group of options: output url hurz22.jpg.
Successfully parsed a group of options.
Opening an output file: hurz22.jpg.
Successfully opened the file.
Stream mapping:

Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))

Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x558a78827f80] marker=d8 avail_size_in_buf=56310
[mjpeg @ 0x558a78827f80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78827f80] marker=e0 avail_size_in_buf=56308
[mjpeg @ 0x558a78827f80] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x558a78827f80] marker=e1 avail_size_in_buf=56290
[mjpeg @ 0x558a78827f80] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x558a78827f80] marker parser used 2 bytes (16 bits)
[mjpeg @ 0x558a78827f80] marker=d9 avail_size_in_buf=24334
[mjpeg @ 0x558a78827f80] Found EOI before any SOF, ignoring
[mjpeg @ 0x558a78827f80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78827f80] No JPEG data found in image
Error while decoding stream #0:0: Invalid data found when processing input
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mjpeg @ 0x558a78827f80] marker=d8 avail_size_in_buf=163491
[mjpeg @ 0x558a78827f80] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x558a78827f80] marker=db avail_size_in_buf=163489
[mjpeg @ 0x558a78827f80] index=0
[mjpeg @ 0x558a78827f80] qscale[0]: 6
[mjpeg @ 0x558a78827f80] index=1
[mjpeg @ 0x558a78827f80] qscale[1]: 13
[mjpeg @ 0x558a78827f80] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x558a78827f80] marker=c4 avail_size_in_buf=163355
[mjpeg @ 0x558a78827f80] class=0 index=0 nb_codes=12
[mjpeg @ 0x558a78827f80] class=1 index=0 nb_codes=162
[mjpeg @ 0x558a78827f80] class=0 index=1 nb_codes=12
[mjpeg @ 0x558a78827f80] class=1 index=1 nb_codes=162
[mjpeg @ 0x558a78827f80] marker parser used 418 bytes (3344 bits)
[mjpeg @ 0x558a78827f80] marker=c0 avail_size_in_buf=162935
[mjpeg @ 0x558a78827f80] sof0: picture: 160x120
[mjpeg @ 0x558a78827f80] component 0 2:1 id: 0 quant:0
[mjpeg @ 0x558a78827f80] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x558a78827f80] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x558a78827f80] pix fmt id 21111100
[mjpeg @ 0x558a78827f80] Format yuvj422p chosen by get_format().
[mjpeg @ 0x558a78827f80] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x558a78827f80] escaping removed 159672 bytes
[mjpeg @ 0x558a78827f80] marker=da avail_size_in_buf=162916
[mjpeg @ 0x558a78827f80] component: 0
[mjpeg @ 0x558a78827f80] component: 1
[mjpeg @ 0x558a78827f80] component: 2
[mjpeg @ 0x558a78827f80] marker parser used 3243 bytes (25944 bits)
[mjpeg @ 0x558a78827f80] marker=d9 avail_size_in_buf=159663
[mjpeg @ 0x558a78827f80] decode frame unused 159663 bytes
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x558a7884b380] Setting 'video_size' to value '160x120'
[graph 0 input from stream 0:0 @ 0x558a7884b380] Setting 'pix_fmt' to value '13'
[graph 0 input from stream 0:0 @ 0x558a7884b380] Setting 'time_base' to value '1/1200000'
[graph 0 input from stream 0:0 @ 0x558a7884b380] Setting 'pixel_aspect' to value '72/72'
[graph 0 input from stream 0:0 @ 0x558a7884b380] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x558a7884b380] w:160 h:120 pixfmt:yuvj422p tb:1/1200000 fr:25/1 sar:72/72
[format @ 0x558a7884b740] Setting 'pix_fmts' to value 'yuvj420p|yuvj422p|yuvj444p'
[AVFilterGraph @ 0x558a78849fc0] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[mjpeg @ 0x558a78831280] Forcing thread count to 1 for MJPEG encoding, use -thread_type slice or a constant quantizer if you want to use multiple cpu cores
[mjpeg @ 0x558a78831280] intra_quant_bias = 96 inter_quant_bias = 0
Output #0, image2, to 'hurz22.jpg':

Metadata:

encoder : Lavf58.64.100
Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, progressive, center), 160x120 [SAR 72:72 DAR 4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:

encoder : Lavc58.112.101 mjpeg

Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

Not duplicating 1 initial frames
[image2 @ 0x558a788283c0] Opening 'hurz22.jpg' for writing
[file @ 0x558a788f6940] Setting default whitelist 'file,crypto,data'
[AVIOContext @ 0x558a788fcac0] Statistics: 0 seeks, 1 writeouts
[out_0_0 @ 0x558a7884c0c0] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=3.1 Lsize=N/A time=00:00:00.08 bitrate=N/A speed=23.9x
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/fritsch/schurz/5gOk0JtwjdIv.jpg):

Input stream #0:0 (video): 2 packets read (219805 bytes); 1 frames decoded;
Total: 2 packets (219805 bytes) demuxed
Output file #0 (hurz22.jpg):
Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (4307 bytes);
Total: 1 packets (4307 bytes) muxed

1 frames successfully decoded, 1 decoding errors
[AVIOContext @ 0x558a78825700] Statistics: 219805 bytes read, 0 seeks

Summary:
The behaviour of the decoder (and image2pipe but not image2) has changed in ffmpeg master for certain input images, meaning with the same input you get different output now. Especially that mean, that before the supplied jpeg decoded with no error and output a 64 KB image. After decoder errors out with invalid data and cannot reproduce the same image as with the latest stable version.

If this is wanted and such jpeg images shall produce two output images in the future _and_ need to be split up prior to be sent to the decoder by hand (as image2pipe fails to properly split them), then please leave a comment.

Last edited 14 months ago by fritsch (previous) (diff)

comment:14 by Craig Andrews, 14 months ago

Cc: candrews@integralblue.com added

comment:15 by Carl Eugen Hoyos, 14 months ago

Priority: normalimportant
Status: newopen
Version: unspecifiedgit-master

comment:16 by Jonathan Dieter, 13 months ago

Cc: jdieter@gmail.com added
Note: See TracTickets for help on using tickets.