问题描述
我使用这个命令将flac文件转码为ogg
ffmpeg -i input.flac -c:a libvorbis -b:a 500k output.ogg
是的,我使用 500k 来尽可能保持最高质量,有些文件可以,但有些文件无法播放 - 格式不支持或文件损坏 foobar 说 - 也是我的 icecast 流媒体读不懂。所以文件有问题。
我认为这是由于高比特率所以我尝试了
ffmpeg -i input.flac -c:a libvorbis -b:a 320k output.ogg
同样的情况,有些文件没问题,有些文件无法播放。 所以我用这个命令默认再次尝试
ffmpeg -i input.flac -c:a libvorbis output.ogg
我不知道为什么。
flac 和 ogg 同属一个家族,转码过程中出现损坏文件是怎么回事?
光谱分析没有显示任何错误 - 这里是 ogg https://prnt.sc/115zdjl,这里是原始 flac https://prnt.sc/115zegw
我真的很感兴趣正在发生的事情以及如何让它发挥作用?
谁能解释一下?
这里是完整的日志
C:\Users\lukas.kotatko>ffmpeg -i "\\192.168.0.128\lukas\online radio resources\Atma FM playlists\channel 1\flac lossless\Tuu\One Thousand Years\02 One Thousand Years.flac" -c:a libvorbis -b:a 500k "\\192.168.0.128\lukas\online radio resources\Atma FM playlists\channel 1\flac lossless\Tuu\One Thousand Years\02 One Thousand Years [500k test].ogg"
ffmpeg version 4.3.1 copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
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 --enable-libgsm --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. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0,flac,from '\\192.168.0.128\lukas\online radio resources\Atma FM playlists\channel 1\flac lossless\Tuu\One Thousand Years\02 One Thousand Years.flac':
Metadata:
GENRE : Tribal / Ambient
ORGANIZATION : Waveform Records
ISRC : 01101-2
COMMENT : US reissue featuring the six original tracks plus two taken from the Invocation album.
musicbrainz_RELEASEGROUPID: 737d0518-3dc2-36b3-9419-282c0ade0e50
ORIGINALDATE : 1993
ORIGINALYEAR : 1993
RELEASETYPE : album
musicbrainz_ALBUMID: f6339129-f662-43a1-93df-2f20540f73cc
ALBUM : One Thousand Years
BARCODE : 789060110125
musicbrainz_albumartISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
album_artist : Tuu
albumartISTSORT : Tuu
ASIN : B00005B9TT
SCRIPT : Latn
RELEASESTATUS : official
LABEL : Waveform Records
CATALOGNUMBER : 01101-2
RELEASECOUNTRY : US
DATE : 2001-05-08
TOTALdisCS : 1
disc : 1
TOTALTRACKS : 8
MEDIA : CD
musicbrainz_TRACKID: aef9824d-e4a6-4ae6-aebe-50a83dd14f71
TITLE : One Thousand Years
musicbrainz_ARTISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
ARTIST : Tuu
ARTISTSORT : Tuu
ARTISTS : Tuu
musicbrainz_RELEASETRACKID: 621c9da6-a85d-3f8b-b485-5e6f74a60cd0
track : 2
TRACKTOTAL : 8
disCTOTAL : 1
Duration: 00:08:03.67,start: 0.000000,bitrate: 792 kb/s
Stream #0:0: Audio: flac,44100 Hz,stereo,s16
Stream #0:1: Video: mjpeg (Baseline),yuvj420p(pc,bt470bg/unkNown/unkNown),600x600 [SAR 1:1 DAR 1:1],90k tbr,90k tbn,90k tbc (attached pic)
Metadata:
comment : Cover (front)
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> theora (libtheora))
Stream #0:0 -> #0:1 (flac (native) -> vorbis (libvorbis))
Press [q] to stop,[?] for help
[swscaler @ 0000015307581a00] deprecated pixel format used,make sure you did set range correctly
[ogg @ 00000153073f1680] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate,a different muxer or -vsync 2
Output #0,ogg,to '\\192.168.0.128\lukas\online radio resources\Atma FM playlists\channel 1\flac lossless\Tuu\One Thousand Years\02 One Thousand Years [500k test].ogg':
Metadata:
GENRE : Tribal / Ambient
ORGANIZATION : Waveform Records
ISRC : 01101-2
COMMENT : US reissue featuring the six original tracks plus two taken from the Invocation album.
musicbrainz_RELEASEGROUPID: 737d0518-3dc2-36b3-9419-282c0ade0e50
ORIGINALDATE : 1993
ORIGINALYEAR : 1993
RELEASETYPE : album
musicbrainz_ALBUMID: f6339129-f662-43a1-93df-2f20540f73cc
ALBUM : One Thousand Years
BARCODE : 789060110125
musicbrainz_albumartISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
album_artist : Tuu
albumartISTSORT : Tuu
ASIN : B00005B9TT
SCRIPT : Latn
RELEASESTATUS : official
LABEL : Waveform Records
CATALOGNUMBER : 01101-2
RELEASECOUNTRY : US
DATE : 2001-05-08
TOTALdisCS : 1
disc : 1
TOTALTRACKS : 8
MEDIA : CD
musicbrainz_TRACKID: aef9824d-e4a6-4ae6-aebe-50a83dd14f71
TITLE : One Thousand Years
musicbrainz_ARTISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
ARTIST : Tuu
ARTISTSORT : Tuu
ARTISTS : Tuu
musicbrainz_RELEASETRACKID: 621c9da6-a85d-3f8b-b485-5e6f74a60cd0
track : 2
TRACKTOTAL : 8
disCTOTAL : 1
encoder : Lavf58.45.100
Stream #0:0: Video: theora (libtheora),yuv420p(progressive),q=2-31,200 kb/s,90k fps,90k tbc (attached pic)
Metadata:
DESCRIPTION : Cover (front)
encoder : Lavc58.91.100 libtheora
GENRE : Tribal / Ambient
ORGANIZATION : Waveform Records
ISRC : 01101-2
musicbrainz_RELEASEGROUPID: 737d0518-3dc2-36b3-9419-282c0ade0e50
ORIGINALDATE : 1993
ORIGINALYEAR : 1993
RELEASETYPE : album
musicbrainz_ALBUMID: f6339129-f662-43a1-93df-2f20540f73cc
ALBUM : One Thousand Years
BARCODE : 789060110125
musicbrainz_albumartISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
albumartIST : Tuu
albumartISTSORT : Tuu
ASIN : B00005B9TT
SCRIPT : Latn
RELEASESTATUS : official
LABEL : Waveform Records
CATALOGNUMBER : 01101-2
RELEASECOUNTRY : US
DATE : 2001-05-08
TOTALdisCS : 1
disCNUMBER : 1
TOTALTRACKS : 8
MEDIA : CD
musicbrainz_TRACKID: aef9824d-e4a6-4ae6-aebe-50a83dd14f71
TITLE : One Thousand Years
musicbrainz_ARTISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
ARTIST : Tuu
ARTISTSORT : Tuu
ARTISTS : Tuu
musicbrainz_RELEASETRACKID: 621c9da6-a85d-3f8b-b485-5e6f74a60cd0
TRACKNUMBER : 2
TRACKTOTAL : 8
disCTOTAL : 1
Stream #0:1: Audio: vorbis (libvorbis),fltp (16 bit),500 kb/s
Metadata:
encoder : Lavc58.91.100 libvorbis
GENRE : Tribal / Ambient
ORGANIZATION : Waveform Records
ISRC : 01101-2
DESCRIPTION : US reissue featuring the six original tracks plus two taken from the Invocation album.
musicbrainz_RELEASEGROUPID: 737d0518-3dc2-36b3-9419-282c0ade0e50
ORIGINALDATE : 1993
ORIGINALYEAR : 1993
RELEASETYPE : album
musicbrainz_ALBUMID: f6339129-f662-43a1-93df-2f20540f73cc
ALBUM : One Thousand Years
BARCODE : 789060110125
musicbrainz_albumartISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
albumartIST : Tuu
albumartISTSORT : Tuu
ASIN : B00005B9TT
SCRIPT : Latn
RELEASESTATUS : official
LABEL : Waveform Records
CATALOGNUMBER : 01101-2
RELEASECOUNTRY : US
DATE : 2001-05-08
TOTALdisCS : 1
disCNUMBER : 1
TOTALTRACKS : 8
MEDIA : CD
musicbrainz_TRACKID: aef9824d-e4a6-4ae6-aebe-50a83dd14f71
TITLE : One Thousand Years
musicbrainz_ARTISTID: e05a42e7-60a3-4d2d-983c-51dc4eb67cad
ARTIST : Tuu
ARTISTSORT : Tuu
ARTISTS : Tuu
musicbrainz_RELEASETRACKID: 621c9da6-a85d-3f8b-b485-5e6f74a60cd0
TRACKNUMBER : 2
TRACKTOTAL : 8
disCTOTAL : 1
frame= 1 fps=0.1 q=-0.0 Lsize= 25860kB time=00:08:03.66 bitrate= 438.0kbits/s speed=44.6x
video:8kB audio:25721kB subtitle:0kB other streams:0kB global headers:7kB muxing overhead: 0.511663%
解决方法
我想要实现的是流式传输高分辨率无损 flac 文件。我好像快到了。
此命令 ffmpeg -i input.flac output.ogg
生成有损 ogg 文件。它会大幅缩小文件大小并生成比特率约为 128 k 的文件。
光谱分析显示细节 https://prnt.sc/117904c - 非常糟糕。所有高于 17 kHz 的频率都一去不复返了 + 其他“听不见”的声音也一去不复返了。即使使用 -b:a 选项 ffmpeg -i input.flac -b:a 320k output.ogg
它仍然是有损文件,只是比特率更高。据我所知,最大 -b:a 是 500k.. 已经相当准确,但仍然是一个有损文件。
但是这个命令 ffmpeg -i input.flac -c:a libvorbis -c:a copy -map 0:a output.ogg
实际上有效。它将 flac 包装到 ogg 容器,以便更好地进行流式传输,并保持所有无损质量。见Why is FLAC Streaming over HTTP done with Ogg encapsulation instead of natively?
我似乎终于弄清楚如何将 flac 文件准备为无损高分辨率流。只需使用此命令将它们包装到 ogg 容器中即可。
ffmpeg -i input.flac -c:a libvorbis -c:a copy -map 0:a output.ogg
频谱分析证明它实际上是无损文件,即使它具有 .ogg 扩展名: 这里是包装 ogg flac 文件 https://prnt.sc/1178jp4,这里是原始 flac 文件 https://prnt.sc/1178l8h。
现在我需要用多个文件对其进行测试,看看 Icecast 服务器如何处理无损流