Opened 13 years ago

Closed 12 years ago

#401 closed defect (fixed)

ffmpeg fails to decode MJPG in AVI

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

Description

ffmpeg fails to decode MJPG in AVI, sample is at http://www.box.net/shared/fqqufn3ul5dlkheyu40r
mplayer successfully decodes and plays this sample.

$ ./ffmpeg -i /storage/test/mencoder/mjpg.avi -vcodec rawvideo -pix_fmt uyvy422 -vtag yuvs -an -f mov -y /tmp/o.mov
ffmpeg version N-31890-gecaf514, Copyright (c) 2000-2011 the FFmpeg developers  built on Aug 16 2011 14:34:59 with gcc 4.4.3
  configuration: --enable-debug=gdb3 --disable-optimizations --disable-asm --disable-stripping
  libavutil    51. 12. 0 / 51. 12. 0
  libavcodec   53. 10. 0 / 53. 10. 0
  libavformat  53.  7. 0 / 53.  7. 0
  libavdevice  53.  3. 0 / 53.  3. 0
  libavfilter   2. 31. 1 /  2. 31. 1
  libswscale    2.  0. 0 /  2.  0. 0
[avi @ 0x239c350] max_analyze_duration 5000000 reached at 5000000
Input #0, avi, from '/storage/test/mencoder/mjpg.avi':
  Duration: 00:06:07.93, start: 0.000000, bitrate: 227 kb/s
    Stream #0.0: Video: mjpeg, 640x480, 30 tbr, 30 tbn, 30 tbc
    Stream #0.1: Audio: pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s
[buffer @ 0x239d4b0] Invalid pixel format string '-1'
Error opening filters!

Change History (6)

comment:1 by Carl Eugen Hoyos, 13 years ago

Keywords: mjpeg added
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

Works fine with -analyzeduration 28000000

comment:2 by reimar, 13 years ago

This is probably caused by libavfilter. The (vsrc)buffer filter seems to need a pixfmt from the start.
However the filters are created before the decoder is actually opened.
So it is completely reliant on the probe filling in the pix_fmt.
However since this file is non-interleaved and FFmpeg detects this too late, the probe never gets any video data, thus does not open the decoder and thus the pix_fmt is not filled in.
This seems all rather silly though: it is quite silly that it is not tried to open the decoder during probe even if no data is available, as is opening the decoder only after the filter has been set up.

comment:3 by JK, 13 years ago

I'm having the same problem, is there any progress on this ticket yet or any known workaround?

in reply to:  2 comment:5 by Michael Niedermayer, 13 years ago

Replying to reimar:

This is probably caused by libavfilter. The (vsrc)buffer filter seems to need a pixfmt from the start.
However the filters are created before the decoder is actually opened.
So it is completely reliant on the probe filling in the pix_fmt.
However since this file is non-interleaved and FFmpeg detects this too late, the probe never gets any video data, thus does not open the decoder and thus the pix_fmt is not filled in.
This seems all rather silly though: it is quite silly that it is not tried to open the decoder during probe even if no data is available, as is opening the decoder only after the filter has been set up.

The decoder is opened in av_find_stream_info() but mjpeg can store a wide varity of pixel formats and iam not sure if the actually used one can be identified before the first frame.

comment:6 by Michael Niedermayer, 12 years ago

Component: avcodecavformat
Keywords: avi added
Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.