我正在尝试修剪和连接音频文件的多个部分。经过多次搜索,这似乎可行。
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] out_0_0 中有 100 个缓冲区排队,可能出现问题。 [out_0_0 @ 000001df0a98d6c0] out_0_0 中有 1000 个缓冲区排队,可能出现问题。
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
玩得开心!