Thanks for coming here, I hope you are enjoying learning here, I have also written some books in case you want to learn a bit more :)
If you need my help with Drupal, Linux, Jira, Scripting, Automation or want to contact me then raise a ticket for me please :) and I will get back to you, promise

ffmpeg to create walking/bike ride videos with background music

I have an action camera which I use sometimes to record my rides or walks. It creates multiple MOV files of size 4GB. So to make a video using those big files takes lot of time, however all I really need to do is concatenate them, remove audio and then merge it with another big mp3 file. All the ffmpeg commands are below. Enjoy.

While concatenating multiple videos remove audio using
ffmpeg -safe 0 -f concat -i file.txt -vcodec copy -an output.MOV

Create file.txt for the concatenate to work
for f in *.mp3 ; do echo "file '${f}'" >> file.txt; done;

Concatenate audio files
ffmpeg -safe 0 -f concat -i file.txt -acodec copy all.mp3

Merge video with audio and keeping the shortest duration (from video)
ffmpeg -i output.MOV -i ~/Documents/sounds_youtube/tmp/all.mp3 -map 0:v -map 1:a -filter:a "volume=0.2" -vcodec copy -shortest final.MOV

You can also split video.
ffmpeg -i output.MOV -ss 00:00:00 -t 00:09:00 -c copy final.MOV

You can also reduce file size drastically using this command.
 ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

Reduce the size of all the videos in a directory.
for f in *.MP4;do ffmpeg -i ${f} -vcodec libx265 -crf 28 small_${f};done;

All done.

Similar posts

Ravi Sagar Newsletter

Honestly I hardly send out mails but I guess there is no harm in at least having a newsletter. I will only send newsletter when I have something important to share or an update. People are busy and no one has time to read emails these days. If you really like my content then I guess you will remember my site and come back for more.

Want to contact me?