View Single Post
Old 12-06-2020, 01:56 PM   #4
leafac
Human being with feelings
 
leafac's Avatar
 
Join Date: Sep 2020
Location: Portugal
Posts: 110
Default

For those of you who, like me, stumble upon this, here are the most relevant ffmpeg commands:

Inspect a file to figure out the video and audio tracks it includes (something called “streams”):

Code:
$ ffmpeg -i example.mkv
This command is going to show you stream identifiers such as ‘0:0’. Take note, because these identifiers are used in the commands below.

Extract a video track into its own file:

Code:
$ ffmpeg -i example.mkv -map 0:0 -c copy example-video.mp4
The ‘-c copy’ part is there so that we’re just taking the video out of one container (MKV) and putting it into another (MP4) without reecoding, which would be slow and lossy.

Extract an audio track into its own file:

Code:
$ ffmpeg -i example.mkv -map 0:1 example-audio.wav
This time we’re not simply taking the audio out of one container and putting it into another; we’re actually reencoding to WAV. Typically the MKV included audio in AAC and we could use ‘-c copy’ to extract the AAC without reencoding, but I tried to work with AAC in REAPER and it didn’t go well, for example, I’d make edits and the audio would go out of sync. Reencoding isn’t as big a deal with audio as it is with video because it’s super-fast and we don’t lose quality, as we’re going from a more compressed stream (AAC) to a less compressed stream (WAV).

Extract an audio channel into its own file:

Code:
$ ffmpeg -i example.mkv -map_channel 0.1.0 example-audio.wav
Programs such as OBS may record in stereo even if the source was mono, for example, a microphone. With the command above we’re extracting a single channel and creating a mono WAV. The ‘0.1’ corresponds to the stream (the thing that was ‘0:1’ in the examples above); the final ‘.0’ means channel 0 (that is the left channel in a stereo stream).

Putting it all together:

Code:
$ ffmpeg -i example.mkv -map 0:0 -c copy example-video.mp4 -map_channel 0.1.0 example-microphone.wav -map 0:2 example-computer.wav
The example above is a single command that extracts all the relevant parts of a multitrack recording and produces files that are ready to edit in REAPER.
leafac is offline   Reply With Quote