Opened 3 years ago

Last modified 3 years ago

#9334 open defect

MP4 to APNG conversion incorrectly has transparent background

Reported by: mcpower Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: apng
Cc: mcpower Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: The attached black and white MP4 video (which has no alpha channel), when transcoded to APNG using ffmpeg results in the background being transparent.

How to reproduce:

PS> ffmpeg -i black_and_white_splash.mp4 -plays 0 black_and_white_splash.apng
ffmpeg version 2021-07-14-git-ca56299fb3-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.3.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  3.101 / 59.  3.101
  libavformat    59.  4.100 / 59.  4.100
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.103 /  8.  0.103
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'black_and_white_splash.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.4.100
  Duration: 00:00:02.37, start: 0.000000, bitrate: 63 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 160x160 [SAR 1:1 DAR 1:1], 57 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> apng (native))
Press [q] to stop, [?] for help
Output #0, apng, to 'black_and_white_splash.apng':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.4.100
  Stream #0:0(und): Video: apng, rgb24(pc, bt709, progressive), 160x160 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 30 fps, 30 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.3.101 apng
frame=   71 fps=0.0 q=-0.0 Lsize=     182kB time=00:00:02.36 bitrate= 629.6kbits/s speed=22.7x

Also reproduced with ffmpeg version 4.2.4-1ubuntu0.1.

Attached is the input file, the output file, and a recording of the output APNG file as displayed in Google Chrome. Google Chrome uses an #e6e6e6 (light grey) background behind all transparent backgrounds.

Attachments (3)

black_and_white_splash.mp4 (18.2 KB ) - added by mcpower 3 years ago.
black_and_white_splash.apng (181.9 KB ) - added by mcpower 3 years ago.
black_and_white_splash_apng_in_chrome.mp4 (118.9 KB ) - added by mcpower 3 years ago.

Download all attachments as: .zip

Change History (7)

by mcpower, 3 years ago

Attachment: black_and_white_splash.mp4 added

by mcpower, 3 years ago

Attachment: black_and_white_splash.apng added

comment:1 by pdr0, 3 years ago

workaround is to specify rgba

ffmpeg -i black_and_white_splash.mp4 -plays 0 -vf scale=out_color_matrix=bt709,format=rgba rgba.apng

(ooops, should be in_color_matrix , not out_color_matrix, for a YUV to RGB conversion - but it does not matter for a greyscale example)

Last edited 3 years ago by pdr0 (previous) (diff)

comment:2 by Balling, 3 years ago

What is also funny is that apng has sRGB chunk, which is wrong... BT.709 is like 2.4 gamma on perfect OLED.

Last edited 3 years ago by Balling (previous) (diff)

comment:4 by Balling, 3 years ago

Keywords: apng added
Status: newopen
Note: See TracTickets for help on using tickets.