簡體   English   中英

是否可以對具有精確長度(以毫秒為單位)的音頻流進行編碼?

[英]Is it possible to encode an audio stream with the exact length (to millisecond)?

我希望在 mp3、aac 或 vorbis 編解碼器中創建長度正好為30 秒的輸出文件。 我已經使用 avconv (也嘗試過 ffmpeg)和以下命令:

avconv  -i input_file_here -c:a aac -b:a 320k -t 30 out.mp4

這會產生輸出,說明它已經編碼了 30 秒,但是:

$ avprobe out.mp4
avprobe version v13_dev0-1648-gc4642788e, Copyright (c) 2007-2018 the Libav developers
  built on Apr 24 2019 15:49:35 with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:30.02, start: 0.023220, bitrate: 323 kb/s
    Stream #0:0(und): Audio: aac (LC) [mp4a / 0x6134706D]
      44100 Hz, stereo, fltp, 321 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
# avprobe output

當我在 mp3 中編碼時,它正確顯示它在編碼過程中超過 30 秒。 當我嘗試 vorbis 時,它的運行時間略少於 30 秒。

是否可以使用任何工具實現 30 秒到毫秒的長度(我更喜歡 avconv)。

在您的示例中,您使用的是 aac 音頻 44100khz。 AAC 每幀使用 1024 個樣本。 1024/44100 不能被 30 整除。所以,不可能。 可能可以調整啟動樣本,但您需要了解啟動樣本的工作原理,並修改編碼器。

Mp3 每幀使用 1152、572 或 384 個樣本,具體取決於層。 可能有一個有效的組合。 在這里查看更多https://hydrogenaud.io/index.php/topic,85125.0.html

我對 vorbis 一無所知,所以我不知道它是否可能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM