Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7883 closed defect (worksforme)

Videos with alpha channel are corrupted by scaling

Reported by: Acru Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

When using the scale filter on a video with an alpha channel, or if the format is changed to rgba etc, the video is corrupted. I have not checked if other filters are also effected.

This issue appeared between build 20190312-d227ed5-win64-static and build ffmpeg-20190315-def18ac-win64-static, narrowing down what commit caused, though I am uncertain exactly which. The issue persists in the latest build available to me, 20190505-e384f6f-win64-static

How to reproduce:

A command such as the following, on a video with alpha;

ffmpeg -i "Door (png).mov" -vf "scale=iw*0.5:-1" -y out.mp4

Or any video when the format is changed to rgba;

ffmpeg -i in.mp4 -vf "format=rgba,scale=iw*0.5:-1" -y out.mp4

The output log does not indicate any differences, before and after the bug was introduced.

Some alpha-channeled videos are available here, for testing; https://drive.google.com/open?id=0Bxp60P6x4uM2clU3VF91bzlYMnc

Change History (5)

comment:1 by Carl Eugen Hoyos, 5 years ago

Component: ffmpegundetermined

Please provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

in reply to:  1 comment:2 by Acru, 5 years ago

Replying to cehoyos:

Please provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

Here is the command with associated output;

>ffmpeg -i "Door (png).mov" -vf "scale=iw*0.5:-1" -y out.mp4
ffmpeg version N-93762-ge384f6f2f9 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.3.1 (GCC) 20190414
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 52.100 / 58. 52.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 50.100 /  7. 50.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Door (png).mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2013-04-07T21:58:25.000000Z
  Duration: 00:00:10.04, start: 0.000000, bitrate: 314318 kb/s
    Stream #0:0(eng): Video: png (png  / 0x20676E70), rgba(pc), 1920x1080 [SAR 2834:2834 DAR 16:9], 314308 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      creation_time   : 2013-04-07T21:58:26.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : PNG
      timecode        : 00:00:00;00
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2013-04-07T22:03:42.000000Z
      handler_name    : Time Code Media Handler
      timecode        : 00:00:00;00
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0000000000575b00] using SAR=1/1
[libx264 @ 0000000000575b00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0000000000575b00] profile High 4:4:4 Predictive, level 3.1, 4:4:4, 8-bit
[libx264 @ 0000000000575b00] 264 - core 157 r2970 5493be8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=4 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 'out.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf58.27.103
    Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 960x540 [SAR 1:1 DAR 16:9], q=-1--1, 0.03 fps, 30k tbn, 29.97 tbc (default)
    Metadata:
      creation_time   : 2013-04-07T21:58:26.000000Z
      handler_name    : Apple Video Media Handler
      timecode        : 00:00:00;00
      encoder         : Lavc58.52.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=   19 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   43 fps= 43 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   61 fps= 40 q=29.0 size=       0kB time=00:00:00.06 bitrate=   6.2kbits/s speed=0.0441x    
frame=   81 fps= 40 q=29.0 size=       0kB time=00:00:00.73 bitrate=   0.6kbits/s speed=0.363x    
frame=   99 fps= 39 q=29.0 size=       0kB time=00:00:01.33 bitrate=   0.3kbits/s speed=0.525x    
frame=  118 fps= 38 q=29.0 size=       0kB time=00:00:01.96 bitrate=   0.2kbits/s speed=0.64x    
frame=  139 fps= 38 q=29.0 size=       0kB time=00:00:02.66 bitrate=   0.2kbits/s speed=0.734x    
frame=  160 fps= 39 q=29.0 size=       0kB time=00:00:03.37 bitrate=   0.1kbits/s speed=0.811x    
frame=  178 fps= 38 q=29.0 size=       0kB time=00:00:03.97 bitrate=   0.1kbits/s speed=0.852x    
frame=  196 fps= 38 q=29.0 size=       0kB time=00:00:04.57 bitrate=   0.1kbits/s speed=0.886x    
frame=  215 fps= 38 q=29.0 size=       0kB time=00:00:05.20 bitrate=   0.1kbits/s speed=0.919x    
frame=  236 fps= 38 q=29.0 size=       0kB time=00:00:05.90 bitrate=   0.1kbits/s speed=0.953x    
frame=  256 fps= 38 q=29.0 size=     256kB time=00:00:06.57 bitrate= 319.1kbits/s speed=0.978x    
frame=  275 fps= 38 q=29.0 size=     256kB time=00:00:07.20 bitrate= 291.0kbits/s speed=0.996x    
frame=  296 fps= 38 q=26.0 size=     256kB time=00:00:07.90 bitrate= 265.2kbits/s speed=1.02x    
frame=  301 fps= 38 q=-1.0 Lsize=     371kB time=00:00:09.94 bitrate= 305.3kbits/s speed=1.24x    
video:366kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.288334%
[libx264 @ 0000000000575b00] frame I:2     Avg QP:19.38  size: 43754
[libx264 @ 0000000000575b00] frame P:105   Avg QP:20.74  size:  1575
[libx264 @ 0000000000575b00] frame B:194   Avg QP:23.80  size:   624
[libx264 @ 0000000000575b00] consecutive B-frames:  9.6% 12.6%  2.0% 75.7%
[libx264 @ 0000000000575b00] mb I  I16..4: 23.3% 53.5% 23.2%
[libx264 @ 0000000000575b00] mb P  I16..4:  2.5%  0.8%  0.1%  P16..4: 17.5%  2.5%  1.1%  0.0%  0.0%    skip:75.5%
[libx264 @ 0000000000575b00] mb B  I16..4:  0.6%  0.1%  0.0%  B16..8: 14.5%  0.4%  0.0%  direct: 0.1%  skip:84.3%  L0:45.3% L1:54.1% BI: 0.6%
[libx264 @ 0000000000575b00] 8x8 transform intra:30.0% inter:98.3%
[libx264 @ 0000000000575b00] coded y,u,v intra: 32.3% 2.4% 1.2% inter: 3.7% 0.0% 0.0%
[libx264 @ 0000000000575b00] i16 v,h,dc,p:  1% 89%  0% 10%
[libx264 @ 0000000000575b00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 38% 15%  5%  5%  5%  7%  5%  7%
[libx264 @ 0000000000575b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 65%  8%  2%  2%  2%  3%  2%  3%
[libx264 @ 0000000000575b00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000000575b00] ref P L0: 53.6% 13.1% 20.8% 12.5%
[libx264 @ 0000000000575b00] ref B L0: 86.0% 11.6%  2.4%
[libx264 @ 0000000000575b00] ref B L1: 96.1%  3.9%
[libx264 @ 0000000000575b00] kb/s:297.89

Like I said in the OP though, the log doesn't indicate any problem but the video output is bad;

https://www.dropbox.com/s/vxx2jzd7lob7k7o/out.mp4_snapshot_00.09_%5B2019.05.06_01.21.57%5D.png

comment:3 by Gyan, 5 years ago

Can't reproduce it here. Have you checked if alpha channel is relevant - check with format=rgb24. I suspect your player's decoder can't handle 4:4:4 format but it still tries. Add -pix_fmt yuv420p and check.

comment:4 by Carl Eugen Hoyos, 5 years ago

Keywords: scale alpha regression removed
Resolution: worksforme
Status: newclosed

Probably #7822.

in reply to:  4 comment:5 by Acru, 5 years ago

Replying to cehoyos:

Probably #7822.

Ah, yes, that change in x264 would do it.

Is there a way to maintain compatibility with older decoders, without just using an older ffmpeg? (Assuming I want to keep using 4:4:4 as an intermediary)

Note: See TracTickets for help on using tickets.