How to merge many mp4 videos with FFMPEG in a few seconds

I got a video, splitted into lots of files, each only 5 minutes long. I had only two options: either I wasted 30 minutes manually inserting them into a windowed program, or I wasted 2 hours figuring out a command line solution.

Obviously I chose the second option, so in the future the conversion will be more immediate, just follow this post 😉

First of all you have to create a text file that contains the list of files to convert.We have the computer do it. Assuming that all the files to be merged are all located in the same directory and are *.mp4 files, you have to type:

find *.mp4 | sed 's:\ :\ :g'| sed 's/^/file /' > list.txt

This creates a text file called list.txt which contains the file name (preceded by the keyword file).

Then, you pass the list of files to join to FFMPEG, with the command:

ffmpeg -safe 0 -f concat -i list.txt -c copy video-merge.mp4

Done!

Linux and OpenVPN, how to save the password

I recently purchased a VPN subscription from Fastest VPN, with the purpose of using it on Linux, via SSH, command line only. They don’t offer anything special about Linux and the command line, they just use OpenVPN.

How it works: simply install OpenVPN (for example with sudo apt install openvpn), then download the configuration files (for example, these are the files for Fastest VPN) and just write sudo openvpn nomeserver.ovpn to connect.

But there is a big problem: each time you have to write the password by hand! Intolerable, especially with a complex password. Luckily there is a shortcut.

You can create a file with credentials. In a directory accessible only to you, create a file called login.conf and enter, on two lines, username and password, like this:

Username
Password

At this point we modify the *.ovpn files of the configuration. For example, open Luxembourg-UDP.ovpn and see the auth-user-pass entry. We replace it with auth-user-pass login.conf, so when we load the configuration with openvpn, our credentials are auto-filled. Now though, here are 50 files, one for each server. Do we open the files one by one and edit them by hand? No way! sed was invented on purpose.

Just write it down:

sed -i 's/auth-user-pass/auth-user-pass login.conf/g' *.ovpn

and automatically all lines with auth-user-pass will be changed with auth-user-pass login.conf. So, when we download the updated server configurations, they will continue to work perfectly!