Opened 11 years ago
Closed 11 years ago
#3229 closed defect (fixed)
Wrong field order for mjpeg
Reported by: | hxuanyu | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avcodec |
Version: | git-master | Keywords: | mjpeg |
Cc: | ami_stuff@o2.pl | Blocked By: | |
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description (last modified by )
used ffplay to play 2 videos (both MJPEG encoded AVI file, generated by same program).
While the video having relative low resolution plays correctly, the higher resolution one show bad images.
below is the output of bad file
$ ffplay.exe bad.avi ffplay version N-58485-ga12b4bd Copyright (c) 2003-2013 the FFmpeg developers built on Nov 26 2013 22:01:46 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 55.100 / 52. 55.100 libavcodec 55. 44.100 / 55. 44.100 libavformat 55. 21.102 / 55. 21.102 libavdevice 55. 5.101 / 55. 5.101 libavfilter 3. 91.100 / 3. 91.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 [avi @ 04012d40] Stream #1: not enough frames to estimate rate; consider increasing probesize Input #0, avi, from 'bad.avi': Duration: 00:00:06.03, start: 0.000000, bitrate: 40053 kb/s Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 468x312, 30 fps, 30 tbr, 30 tbn, 30 tbc Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s [swscaler @ 040d66e0] deprecated pixel format used, make sure you did set range correctly 2.14 A-V: -0.023 fd= 0 aq= 24KB vq= 1767KB sq= 0B f=0/0 4.58 A-V: -0.024 fd= 0 aq= 20KB vq= 1753KB sq= 0B f=0/0
Samples files are here
https://dl.dropboxusercontent.com/u/89678527/good.avi
https://dl.dropboxusercontent.com/u/89678527/bad.avi
and please see attached screen shot
Attachments (1)
Change History (8)
by , 11 years ago
comment:1 by , 11 years ago
Component: | undetermined → avcodec |
---|---|
Description: | modified (diff) |
Keywords: | mjpeg added |
Reproduced by developer: | set |
Status: | new → open |
Version: | unspecified → git-master |
comment:2 by , 11 years ago
$ ffmpeg -loglevel debug -i bad.avi ffmpeg version N-59134-g1c67ad9 Copyright (c) 2000-2013 the FFmpeg developers built on Dec 16 2013 02:32:20 with gcc 4.7 (SUSE Linux) configuration: --enable-gpl libavutil 52. 58.100 / 52. 58.100 libavcodec 55. 45.101 / 55. 45.101 libavformat 55. 22.100 / 55. 22.100 libavdevice 55. 5.102 / 55. 5.102 libavfilter 3. 92.100 / 3. 92.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Splitting the commandline. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. Reading option '-i' ... matched as input file with argument 'bad.avi'. Finished splitting the commandline. Parsing a group of options: global . Applying option loglevel (set logging level) with argument debug. Successfully parsed a group of options. Parsing a group of options: input file bad.avi. Successfully parsed a group of options. Opening an input file: bad.avi. [avi @ 0x3731100] Format avi probed with size=2048 and score=100 [avi @ 0x3731760] use odml:1 st:1 removing common factor 4 from timebase [avi @ 0x3731100] Before avformat_find_stream_info() pos: 32390 bytes read:140776 seeks:6 [avi @ 0x3731100] parser not found for codec pcm_s16le, packets or times may be invalid. [mjpeg @ 0x3731ba0] marker=d8 avail_size_in_buf=239529 [mjpeg @ 0x3731ba0] marker parser used 0 bytes (0 bits) [mjpeg @ 0x3731ba0] marker=e0 avail_size_in_buf=239527 [mjpeg @ 0x3731ba0] polarity 1 [mjpeg @ 0x3731ba0] marker parser used 15 bytes (120 bits) [mjpeg @ 0x3731ba0] marker=dd avail_size_in_buf=239509 [mjpeg @ 0x3731ba0] restart interval: 0 [mjpeg @ 0x3731ba0] marker parser used 4 bytes (32 bits) [mjpeg @ 0x3731ba0] marker=db avail_size_in_buf=239503 [mjpeg @ 0x3731ba0] index=0 [mjpeg @ 0x3731ba0] qscale[0]: 0 [mjpeg @ 0x3731ba0] index=1 [mjpeg @ 0x3731ba0] qscale[1]: 0 [mjpeg @ 0x3731ba0] marker parser used 132 bytes (1056 bits) [mjpeg @ 0x3731ba0] marker=c0 avail_size_in_buf=239369 [mjpeg @ 0x3731ba0] sof0: picture: 468x156 [mjpeg @ 0x3731ba0] component 0 2:1 id: 0 quant:0 [mjpeg @ 0x3731ba0] component 1 1:1 id: 1 quant:1 [mjpeg @ 0x3731ba0] component 2 1:1 id: 2 quant:1 [mjpeg @ 0x3731ba0] pix fmt id 21111100 [mjpeg @ 0x3731ba0] marker parser used 17 bytes (136 bits) [mjpeg @ 0x3731ba0] escaping removed 119331 bytes [mjpeg @ 0x3731ba0] marker=da avail_size_in_buf=239350 [mjpeg @ 0x3731ba0] component: 0 [mjpeg @ 0x3731ba0] component: 1 [mjpeg @ 0x3731ba0] component: 2 [mjpeg @ 0x3731ba0] marker parser used 120018 bytes (960141 bits) [mjpeg @ 0x3731ba0] marker=d9 avail_size_in_buf=118322 [mjpeg @ 0x3731ba0] marker parser used 0 bytes (0 bits) [mjpeg @ 0x3731ba0] marker=d8 avail_size_in_buf=118318 [mjpeg @ 0x3731ba0] marker parser used 0 bytes (0 bits) [mjpeg @ 0x3731ba0] marker=e0 avail_size_in_buf=118316 [mjpeg @ 0x3731ba0] polarity 2 [mjpeg @ 0x3731ba0] marker parser used 15 bytes (120 bits) [mjpeg @ 0x3731ba0] marker=dd avail_size_in_buf=118298 [mjpeg @ 0x3731ba0] restart interval: 0 [mjpeg @ 0x3731ba0] marker parser used 4 bytes (32 bits) [mjpeg @ 0x3731ba0] marker=db avail_size_in_buf=118292 [mjpeg @ 0x3731ba0] index=0 [mjpeg @ 0x3731ba0] qscale[0]: 0 [mjpeg @ 0x3731ba0] index=1 [mjpeg @ 0x3731ba0] qscale[1]: 0 [mjpeg @ 0x3731ba0] marker parser used 132 bytes (1056 bits) [mjpeg @ 0x3731ba0] marker=c0 avail_size_in_buf=118158 [mjpeg @ 0x3731ba0] sof0: picture: 468x156 [mjpeg @ 0x3731ba0] component 0 2:1 id: 0 quant:0 [mjpeg @ 0x3731ba0] component 1 1:1 id: 1 quant:1 [mjpeg @ 0x3731ba0] component 2 1:1 id: 2 quant:1 [mjpeg @ 0x3731ba0] marker parser used 17 bytes (136 bits) [mjpeg @ 0x3731ba0] escaping removed 900 bytes [mjpeg @ 0x3731ba0] marker=da avail_size_in_buf=118139 [mjpeg @ 0x3731ba0] component: 0 [mjpeg @ 0x3731ba0] component: 1 [mjpeg @ 0x3731ba0] component: 2 [mjpeg @ 0x3731ba0] marker parser used 117238 bytes (937904 bits) [mjpeg @ 0x3731ba0] marker=d9 avail_size_in_buf=2 [mjpeg @ 0x3731ba0] decode frame unused 2 bytes [avi @ 0x3731100] Probe buffer size limit of 5000000 bytes reached [avi @ 0x3731100] Stream #1: not enough frames to estimate rate; consider increasing probesize [avi @ 0x3731100] After avformat_find_stream_info() pos: 5167988 bytes read:5276374 seeks:6 frames:21 Guessed Channel Layout for Input Stream #0.1 : stereo Input #0, avi, from 'bad.avi': Duration: 00:00:06.03, start: 0.000000, bitrate: 40053 kb/s Stream #0:0, 21, 1/30: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 468x312, 1/30, 30 fps, 30 tbr, 30 tbn, 30 tbc Stream #0:1, 0, 1/44100: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s Successfully opened the file. At least one output file must be specified [AVIOContext @ 0x37397c0] Statistics: 5276374 bytes read, 6 seeks
follow-up: 4 comment:3 by , 11 years ago
Cc: | added |
---|
It's a problem with fields' order.
This quick hack fixes it:
libavcoedec/mjpegdec.c:
if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */ s->interlace_polarity = 1; /* bottom field first */ av_log(avctx, AV_LOG_DEBUG, "bottom field first\n"); } if (avctx->codec->id == AV_CODEC_ID_AMV) s->flipped = 1; + s->interlace_polarity = 1; return 0;
Also WMP plays the file correctly.
comment:4 by , 11 years ago
Replying to ami_stuff:
It's a problem with fields' order.
This quick hack fixes it:
libavcoedec/mjpegdec.c:
if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */ s->interlace_polarity = 1; /* bottom field first */ av_log(avctx, AV_LOG_DEBUG, "bottom field first\n"); } if (avctx->codec->id == AV_CODEC_ID_AMV) s->flipped = 1; + s->interlace_polarity = 1; return 0;Also WMP plays the file correctly.
Yes, it works!
comment:5 by , 11 years ago
Additional sample Test.mp4
(which is an avi file) from forum also uploaded to http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3229/
comment:6 by , 11 years ago
Summary: | ffplay shows bad images → Wrong field order for mjpeg |
---|
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
Looks much nicer with
mplayer -vc mjpeg