[FFmpeg-trac] #3399(undetermined:new): Scaling MP4 Video results in bad output MP4

FFmpeg trac at avcodec.org
Tue Feb 18 23:54:42 CET 2014


#3399: Scaling MP4 Video results in bad output MP4
----------------------------------+----------------------------------------
             Reporter:  mressler  |                    Owner:
                 Type:  defect    |                   Status:  new
             Priority:  normal    |                Component:  undetermined
              Version:  2.1.3     |               Resolution:
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+----------------------------------------

Comment (by mressler):

 (I don't see a way to edit the description above, so here's a new
 description with full output.)

 Summary of the bug:

 Attempting to scale an MP4/H264 1920x1080 source video to 1024:-1 (also
 Mp4/H264) results in odd playback in different players. VLC shows green
 box artifacts, QuickTime? and MPlayer both show jerky/slow playback.

 How to reproduce:

 (Grab source from:
 ​https://www.dropbox.com/s/thy8zxbvx1ygqru/VID_20130619_161750_449.mp4)

 {{{
 % ffmpeg -i VID_20130619_161750_449.mp4 -vf "scale=1024:-1" VID_scaled.mp4
 ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers
   built on Feb 17 2014 12:57:49 with Apple LLVM version 5.0
 (clang-500.2.79) (based on LLVM 3.3svn)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.3 --enable-shared
 --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
 --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang
 --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-
 libmp3lame --enable-libxvid
   libavutil      52. 48.101 / 52. 48.101
   libavcodec     55. 39.101 / 55. 39.101
   libavformat    55. 19.104 / 55. 19.104
   libavdevice    55.  5.100 / 55.  5.100
   libavfilter     3. 90.100 /  3. 90.100
   libavresample   1.  1.  0 /  1.  1.  0
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VID_20130619_161750_449.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     creation_time   : 2013-06-19 20:18:49
   Duration: 00:00:58.05, start: 0.000000, bitrate: 15706 kb/s
     Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
 fltp, 128 kb/s (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : SoundHandle
     Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 /
 0x31637661), yuv420p, 1920x1080, 15469 kb/s, SAR 65536:65536 DAR 16:9,
 29.89 fps, 1k tbr, 1k tbn, 2k tbc (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : VideoHandle
 File 'VID_scaled.mp4' already exists. Overwrite ? [y/N] y
 [libx264 @ 0x7fc0f2863c00] using SAR=1/1
 [libx264 @ 0x7fc0f2863c00] MB rate (2304000) > level limit (2073600)
 [libx264 @ 0x7fc0f2863c00] using cpu capabilities: MMX2 SSE2Fast SSSE3
 FastShuffle SSE4.2 AVX
 [libx264 @ 0x7fc0f2863c00] profile High, level 5.2
 [libx264 @ 0x7fc0f2863c00] 264 - core 125 - H.264/MPEG-4 AVC codec -
 Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1
 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12
 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25
 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0
 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
 Output #0, mp4, to 'VID_scaled.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     encoder         : Lavf55.19.104
     Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
 yuv420p, 1024x576 [SAR 1:1 DAR 16:9], q=-1--1, 16k tbn, 1k tbc (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : VideoHandle
     Stream #0:1(eng): Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100
 Hz, stereo, s16, 128 kb/s (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : SoundHandle
 Stream mapping:
   Stream #0:1 -> #0:0 (h264 -> libx264)
   Stream #0:0 -> #0:1 (aac -> libfaac)
 Press [q] to stop, [?] for help
 frame=58016 fps=149 q=-1.0 Lsize=   47319kB time=00:00:58.01
 bitrate=6681.8kbits/s dup=56281 drop=0
 video:45706kB audio:890kB subtitle:0 global headers:0kB muxing overhead
 1.551760%
 [libx264 @ 0x7fc0f2863c00] frame I:241   Avg QP:19.11  size: 59516
 [libx264 @ 0x7fc0f2863c00] frame P:15706 Avg QP:21.99  size:  1876
 [libx264 @ 0x7fc0f2863c00] frame B:42069 Avg QP:32.95  size:    71
 [libx264 @ 0x7fc0f2863c00] consecutive B-frames:  3.2%  0.2%  0.5% 96.1%
 [libx264 @ 0x7fc0f2863c00] mb I  I16..4:  5.1% 69.1% 25.8%
 [libx264 @ 0x7fc0f2863c00] mb P  I16..4:  0.0%  0.2%  0.1%  P16..4:  7.9%
 2.8%  2.1%  0.0%  0.0%    skip:86.9%
 [libx264 @ 0x7fc0f2863c00] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  3.3%
 0.0%  0.0%  direct: 0.0%  skip:96.7%  L0:26.8% L1:73.2% BI: 0.0%
 [libx264 @ 0x7fc0f2863c00] 8x8 transform intra:69.6% inter:59.9%
 [libx264 @ 0x7fc0f2863c00] coded y,uvDC,uvAC intra: 92.9% 68.7% 35.0%
 inter: 1.4% 1.0% 0.0%
 [libx264 @ 0x7fc0f2863c00] i16 v,h,dc,p: 14% 11%  5% 70%
 [libx264 @ 0x7fc0f2863c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 16% 22%  5%
 8%  9%  8%  6%  8%
 [libx264 @ 0x7fc0f2863c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 15% 10%  6%
 10% 11%  8%  6%  7%
 [libx264 @ 0x7fc0f2863c00] i8c dc,h,v,p: 51% 19% 23%  7%
 [libx264 @ 0x7fc0f2863c00] Weighted P-Frames: Y:0.4% UV:0.0%
 [libx264 @ 0x7fc0f2863c00] ref P L0: 81.7% 12.1%  5.9%  0.4%  0.0%
 [libx264 @ 0x7fc0f2863c00] ref B L0: 95.8%  4.2%  0.0%
 [libx264 @ 0x7fc0f2863c00] ref B L1: 85.4% 14.6%
 [libx264 @ 0x7fc0f2863c00] kb/s:6453.67
 }}}

 VID_scaled.mp4 ends up with green artifacts in VLC and doesn't play
 appropriately in QuickTime? or MPlayer.
 Interestingly, if I clip the video first via:

 {{{
 % ffmpeg -i VID_20130619_161750_449.mp4 -ss 18 -t 15 -c:v copy -c:a copy
 clip2.mp4
 ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers
   built on Feb 17 2014 12:57:49 with Apple LLVM version 5.0
 (clang-500.2.79) (based on LLVM 3.3svn)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.3 --enable-shared
 --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
 --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang
 --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-
 libmp3lame --enable-libxvid
   libavutil      52. 48.101 / 52. 48.101
   libavcodec     55. 39.101 / 55. 39.101
   libavformat    55. 19.104 / 55. 19.104
   libavdevice    55.  5.100 / 55.  5.100
   libavfilter     3. 90.100 /  3. 90.100
   libavresample   1.  1.  0 /  1.  1.  0
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VID_20130619_161750_449.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     creation_time   : 2013-06-19 20:18:49
   Duration: 00:00:58.05, start: 0.000000, bitrate: 15706 kb/s
     Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
 fltp, 128 kb/s (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : SoundHandle
     Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 /
 0x31637661), yuv420p, 1920x1080, 15469 kb/s, SAR 65536:65536 DAR 16:9,
 29.89 fps, 1k tbr, 1k tbn, 2k tbc (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : VideoHandle
 File 'clip2.mp4' already exists. Overwrite ? [y/N] y
 Output #0, mp4, to 'clip2.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     encoder         : Lavf55.19.104
     Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
 1920x1080 [SAR 65536:65536 DAR 16:9], q=2-31, 15469 kb/s, 29.89 fps, 16k
 tbn, 1k tbc (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : VideoHandle
     Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz,
 stereo, 128 kb/s (default)
     Metadata:
       creation_time   : 2013-06-19 20:18:49
       handler_name    : SoundHandle
 Stream mapping:
   Stream #0:1 -> #0:0 (copy)
   Stream #0:0 -> #0:1 (copy)
 Press [q] to stop, [?] for help
 frame=  444 fps=0.0 q=-1.0 Lsize=   28323kB time=00:00:15.00
 bitrate=15462.3kbits/s
 video:28072kB audio:234kB subtitle:0 global headers:0kB muxing overhead
 0.057352%
 }}}

 And then run the scale command:

 {{{
 % ffmpeg -i clip2.mp4 -vf "scale=1024:-1" VID_clip_scaled.mp4
 ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers
   built on Feb 17 2014 12:57:49 with Apple LLVM version 5.0
 (clang-500.2.79) (based on LLVM 3.3svn)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.3 --enable-shared
 --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
 --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang
 --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-
 libmp3lame --enable-libxvid
   libavutil      52. 48.101 / 52. 48.101
   libavcodec     55. 39.101 / 55. 39.101
   libavformat    55. 19.104 / 55. 19.104
   libavdevice    55.  5.100 / 55.  5.100
   libavfilter     3. 90.100 /  3. 90.100
   libavresample   1.  1.  0 /  1.  1.  0
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clip2.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf55.19.104
   Duration: 00:00:15.00, start: 0.005011, bitrate: 15466 kb/s
     Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
 0x31637661), yuv420p, 1920x1080, 15542 kb/s, 30.01 fps, 30 tbr, 16k tbn,
 32k tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
 fltp, 127 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
 [libx264 @ 0x7ff8c48f1200] using cpu capabilities: MMX2 SSE2Fast SSSE3
 FastShuffle SSE4.2 AVX
 [libx264 @ 0x7ff8c48f1200] profile High, level 3.1
 [libx264 @ 0x7ff8c48f1200] 264 - core 125 - H.264/MPEG-4 AVC codec -
 Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1
 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12
 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25
 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0
 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
 Output #0, mp4, to 'VID_clip_scaled.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf55.19.104
     Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
 yuv420p, 1024x576, q=-1--1, 15360 tbn, 30 tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(eng): Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100
 Hz, stereo, s16, 128 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
 Stream mapping:
   Stream #0:0 -> #0:0 (h264 -> libx264)
   Stream #0:1 -> #0:1 (aac -> libfaac)
 Press [q] to stop, [?] for help
 frame=  451 fps= 56 q=-1.0 Lsize=    2622kB time=00:00:15.00
 bitrate=1432.0kbits/s dup=7 drop=0
 video:2370kB audio:235kB subtitle:0 global headers:0kB muxing overhead
 0.674256%
 [libx264 @ 0x7ff8c48f1200] frame I:2     Avg QP:21.56  size: 57176
 [libx264 @ 0x7ff8c48f1200] frame P:168   Avg QP:24.62  size: 10380
 [libx264 @ 0x7ff8c48f1200] frame B:281   Avg QP:27.22  size:  2020
 [libx264 @ 0x7ff8c48f1200] consecutive B-frames:  0.4% 27.1% 67.2%  5.3%
 [libx264 @ 0x7ff8c48f1200] mb I  I16..4:  6.5% 64.9% 28.6%
 [libx264 @ 0x7ff8c48f1200] mb P  I16..4:  0.2%  1.5%  0.5%  P16..4: 44.3%
 13.9%  9.8%  0.0%  0.0%    skip:29.9%
 [libx264 @ 0x7ff8c48f1200] mb B  I16..4:  0.0%  0.1%  0.0%  B16..8: 49.8%
 2.1%  0.3%  direct: 0.4%  skip:47.3%  L0:39.9% L1:57.4% BI: 2.6%
 [libx264 @ 0x7ff8c48f1200] 8x8 transform intra:66.9% inter:72.6%
 [libx264 @ 0x7ff8c48f1200] coded y,uvDC,uvAC intra: 79.3% 58.4% 20.6%
 inter: 12.6% 5.9% 0.2%
 [libx264 @ 0x7ff8c48f1200] i16 v,h,dc,p: 22% 25%  5% 48%
 [libx264 @ 0x7ff8c48f1200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 13% 20%  5%
 12% 12% 11%  6%  8%
 [libx264 @ 0x7ff8c48f1200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 13% 14%  5%
 12% 13%  9%  6%  5%
 [libx264 @ 0x7ff8c48f1200] i8c dc,h,v,p: 55% 19% 18%  8%
 [libx264 @ 0x7ff8c48f1200] Weighted P-Frames: Y:5.4% UV:0.0%
 [libx264 @ 0x7ff8c48f1200] ref P L0: 60.9% 17.9% 15.4%  5.7%  0.1%
 [libx264 @ 0x7ff8c48f1200] ref B L0: 81.3% 16.3%  2.5%
 [libx264 @ 0x7ff8c48f1200] ref B L1: 88.1% 11.9%
 [libx264 @ 0x7ff8c48f1200] kb/s:1290.94
 }}}

 The resulting video plays fine in VLC, QuickTime?, and MPlayer.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/3399#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list