使用 FFmpeg 解码 WebP

使用 FFmpeg 解码 WebP

我想转换此文件:

https://gstatic.com/webp/gallery/1.sm.webp

使用 FFmpeg 转换为 PNG 或 JPG。我尝试过这个:

ffmpeg -i 1.sm.webp a.png

但出现了错误:

ffmpeg version git-2020-05-22-38490cb Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200513
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-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc
--enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
--disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm
--enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2
--enable-avisynth --enable-libopenmpt --enable-amf
libavutil      56. 46.100 / 56. 46.100
libavcodec     58. 86.101 / 58. 86.101
libavformat    58. 43.100 / 58. 43.100
libavdevice    58.  9.103 / 58.  9.103
libavfilter     7. 82.100 /  7. 82.100
libswscale      5.  6.101 /  5.  6.101
libswresample   3.  6.100 /  3.  6.100
libpostproc    55.  6.100 / 55.  6.100
[webp @ 00000000005750c0] missing RIFF tag
[image2 @ 0000000000562540] decoding for stream 0 failed
[image2 @ 0000000000562540] Could not find codec parameters for stream 0
(Video: webp, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, image2, from '1.sm.webp':
Duration: 00:00:00.04, start: 0.000000, bitrate: 48 kb/s
Stream #0:0: Video: webp, none, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (webp (native) -> png (native))
Press [q] to stop, [?] for help
[webp @ 0000000000577fc0] missing RIFF tag
Error while decoding stream #0:0: Invalid data found when processing input
Cannot determine format of input stream 0:0 after EOF
Error marking filters as finished
Conversion failed!

我也尝试过这个:

ffmpeg -probesize 1000 -i 1.sm.webp a.png

但文件只有 243 个字节,错误仍然存​​在。我也尝试了 JPG。我做错了吗?我知道这个文件可以转换,因为我之前用 Go 程序做过:

https://github.com/muv1/cove/tree/cb640c66/webp-to-png

答案1

我首先得到的文件是这样的:

curl -O https://gstatic.com/webp/gallery/1.sm.webp

但这是无效的:

$ curl https://gstatic.com/webp/gallery/1.sm.webp
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.gstatic.com/webp/gallery/1.sm.webp">here</A>.
</BODY></HTML>

应为下列之一:

curl -O https://www.gstatic.com/webp/gallery/1.sm.webp
curl -L -O https://gstatic.com/webp/gallery/1.sm.webp

答案2

看 :https://trac.ffmpeg.org/ticket/4907 看起来 webm 到 png (等等) 还不受支持:“错误总结:目前,FFmpeg 可以编码动画 WebPs?但无法解码它们,这给用户带来了不便。”

相关内容