audio - 是否可以在不使用 ffmpeg 重新编码的情况下更改音量?

标签 audio ffmpeg bitrate re-encoding

我刚刚有这个问题,因为我在 ffmpeg 中使用了以下命令:

ffmpeg -i input.wav -filter:a "volume=0.2" output.wav

遵循此处的文档:https://trac.ffmpeg.org/wiki/AudioVolume

但是,当我创建新文件时,输出的大小是输入的一半,并且音轨的比特率也降低了。

所以我的问题是:
  • 比特率是否应该像这样随着音量的减少和增加而降低?
  • 是否可以在不使用 ffmpeg 重新编码的情况下更改音量?
  • 最佳答案

    我不是专家,但我增加音量的方式似乎不会引起问题......例如音频的比特率相同...文件大小也相似。

    ffmpeg -i ac.mp4 -af volume=7 -vcodec copy ac2.mp4
    
    注意-以下是涉及 c# 的编程问题,但有人提到上述 Increase/Decrease audio volume using FFmpeg
    对于文档
    ffmpeg - ?没有显示太多。如果你这样做 ffmpeg -? | grep "vol"那么它提到的只是“-vol volume” 如果你这样做 ffmpeg -? | grep "-af"那么它只说-af filter_graph set audio filters"没有提及您可以使用哪些音频过滤器。
    但是与一些 ffmpeg 专家交谈时,他们提到了重新文档..
    "
    有 ffmpeg-filters 手册页以及 -h filter=NAME 向您展示了可用于过滤器的选项的简要说明。
    在网上你也有 ffmpeg-all 一个 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>
    

    关于audio - 是否可以在不使用 ffmpeg 重新编码的情况下更改音量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60257883/

    相关文章:

    python - 我怎样才能创作旋律?有声音模块吗?

    video - 如何在ffmpeg中调用atadenoise函数?

    node.js - 使用 ffmpeg,我无法在 node.js spawn 上收到任何错误消息

    javascript - ytdl 和 ffmpeg 的 Node js async/await promise 问题

    python - 当我尝试以 2116kbps 播放 wav 文件时,OpenAL 只会发出噪音,有什么问题吗?

    ios - Audio Units支持airplay吗?

    python - 使用 ossaudiodev 进行播放

    python - Audiomath 中的动态平移并不完全平滑

    powershell - 在Powershell中按比特率递归获取文件列表

    FFmpeg:比特率动态变化