多次修剪(音訊)ffmpeg期間的緩衝區錯誤

多次修剪(音訊)ffmpeg期間的緩衝區錯誤

我正在嘗試修剪和連接音訊檔案的多個部分。經過多次搜索,這似乎有效。

ffmpeg -i dd.3gpp -filter_complex "[0]atrim=start=00:00:00.060:end=00:00:46.580[a];[0]atrim=start=00:0:50.250:end=00:01:50.670[b];[a][b]concat=n=2:v=0:a=1" output.mp3

然而,沒多久我就意識到它只有在修剪部分之間的間隔很短的情況下才有效。將第二個修剪部分的時間戳記更改為此,

ffmpeg -i dd.3gpp -filter_complex "[0]atrim=start=00:00:00.060:end=00:00:46.580[a];[0]atrim=start=00:03:23.250:end=00:06:50.670[b];[a][b]concat=n=2:v=0:a=1" output.mp3

它不斷向我拋出這個錯誤。

[out_0_0 @ 000001df0a98d6c0] 100 個緩衝區在 out_0_0 中排隊,可能會出現問題。 [out_0_0 @ 000001df0a98d6c0] 1000 個緩衝區在 out_0_0 中排隊,可能會出現問題。

報告

ffmpeg version git-2019-12-12-f58bda6 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  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-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 36.101 / 56. 36.101
  libavcodec     58. 65.100 / 58. 65.100
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.101 / 58.  9.101
  libavfilter     7. 68.100 /  7. 68.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dd.3gpp':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 2019-12-14T18:42:01.000000Z
    com.android.version: 7.0
  Duration: 00:08:46.06, start: 0.000000, bitrate: 129 kb/s
    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2019-12-14T18:42:01.000000Z
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 (aac) -> atrim
  Stream #0:0 (aac) -> atrim
  concat -> Stream #0:0 (libmp3lame)
Press [q] to stop, [?] for help
Output #0, mp3, to 'output.mp3':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 0
    compatible_brands: isom3gp4
    com.android.version: 7.0
    TSSE            : Lavf58.35.101
    Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp (default)
    Metadata:
      encoder         : Lavc58.65.100 libmp3lame
size=     170kB time=00:00:10.84 bitrate= 128.5kbits/s speed=21.7x    
size=     256kB time=00:00:19.77 bitrate= 106.0kbits/s speed=19.7x    
size=     256kB time=00:00:28.17 bitrate=  74.4kbits/s speed=18.7x    
size=     512kB time=00:00:39.69 bitrate= 105.7kbits/s speed=19.8x    
[out_0_0 @ 000001df0a98d6c0] 100 buffers queued in out_0_0, something may be wrong.
[out_0_0 @ 000001df0a98d6c0] 1000 buffers queued in out_0_0, something may be wrong.
size=    1280kB time=00:01:33.09 bitrate= 112.6kbits/s speed=22.9x    
size=    1521kB time=00:01:37.27 bitrate= 128.1kbits/s speed=22.9x    
video:0kB audio:1520kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.023446%

是不是有什麼地方做錯了?歡迎所有建議。

在此輸入影像描述

答案1

所以在研究了這兩個代碼一段時間之後,

ffmpeg -i dd.3gpp -filter_complex "[0]atrim=start=00:00:00.060:end=00:00:46.580[a];[0]atrim=start=00:0:50.250:end=00:01:50.670[b];[a][b]concat=n=2:v=0:a=1" output.mp3

ffmpeg -i dd.3gpp -filter_complex "[0]atrim=start=00:00:00.060:end=00:00:46.580[a];[0]atrim=start=00:03:23.250:end=00:06:50.670[b];[a][b]concat=n=2:v=0:a=1" output.mp3

看來緩衝區錯誤與兩次修剪之間的時間間隔是否短無關。

相反,格式時間戳似乎是問題所在。我將時間戳更改為S+[.m...], 而不是[HH:]MM:SS[.m...]

ffmpeg -i dd.3gpp -filter_complex "[0]atrim=start=0.060:end=46.580[a];[0]atrim=start=203.250:end=410.670[b];[a][b]concat=n=2:v=0:a=1" output.mp3

並且錯誤不再出現。第一個程式碼工作正常,因為00:00:ss.m..我認為所有時間戳記都落在秒列 ( ) 內。我必須說,我對為什麼格式在這種情況下起作用一無所知。也許這裡的專業人士可以解釋得更好。

答案2

問題的根源在於冒號“:”用於透過filter_complex分隔參數。所以你需要逃避它。

優秀的答案來自https://superuser.com/a/1145796

提供以下字元轉義解決方案:

"trim=start='00\:00\:01.23':end='00\:00\:04.56'" "trim=start=00\\\:00\\\:01.23:end=00\\\:00\\\:04.56" trim=start=00\\\\:00\\\\:01.23:end=00\\\\:00\\\\:04.56

玩得開心!

相關內容