Member-only story

FFmpeg — a clever piece of software

Solving a routine problem with splitting, fading and merging

Bill Clarke
2 min readDec 2, 2020

Sitting with 13 video files, in total of 6.5 h. What could I do? I wanted several small clips from these videos to merge into one. Using an app like Audacity or Reaper would be possible, but in this case it felt a bit cumbersome.

Using FFmpeg here makes this task rather straightforward. Even for an absolute beginner it wouldn’t be a big hurdle, as it mostly consist of adding start and end times to the command.

ffmpeg -i one.mp4 -i two.mp4 -b:a 160k -ar 44100 -filter_complex "\
[0:a]atrim=end='1\:0',asetpts=PTS-STARTPTS,afade=d=3:curve=hsin,areverse,afade=d=3:curve=hsin, areverse[a0]; \
[0:a]atrim=start='26\:31',asetpts=PTS-STARTPTS,afade=d=3:curve=hsin,areverse,afade=d=3:curve=hsin, areverse[a1]; \
[0:a]atrim=start='20\:48':end='22\:13',asetpts=PTS-STARTPTS,afade=d=3:curve=hsin,areverse,afade=d=3:curve=hsin, areverse[a2]; \
[1:a]atrim=end='0\:25',asetpts=PTS-STARTPTS,afade=d=3:curve=hsin,areverse,afade=d=3:curve=hsin, areverse[a3]; \
[a0][a1][a2][a3]concat=n=4:v=0:a=1[outa]" \
-map "[outa]" output.mp3

In this example two video files, one.mp4 and two.mp4, is the starting point. The flags -b:a and -ar select the bit rate and sampling rate respectively. The following lines is for each audio clip. start and end…

--

--

Bill Clarke
Bill Clarke

Written by Bill Clarke

Linux enthusiast. Also uses macOS and Chrome OS now and then.

No responses yet

Write a response