5

Am trying to trim and concatenate multiple sections of an audio file. After a number of searches, this seemed to work.

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

However it didn't take long before I realised that it only worked when intervals between the trimmed sections were short. Changing the timestamps of the second trimmed section into this,

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

It keeps throwing this error at me.

[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.

Report

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%

Is there something that am doing wrong? All suggestions are welcomed.

enter image description here

Gideon
  • 181

2 Answers2

4

So after playing around with the two codes for a while,

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

it appears the buffer error has nothing to do with whether or not the time intervals between the two trims ware short.

Rather, the format of the timestamps seemed to have been the issue. I changed the timestamps into S+[.m...], instead of [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

and the error is not showing up anymore. The first code worked alright because all timestamps fall within the seconds column (00:00:ss.m..) I think. I must say I have not the slightest inkling as to why the formatting plays a role in this instance. Maybe the professionals here could explain better.

Gideon
  • 181
0

The source of the issue is that the colon ":" is used for separating arguments by filter_complex. So you need to escape it.

The excellent answer from https://superuser.com/a/1145796

Provides the following character escape solutions:

"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

Have fun!