FFMPEG 无法从透明 webm 渲染透明 png 框架

FFMPEG 无法从透明 webm 渲染透明 png 框架

我想要像原始源一样导出每一帧,在 webm 视频中是 alpha/透明视频轨道,如果我尝试使用我的基本命令导出,则会以黑色背景导出。

ffmpeg \
-hide_banner \
-loglevel error\
-stats \
-i ${DIRECTORY_CONVERT_VIDEO_TO_FRAMES}${videofile} \
-vf "scale=${new_width}:${new_height}" \
"${DIRECTORY_CONVERTED_FRAMES}"%04d.png

我添加了-c:v png-q:v 0format=rgba效果仍然相同。

ffmpeg \
    -hide_banner \
    -loglevel error \
    -stats \
    -i video/ok.webm \
    -vf "scale=${new_width}:${new_height},format=rgba" \
    -c:v png \
    -q:v 0 \
    "${DIRECTORY_CONVERTED_FRAMES}"%04d.png

请帮帮我。我忘了,视频元数据:

ffprobe -show\_streams video/ok.webm

ffprobe version n6.1.1 Copyright (c) 2007-2023 the FFmpeg developers

built with gcc 13.2.1 (GCC) 20230801

configuration: --prefix=/usr --disable-debug --disable-static --disable-strippi

ng --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore\_amrnb --enable-libopencore\_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan               libavutil      58. 29.100 / 58. 29.100

libavcodec     60. 31.102 / 60. 31.102

libavformat    60. 16.100 / 60. 16.100

libavdevice    60.  3.100 / 60.  3.100

libavfilter     9. 12.100 /  9. 12.100

libswscale      7.  5.100 /  7.  5.100

libswresample   4. 12.100 /  4. 12.100

libpostproc    57.  3.100 / 57.  3.100

Input #0, matroska,webm, from 'video/ok.webm':

Metadata:

ENCODER         : Lavf60.16.100

Duration: 00:00:05.00, start: 0.000000, bitrate: 2580 kb/s

Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv, progressive), 600x1040, SAR 1:

1 DAR 15:26, 30 fps, 30 tbr, 1k tbn                                                  Metadata:

alpha\_mode      : 1

ENCODER         : Lavc60.31.102 libvpx-vp9

DURATION        : 00:00:05.000000000

\[STREAM\]

index=0

codec\_name=vp9

codec\_long\_name=Google VP9

profile=Profile 0

codec\_type=video

codec\_tag\_string=\[0\]\[0\]\[0\]\[0\]

codec\_tag=0x0000

width=600

height=1040

coded\_width=600

coded\_height=1040

closed\_captions=0

film\_grain=0

has\_b\_frames=0

sample\_aspect\_ratio=1:1

display\_aspect\_ratio=15:26

pix\_fmt=yuv420p

level=-99

color\_range=tv

color\_space=unknown

color\_transfer=unknown

color\_primaries=unknown

chroma\_location=unspecified

field\_order=progressive

refs=1

id=N/A

r\_frame\_rate=30/1

avg\_frame\_rate=30/1

time\_base=1/1000

start\_pts=0

start\_time=0.000000

duration\_ts=N/A

duration=N/A

bit\_rate=N/A

max\_bit\_rate=N/A

bits\_per\_raw\_sample=N/A

nb\_frames=N/A

nb\_read\_frames=N/A

nb\_read\_packets=N/A

DISPOSITION:default=0

DISPOSITION:dub=0

DISPOSITION:original=0

DISPOSITION:comment=0

DISPOSITION:lyrics=0

DISPOSITION:karaoke=0

DISPOSITION:forced=0

DISPOSITION:hearing\_impaired=0

DISPOSITION:visual\_impaired=0

DISPOSITION:clean\_effects=0

DISPOSITION:attached\_pic=0

DISPOSITION:timed\_thumbnails=0

DISPOSITION:non\_diegetic=0

DISPOSITION:captions=0

DISPOSITION:descriptions=0

DISPOSITION:metadata=0

DISPOSITION:dependent=0

DISPOSITION:still\_image=0

TAG:alpha\_mode=1

TAG:ENCODER=Lavc60.31.102 libvpx-vp9

TAG:DURATION=00:00:05.000000000

\[/STREAM\]

答案1

要解码 alpha,您需要强制使用 vpx 解码器。

对于 VP9,设置ffmpeg -c:v libvpx-vp9 -i video/ok.webm ...

相关内容