How to convert an entire video directory via terminal in Ubuntu Server 18?

Asked

Viewed 37 times

1

I have a directory and wanted to convert all videos . mkv to . mp4.

The only problem I’m having is:

ffmpeg -f concact-i lista.txt -c copy novo.mp4

the only problem is that this way I get the whole directory but comes out in a single video. I’d like to take them all and convert...

1 answer

3


It’s very simple using the ffmpeg. To convert only one file you use the:

ffmpeg -i arquivo.mkv -codec copy arquivo.mp4

Here, you are copying the video codec and audio codec so that nothing is encoded and the quality reduced.

To convert all MKV files into the current directory, run a simple loop on the terminal:

r i in *.mkv; 
do
ffmpeg -i "$i" -codec copy "${i%.*}.mp4"
done

Note: Apparently subtitles included in MKV are not converted together with MKV.

A tip, try to create an alias on Ubuntu with this loop, so when you want to convert all MKV from a folder to MP4, just enter the folder and run the alias.

  • Look... Thanks a lot saw! I’ll do it next time. I just had to make a manual script to make it run auto. Imagine the work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.