当我将 Opus 音频流从 WebM 重新混合到另一个容器(如 ogg 或 opus)时遇到了一个奇怪的问题。
通过频谱分析仪运行输出文件可以清楚地显示数据有丢失/变化。我不确定结果是否 100% 准确,尽管多个程序证实了这一点。我尝试了使用 FFmpeg 和 MKVExtract 的多种方法,但在这两种情况下,提取的文件都有明显的差异(大小也不同)。
经过深入研究,我发现这个错误在 FFmpeg 中,这可以解释错位以及文件大小的变化。但这里似乎还有更多事情发生。我使用 Audacity 将源文件和所有提取的文件转换为 32 位 WAV,然后再次分析它们。在这种情况下,偏移更加明显,实际数据的差异也更大。
是否有更加健全的测试方法和可靠的工具以便在必要时更方便地进行批处理?
这是 Audacity 和 Spek 的频谱输出以及一些附加信息:
Source file: audio.webm
Size: 2.94 MB
Spek: https://i.imgur.com/5NtmwG7.png
Audacity: https://i.imgur.com/hEs8Ajo.png
Extracted file using FFmpeg: audio_extracted_ffmpeg.opus
Size: 2.90 MB
Spek: https://i.imgur.com/5UBV3FV.png
Audacity: https://i.imgur.com/lsZl0Bt.png
Extracted file using MKVExtract: audio_extracted_mkvextract.opus
Size: 2.91 MB
Spek: https://i.imgur.com/waa1TOJ.png
Audacity: https://i.imgur.com/TAqyIst.png
Comparison between the source WebM and the FFmpeg Opus in Audacity:
Source file: https://i.imgur.com/xYciUfH.png
Extracted via FFmpeg: https://i.imgur.com/T8T02fx.png
这是 FFmpeg 提取的输出:
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
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. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, matroska,webm, from 'files/audio.webm':
Metadata:
encoder : google/video-file
Duration: 00:03:08.30, start: -0.007000, bitrate: 131 kb/s
Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Output #0, opus, to 'files/ffmpeg/audio_extracted_ffmpeg.opus':
Metadata:
encoder : Lavf58.29.100
Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
encoder : Lavf58.29.100
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 2975kB time=00:03:08.28 bitrate= 129.5kbits/s speed=6.57e+03x
video:0kB audio:2952kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.803061%
和 MKVToolNix:
Extracting track 0 with the CodecID 'A_OPUS' to the file 'files/mkvextract/audio_extracted_mkvextract.opus'. Container format: Ogg (Opus in Ogg)
Progress: 100%
CLI 参数:
ffmpeg -i "source.webm" -vn -acodec copy "output.opus"
mkvextract "source.webm" tracks 0:"output.opus"