impulsivetravelerguy
Member
- Joined
- Feb 8, 2016
- Messages
- 77
- Reaction score
- 27
- Country
- United States
I know I've been slacking lately with my custom dash cam and have been playing with footage from my existing dash cams. One problem I found is a lot of dash cams split the video into 1 minute segments. If you want to combine the videos into a single video, you have to manually put them into a video editing program and then combine them.
I solved this problem by creating a simple BASH script that will combine the videos in a given folder into a single video and then also create a separate 10x video. I created this on Ubuntu Linux. Ffmpeg can be easily installed with apt-get. This script was meant for .MP4 files, but it can be easily modified for other formats.
Once ffmpeg is installed, you just need to put this script in the folder with the video files you want to combine and then run it:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 1.) Find MP4 files and export them to list.txt with the full path
ls -d $PWD/*.MP4 > list.txt
# 2.) Edit the list.txt file to add file ' to the beginning and ' to the end
sed -i "s|$PWD|file '$PWD|g" list.txt
sed -i "s|.MP4|.MP4'|g" list.txt
# 3.) Combine all the videos into a single video
ffmpeg -f concat -safe 0 -i list.txt -c copy combined.mp4
# 4.) Speed up the video 10x. -an for removing audio so video is correct length
ffmpeg -i combined.mp4 -filter:v "setpts=0.1*PTS" -an spedup.mp4
# 5.) Cleanup list.txt
rm list.txt
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I solved this problem by creating a simple BASH script that will combine the videos in a given folder into a single video and then also create a separate 10x video. I created this on Ubuntu Linux. Ffmpeg can be easily installed with apt-get. This script was meant for .MP4 files, but it can be easily modified for other formats.
Once ffmpeg is installed, you just need to put this script in the folder with the video files you want to combine and then run it:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 1.) Find MP4 files and export them to list.txt with the full path
ls -d $PWD/*.MP4 > list.txt
# 2.) Edit the list.txt file to add file ' to the beginning and ' to the end
sed -i "s|$PWD|file '$PWD|g" list.txt
sed -i "s|.MP4|.MP4'|g" list.txt
# 3.) Combine all the videos into a single video
ffmpeg -f concat -safe 0 -i list.txt -c copy combined.mp4
# 4.) Speed up the video 10x. -an for removing audio so video is correct length
ffmpeg -i combined.mp4 -filter:v "setpts=0.1*PTS" -an spedup.mp4
# 5.) Cleanup list.txt
rm list.txt
------------------------------------------------------------------------------------------------------------------------------------------------------------------------