How to splice two OBS recordings together with FFmpeg

How to splice two OBS recordings together with FFmpeg

You have two or more OBS recordings you'd like to edit into a single file. What's the quickest way to do that? You could use iMovie, Final Cut Pro, or even Quicktime, but there's a much faster way. It's a command-line tool called FFmpeg

FFmpeg has been described as the Swiss Army Knife of video tools. It's very versatile, but has a steep learning curve. Zandr says: "It's like a Swiss Army Knife with 200 blades... it can do anything but there's no usable handle."

The secret to FFmpeg being able to do this job so quickly is that unlike many video editors, FFmpeg can concatenate some video formats without needing to re-encode the file. Unfortunately the FLV files produced by OBS aren't in one of those formats. Fortunately, it's just the Flash Video container that is the problem, not the underlying video encoding. So the trick is to change the container first, and then concatenate the files and change the container back.

Lets assume you have two FLV files produced by OBS. for clarity we'll call them partA.flv and partB.flv rather than using OBS's rather unwieldy date-stamp file names. The first step is to convert them from Flash Video files to mpeg-transport files:

ffmpeg -i partA.flv -c copy -bsf:v h264_mp4toannexb -f mpegts partA.ts
ffmpeg -i partB.flv -c copy -bsf:v h264_mp4toannexb -f mpegts partB.ts

Next we'll concatenate those into a new Flash Video file named result.flv:

ffmpeg -i "concat:partA.ts|partB.ts" -c copy -bsf:a aac_adtstoasc result.flv
You could just as easily have the output be an mp4 file:

ffmpeg -i "concat:partA.ts|partB.ts" -c copy -bsf:a aac_adtstoasc result.mp4
To learn more about concatenating files using FFmpeg, check out the concatenation docs on the FFmpeg wiki.
Author
Air Mozilla
Views
2,749
First release
Last update
Rating
0.00 star(s) 0 ratings
Top