Join 53,920 users and earn money for participation

Video Editing Trick: How to Replace the Audio Track of a Video

4 13 exc boost
Avatar for MoreGainStrategies
Written by   166
4 months ago

Here is the scenario

I run a pretty new fitness YouTube channel and periodically upload workout playlists with the best no copyright or free-to-use  music on the internet. For that purpose I wanted to create a new playlist consisting of multiple audio files which I downloaded individually. I put the songs into my video editing software of choice -- which is the free VSDC video editor at the moment. (I'm not getting paid to say that. It's just the truth.)

I went ahead and created a nice music visualization and my laptop struggled through the rendering process. It took more than 4 hours of rendering time... My laptop is pretty slow... I never intended to do more than surfing the web and streaming videos with it, but well, things happened and now I'm trying to do video editing with it... 😅

After impatiently waiting more than 4 hours for the rendering to finish, I proudly opened the video file to admire my masterpiece.

And realized:

Oh no, I forgot to adjust the tracks to matching volumes. 

Explanation

Some tracks were much louder than others. In a workout playlist, this can be intentional: You want the high energy exercises accompanied by loud, pushing music. And you want the cooldown songs to be quieter and relaxing. However, that was not what I had. I had various songs with more or less random volumes strung together. That usually happens when you take music from different sources -- which was what I had done.

Maybe it's just because I am a perfectionist (which is not necessarily a good thing -- this is not a humble brag 🙈), but I had to do something about it. Probably, nobody would have noticed (and maybe nobody will listen to the playlist anyway), but I had to fix it. I could not rest until the issue was solved. 🙈 

What can I do now?

I could change the volume on a couple of tracks and run the rendering process again. That would mean another 4 hours of 100% CPU usage... And the resulting video output would be exactly the same -- only the audio would be slightly different.

Or I could insert the rendered video as input to my video editor, mute its audio track and add the songs again -- this time with the correct volumes. That would work and it would be faster than rendering the video from scratch, but the process would still take about 3 hours of rendering time. And the video quality would probably suffer, because of the video re-rendering. I would get away with it, though, because the artifacts would not be very noticeable. However, repeat that process a couple of times and the video would not look good any more. 

Here is my idea

To save some time, I rendered a blank video (only a black rectangle as video output to be exact) together with the fixed sound. The rendering process was much faster. It took about 15 minutes. I checked that the sound of this video was as I wanted it to be. (I actually ended up readjusting the volumes and rendering the video 3 more times until I was happy with the sound.)

That was a good idea so far, but now I still needed a method to remove the sound track from the original video and replace it with the audio track of the new video. And I would like to keep the video as it is -- without re-rendering it. That would not only preserve the video quality, it would also be much faster.

After trying several methods and with some trial and error, I ended up with the command

ffmpeg.exe -i input_video.mp4 -i replacement_audio.mp4 -vcodec copy -acodec copy -map 0:v:0 -map 1:a:0 output.mp4

This command uses ffmpeg to map the video stream of the first input file and the audio stream of the second input to the output video. An explanation can be found here.

The process took about 10 minutes and was mostly limited by the write speed of the microSD card that I used to save the output video file. -- Did I mention my laptop is slow? Yes, it also only sports 64 GB as an excuse for a SSD drive. And who knows how much of that space is taken up by Windows 10 and its updates -- so I had to use a microSD card to store the video with the humble size of almost 7 GB...

How did the video turn out?

I would say that it turned out really well. You can check the result for yourself here -- maybe you will even like the playlist. 😊

So how much time did I save?

To be honest, none whatsoever... Because the research, trial and error to get to the above method took me more time than it would have taken my laptop to do the 4 hours of rendering. However, if I mess up again, now I know how to fix the problem in a less time-consuming way.

That's also one of the reasons why I am writing this article. I can not only help others searching for a solution to this problem -- now I have a place to look up the solution myself in case I ever need it again. 😄

What I plan to do next time

When I create a new workout Playlist, I will first add all the songs in the video editor, then render a blank video and check the audio until I am satisfied with it. 

Then and only then, I will start to work on the music visualization. Using this improved workflow the time-consuming video rendering has to be done only ONCE -- hopefully. If not, I keep a link to this post nearby...

 Oh and by the way

If you are using a (micro-)SD card to expand your laptop's memory like I did, make sure NOT to use the FAT32 file system. Otherwise, you will waste time rendering a video and once it exceeds a file size of about 4 GB, the file is corrupted and you can restart the rendering process... (Use exFAT instead of FAT32 and the problem is solved.)

3
$ 0.84
$ 0.74 from @TheRandomRewarder
$ 0.05 from @Macronald
$ 0.05 from @tired_momma
Sponsors of MoreGainStrategies
empty
empty
Avatar for MoreGainStrategies
Written by   166
4 months ago
Enjoyed this article?  Earn Bitcoin Cash by sharing it! Explain
...and you will also help the author collect more tips.

Comments

A patient/ impatient perfectionist! 😆 But see the final result is now your masterpiece. I'm listening to it while typing and it's pretty cool! Well done. 👏

$ 0.00
4 months ago

Thank you so much for reading the article and for your comment. I'm glad you like the playlist. 😊👍

I'm looking forward to reading the article you are currently writing. 😊

$ 0.00
4 months ago

lots of good info here...will bookmark this for future when i need to do this. great post my friend!

$ 0.00
4 months ago

Thank you so much. I'm glad you find the article helpful. 😊👍 Have a great start into your week!

$ 0.00
4 months ago