[英]Is it possible to change volume with no reencode with ffmpeg?
我剛剛有這個問題,因為我在 ffmpeg 中使用了以下命令:
ffmpeg -i input.wav -filter:a "volume=0.2" output.wav
遵循此處的文檔: https : //trac.ffmpeg.org/wiki/AudioVolume
但是,當我創建新文件時,輸出大小是輸入大小的一半,並且音軌的比特率也降低了。
所以我的問題是:
好的,正如 Reddit 的某人向我解釋的那樣,我應該能夠在不重新編碼的情況下更改音量,但是,我的輸入編解碼器是 pcm_f32le,而沒有任何說明符的 ffmpeg 的輸出編解碼器的默認設置是 pcm_f16le。
第一個 pcm_f32le 是 32 位,因此它比第二個 16 位存儲更多信息。
所以答案是:
是的,這是因為在這種情況下,我在不知不覺中重新編碼為信息較少的編解碼器。
實際上沒有,它仍在重新編碼。 最好的選擇是使用我上面使用的相同代碼和一個額外的說明符:
ffmpeg -i input.wav -filter:a "volume=0.2" -c:a pcm_f32le output.wav
輸入和輸出的編解碼器必須與 32 位或 16 位相同,否則我必須添加一個說明符,我在 Reddit 上向同一個人展示了如何做。
但是,每當您添加過濾器時,這仍然是重新編碼。
我不是專家,但我增加音量的方式似乎不會引起問題.. 例如音頻的比特率是相同的......文件大小也相似。
ffmpeg -i ac.mp4 -af volume=7 -vcodec copy ac2.mp4
注意-以下是一個涉及 c# 的編程問題,但有人提到了上述使用 FFmpeg 增加/減少音頻音量
用於文檔
ffmpeg -? 沒有顯示太多。 如果你做ffmpeg -? | grep "vol"
ffmpeg -? | grep "vol"
ffmpeg -? | grep "vol"
那么它提到的只是 "-vol volume" 如果你做ffmpeg -? | grep "-af"
ffmpeg -? | grep "-af"
ffmpeg -? | grep "-af"
然后它說的是-af filter_graph set audio filters"
沒有提到您可以使用哪些音頻過濾器。
但是與一些 ffmpeg 專家交談時,他們提到了重新文檔。
”
有 ffmpeg-filters 聯機幫助頁以及 -h filter=NAME ,它向您顯示了可用於過濾器的選項的簡介。
在網上你也有 ffmpeg-all one https://www.ffmpeg.org/ffmpeg-all.html
https://ffmpeg.org/ffmpeg-filters.html#volume
”
從 mediainfo 和 DIR 親自查看文件之間的區別
請注意,源文件和目標文件的大小相似,均為 195MB。 源是 195,166,205 字節,目標是 195,837,608 字節。 所以尺寸差異很小。
請注意
比特率沒有區別
C:\Users\User\Downloads\ac>mediainfo ac.mp4 | find /i "bit"
Overall bit rate : 383 kb/s
Bit rate : 252 kb/s
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.010
Bit rate mode : Constant
Bit rate : 128 kb/s
C:\Users\User\Downloads\ac>mediainfo ac2.mp4 | find /i "bit"
Overall bit rate : 384 kb/s
Bit rate : 252 kb/s
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.010
Bit rate mode : Constant
Bit rate : 128 kb/s
C:\Users\User\Downloads\ac>
這是每個文件的所有 mediainfo 數據,因此您可以自己決定是否可以從中看到更改音量時發生的任何實質性差異。
C:\Users\User\Downloads\ac>mediainfo ac.mp4
General
Complete name : ac.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 186 MiB
Duration : 1 h 7 min
Overall bit rate : 383 kb/s
Writing application : Lavf58.20.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.2
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 h 7 min
Bit rate : 252 kb/s
Width : 1 366 pixels
Height : 768 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 24.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.010
Stream size : 122 MiB (66%)
Writing library : x264 core 157 r2945 72db437
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x3 / me=dia / subme=1 / psy=1 / psy_rd=1.00:0.00 / mixed_ref
=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=4 / lookahead_threads=4 /
sliced_threads=1 / slices=4 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=1 / keyint=250 / keyint_
min=24 / scenecut=40 / intra_refresh=0 / rc=crf / mbtree=0 / crf=26.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC SBR
Format/Info : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name : HE-AAC
Format settings : NBC
Codec ID : mp4a-40-5
Duration : 1 h 7 min
Duration_LastFrame : -23 ms
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 23.438 FPS (2048 SPF)
Compression mode : Lossy
Stream size : 62.2 MiB (33%)
Default : Yes
Alternate group : 1
C:\Users\User\Downloads\ac>mediainfo ac2.mp4
General
Complete name : ac2.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 187 MiB
Duration : 1 h 7 min
Overall bit rate : 384 kb/s
Writing application : Lavf58.31.104
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.2
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 h 7 min
Bit rate : 252 kb/s
Width : 1 366 pixels
Height : 768 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 24.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.010
Stream size : 122 MiB (66%)
Writing library : x264 core 157 r2945 72db437
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x3 / me=dia / subme=1 / psy=1 / psy_rd=1.00:0.00 / mixed_ref
=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=4 / lookahead_threads=4 /
sliced_threads=1 / slices=4 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=1 / keyint=250 / keyint_
min=24 / scenecut=40 / intra_refresh=0 / rc=crf / mbtree=0 / crf=26.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 1 h 7 min
Duration_LastFrame : -19 ms
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 62.4 MiB (33%)
Default : Yes
Alternate group : 1
C:\Users\User\Downloads\ac>dir ac.mp4
Volume in drive C has no label.
Volume Serial Number is 4645-5DCE
Directory of C:\Users\User\Downloads\ac
11/03/2021 15:14 195,166,205 ac.mp4
1 File(s) 195,166,205 bytes
0 Dir(s) 2,360,127,488 bytes free
C:\Users\User\Downloads\ac>dir ac2.mp4
Volume in drive C has no label.
Volume Serial Number is 4645-5DCE
Directory of C:\Users\User\Downloads\ac
11/03/2021 15:28 195,837,608 ac2.mp4
1 File(s) 195,837,608 bytes
0 Dir(s) 2,360,127,488 bytes free
C:\Users\User\Downloads\ac>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.