Opened 8 years ago
Last modified 5 months ago
#6113 open defect
Seek to 0 jpeg image input file image causes eof of the input stream
Reported by: | remigiusz.zukowski | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avformat |
Version: | git-master | Keywords: | image2 seek mjpeg regression |
Cc: | Martin Pecka | Blocked By: | |
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
When input file is an jpeg image (any valid jpeg image) and I seek the file to 0 then the demuxer gives empty stream by immediately outputting eof.
or
I cannot rewind jpeg input stream to the beginning by seeking to 0 or any other value since the demuxer signals eof after any seek.
Does not happen for png image files.
Does not happen with 20151020-git-e91cd8a, cannot determine when exactly it was introduced.
How to reproduce
ffmpeg -ss 0 -i input.jpg output.jpg
ffmpeg version 20170130-cba4f0e
Console output
ffmpeg -v 9 -loglevel 99 -ss -1 -i d:\1.jpg d:\file.jpg ffmpeg version N-83280-gcba4f0e Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib libavutil 55. 45.100 / 55. 45.100 libavcodec 57. 75.100 / 57. 75.100 libavformat 57. 65.100 / 57. 65.100 libavdevice 57. 2.100 / 57. 2.100 libavfilter 6. 71.100 / 6. 71.100 libswscale 4. 3.101 / 4. 3.101 libswresample 2. 4.100 / 2. 4.100 libpostproc 54. 2.100 / 54. 2.100 Splitting the commandline. Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'. Reading option '-ss' ... matched as option 'ss' (set the start time offset) with argument '0'. Reading option '-i' ... matched as input url with argument 'd:\1.jpg'. Reading option 'd:\file.jpg' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option v (set logging level) with argument 9. Successfully parsed a group of options. Parsing a group of options: input url d:\1.jpg. Applying option ss (set the start time offset) with argument 0. Successfully parsed a group of options. Opening an input file: d:\1.jpg. [file @ 00000000004fae00] Setting default whitelist 'file,crypto' Probing image2 score:50 size:2048 Probing jpeg_pipe score:25 size:2048 [image2 @ 00000000004fa400] Format image2 probed with size=2048 and score=50 [image2 @ 00000000004fa400] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1 [mjpeg @ 000000000050c4c0] marker=d8 avail_size_in_buf=266292 [mjpeg @ 000000000050c4c0] marker parser used 0 bytes (0 bits) [mjpeg @ 000000000050c4c0] marker=e0 avail_size_in_buf=266290 [mjpeg @ 000000000050c4c0] marker parser used 16 bytes (128 bits) [mjpeg @ 000000000050c4c0] marker=e1 avail_size_in_buf=266272 [mjpeg @ 000000000050c4c0] marker parser used 77 bytes (616 bits) [mjpeg @ 000000000050c4c0] marker=db avail_size_in_buf=266192 [mjpeg @ 000000000050c4c0] index=0 [mjpeg @ 000000000050c4c0] qscale[0]: 2 [mjpeg @ 000000000050c4c0] marker parser used 67 bytes (536 bits) [mjpeg @ 000000000050c4c0] marker=db avail_size_in_buf=266123 [mjpeg @ 000000000050c4c0] index=1 [mjpeg @ 000000000050c4c0] qscale[1]: 5 [mjpeg @ 000000000050c4c0] marker parser used 67 bytes (536 bits) [mjpeg @ 000000000050c4c0] marker=c0 avail_size_in_buf=266054 [mjpeg @ 000000000050c4c0] Changing bps from 0 to 8 [mjpeg @ 000000000050c4c0] sof0: picture: 1600x1200 [mjpeg @ 000000000050c4c0] component 0 2:2 id: 0 quant:0 [mjpeg @ 000000000050c4c0] component 1 1:1 id: 1 quant:1 [mjpeg @ 000000000050c4c0] component 2 1:1 id: 2 quant:1 [mjpeg @ 000000000050c4c0] pix fmt id 22111100 [mjpeg @ 000000000050c4c0] marker parser used 17 bytes (136 bits) [mjpeg @ 000000000050c4c0] marker=c4 avail_size_in_buf=266035 [mjpeg @ 000000000050c4c0] marker parser used 0 bytes (0 bits) [mjpeg @ 000000000050c4c0] marker=c4 avail_size_in_buf=266002 [mjpeg @ 000000000050c4c0] marker parser used 0 bytes (0 bits) [mjpeg @ 000000000050c4c0] marker=c4 avail_size_in_buf=265819 [mjpeg @ 000000000050c4c0] marker parser used 0 bytes (0 bits) [mjpeg @ 000000000050c4c0] marker=c4 avail_size_in_buf=265786 [mjpeg @ 000000000050c4c0] marker parser used 0 bytes (0 bits) [mjpeg @ 000000000050c4c0] escaping removed 561 bytes [mjpeg @ 000000000050c4c0] marker=da avail_size_in_buf=265603 [mjpeg @ 000000000050c4c0] marker parser used 265042 bytes (2120336 bits) [mjpeg @ 000000000050c4c0] marker=d9 avail_size_in_buf=0 [mjpeg @ 000000000050c4c0] decode frame unused 0 bytes [image2 @ 00000000004fa400] stream 0: start_time: 0.000 duration: 0.040 [image2 @ 00000000004fa400] format: start_time: 0.000 duration: 0.040 bitrate=53258 kb/s [image2 @ 00000000004fa400] After avformat_find_stream_info() pos: 266294 bytes read:266294 seeks:0 frames:1 Input #0, image2, from 'd:\1.jpg': Duration: 00:00:00.04, start: 0.000000, bitrate: 53258 kb/s Stream #0:0, 1, 1/25: Video: mjpeg, 1 reference frame, yuvj420p(pc, bt470bg/unknown/unknown, center), 1600x1200 [SAR 1:1 DAR 4:3], 0/1, 25 tbr, 25 tbn, 25 tbc Successfully opened the file. Parsing a group of options: output url d:\file.jpg. Successfully parsed a group of options. Opening an output file: d:\file.jpg. Successfully opened the file. Initializing cuvid transcoding detected 4 logical cores [graph 0 input from stream 0:0 @ 000000000050b680] Setting 'video_size' to value '1600x1200' [graph 0 input from stream 0:0 @ 000000000050b680] Setting 'pix_fmt' to value '12' [graph 0 input from stream 0:0 @ 000000000050b680] Setting 'time_base' to value '1/25' [graph 0 input from stream 0:0 @ 000000000050b680] Setting 'pixel_aspect' to value '1/1' [graph 0 input from stream 0:0 @ 000000000050b680] Setting 'sws_param' to value 'flags=2' [graph 0 input from stream 0:0 @ 000000000050b680] Setting 'frame_rate' to value '25/1' [graph 0 input from stream 0:0 @ 000000000050b680] w:1600 h:1200 pixfmt:yuvj420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2 [format @ 0000000000513ba0] compat: called with args=[yuvj420p|yuvj422p|yuvj444p] [format @ 0000000000513ba0] Setting 'pix_fmts' to value 'yuvj420p|yuvj422p|yuvj444p' [AVFilterGraph @ 00000000006675a0] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed [mjpeg @ 0000000000507a40] 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 @ 0000000000507a40] intra_quant_bias = 96 inter_quant_bias = 0 Output #0, image2, to 'd:\file.jpg': Metadata: encoder : Lavf57.65.100 Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj420p(pc, center), 1600x1200 [SAR 1:1 DAR 4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc Metadata: encoder : Lavc57.75.100 mjpeg Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 Stream mapping: Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native)) Press [q] to stop, [?] for help cur_dts is invalid (this is harmless if it occurs once at the start per stream) Last message repeated 1 times No more output streams to write to, finishing. frame= 0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed= 0x video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Input file #0 (d:\1.jpg): Input stream #0:0 (video): 0 packets read (0 bytes); 0 frames decoded; Total: 0 packets (0 bytes) demuxed Output file #0 (d:\file.jpg): Output stream #0:0 (video): 0 frames encoded; 0 packets muxed (0 bytes); Total: 0 packets (0 bytes) muxed Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used) 0 frames successfully decoded, 0 decoding errors [AVIOContext @ 0000000000668d00] Statistics: 266294 bytes read, 0 seeks
Change History (6)
comment:1 by , 8 years ago
Version: | unspecified → git-master |
---|
comment:2 by , 8 years ago
Keywords: | mjpeg seek regression added |
---|
comment:3 by , 8 years ago
Component: | undetermined → avformat |
---|---|
Keywords: | image2 added; seek removed |
Priority: | normal → important |
Reproduced by developer: | set |
Status: | new → open |
For -ss 0
, this is a regression since e70d56b8 related to ticket #4849, I don't know what -ss -1
is supposed to do / has never worked afaict.
comment:4 by , 8 years ago
Keywords: | seek added |
---|
comment:5 by , 5 months ago
This has still been a problem nowadays. With ffmpeg 7.0.2, I still get empty output when seeking a JPG image to 0 (while I get 1 frame with no seek). FFMpeg reports a duration of 1/25 s and 1 frame, so I'd expect that seeking to 0 should work.
$ ffmpeg -ss 0 -i img.jpg img2.jpg ffmpeg version 7.0.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2024 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 Input #0, image2, from 'img.jpg': Duration: 00:00:00.04, start: 0.000000, bitrate: 1059428 kb/s Stream #0:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 3024x4032 [SAR 72:72 DAR 3:4], 25 fps, 25 tbr, 25 tbn Stream mapping: Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native)) Press [q] to stop, [?] for help [vost#0:0/mjpeg @ 0x3785b740] No filtered frames for output stream, trying to initialize anyway. Output #0, image2, to 'img2.jpg': Metadata: encoder : Lavf61.1.100 Stream #0:0: Video: mjpeg, yuvj444p(pc, progressive), 3024x4032 [SAR 72:72 DAR 3:4], q=2-31, 200 kb/s, 25 fps, 25 tbn Metadata: encoder : Lavc61.3.100 mjpeg Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A [out#0/image2 @ 0x37857d00] video:0KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown [out#0/image2 @ 0x37857d00] Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used) frame= 0 fps=0.0 q=0.0 Lsize=N/A time=N/A bitrate=N/A speed=N/A
comment:6 by , 5 months ago
Cc: | added |
---|
Please either explain how I can reproduce the issue (sample code) or run
git bisect
to find the change introducing the issue.