How to Add Rifftrax Directly to a Movie's Audio Track
source link: https://rudism.com/how-to-add-rifftrax-directly-to-a-movies-audio-track/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to Add Rifftrax Directly to a Movie's Audio Track2020-05-23 (posted in blog)
I’m not even going to talk about how much I love Mystery Science Theater 3000 right now, but suffice it to say I also love Rifftrax and own a bunch of “Just the Jokes” audio commentaries. I hate having to use a second audio device to play them while I watch the movie, though.
Since I’m in the process of ripping all of my DVDs and Blu-rays to my Plex server, I decided to devise a way to incorporate the Rifftrax audio directly as an alternate audio track. It’s not enough to just plop the Rifftrax audio into the movie as an alternate audio track on its own, since then you really will hear “Just the Jokes” with no audio from the actual movie at all. Instead we’ll need to mix the Rifftrax with the movie’s audio into a new combined audio track and add that to the movie.
This assumes you have
sox installed and that you’ve already ripped the movie into a
mkv container with an
ac3 audio track.
1. Extract the Primary Audio Track
The first step is to figure out the track number of the movie’s audio.
This will list all of the video and audio tracks in the
mkv file. You want to identify the audio track’s id, which will be denoted with
Track type: audio. You want to get the
track ID for mkvmerge & mkvextract. For this example we will assume that is
1. Note that an
mkv can contain multiple audio tracks (in different languages, for example), so make sure you choose the right one.
mkvextract MyMovie.mkv tracks 1:audio.ac3
The above command will extract the track with id
1 to a file called
audio.ac3. You can try playing that file with
vlc and it should be the full audio track of your movie.
2. Trim Rifftrax Audio
This step is a bit of an art and may take a couple tries and tweaks to get right. Essentially you need to listen to the Rifftrax and identify the timestamp where you’re supposed to pause it and wait for a cue in the movie. Let’s say this happens at
2:00. Then you need to watch the movie and identify the timestamp that the cue occurs at. Let’s say this happens at
0:15. Now you subtract the movie cue timestamp from the Rifftrax pause timestamp and get
1:45; that’s how much time you need to trim from the beginning of the Rifftrax audio in order to properly sync it with the movie’s audio track.
sox rifftrax.mp3 rifftrax-trimmed.mp3 trim 1:45
That will create a new
rifftrax-trimmed.mp3 file from your
rifftrax.mp3 file with the first minute and forty five seconds trimmed.
If at the end of this process, you watch the movie with your new Rifftrax audio track and find that the sync is off by some fraction of a second in one direction or the other, you can to come back to this step and attempt to fine-tune it. In this example you could replace
1:44.5 if the robot voice is coming in half a second early, or
1:45.5 if it’s coming in half a second late.
3. Up-mix Rifftrax Channels
Rifftrax “Just the Jokes” mp3 files are mono-channel. This step will convert them to a multi-channel ac3 file to match the number of channels in your movie’s audio. If your movie’s audio is 5.1 surround, this command will put the Rifftrax audio into the front left and right speakers:
ffmpeg -i rifftrax-trimmed.mp3 -filter_complex "[0:a]pan=5.1|FL=FC|FR=FC|LFE=FC[a]" -map "[a]" -c:a ac3 riff-audio.ac3
If your movie only has stereo audio you can do this:
ffmpeg -i rifftrax-trimmed.mp3 -ac 2 -c:a ac3 riff-audio.ac3
4. Mix Movie Audio with Rifftrax
Now we need to combine the
audio.ac3 file you extracted from the
mkv in the first step with the new trimmed and up-mixed Rifftrax
riff-audio.ac3 you generated in the previous step.
ffmpeg -i audio.ac3 -i riff-audio.ac3 -filter_complex "[0:a]volume=0.65,amix=inputs=2:duration=longest" -b:a 640k riff-combined.ac3
You should replace
-b:a 640k with whatever the bitrate of your
audio.ac3 file is, since going higher than that would be pointless. The
[0:a]volume=0.65, part reduces the movie audio to 65% to ensure you can still hear the Rifftrax even when it gets loud, but you can adjust or omit that depending on how loud the specific movie is.
The above command will create a new
riff-combined.ac3 file which should have both the movie audio and the Rifftrax mixed into a single track.
You can now listen to
vlc until you hear an instance of the Rifftrax robot voice thing speaking along with dialog in the movie to see how well it’s synced. If you find that it’s off by an unacceptable amount, you have to go back to step 2 and try trimming the Rifftrax by a different amount.
5. Add Combined Rifftrax Track
Now you can run
mkvtoolnix to add the new combined Rifftrax audio track into the
mkv file. Just click the “Add Source Files” button and select the
mkv file, then click “Add Source Files” again and select your
rifftrax-combined.ac3 file. The new combined track will show up at the bottom of the track listing. Make sure to click it there and set the track’s language and give it a name like “Rifftrax,” and then click “Start Multiplexing” to generate a new
To test it out, open your newly multiplexed
vlc. You should see your new “Rifftrax” entry in the Audio->Audio Tracks menu. Select it and get to laughing.
Short Permalink for Attribution: rdsm.ca/lygvvComments
Aggregate valuable and interesting links.
Joyk means Joy of geeK