LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Help: Batch convert from MKV & embed subtitles to MP4 (https://www.linuxquestions.org/questions/linux-software-2/help-batch-convert-from-mkv-and-embed-subtitles-to-mp4-4175608740/)

alhatmy 06-27-2017 02:21 PM

Help: Batch convert from MKV & embed subtitles to MP4
 
I'm new with Linux commands, please help ...

I have folders that are full with (Mkv) files that got some subtitles inside it, srt or ass ..
I need a command that can transfer all files inside this folder from mkv to mp4 (along with hard sub for embed subtitle)

so the result will be mp4 in same quality .. same name .. with the subtitle

please ..

schneidz 06-27-2017 02:25 PM

you can probably create a script using h264enc.

alhatmy 06-27-2017 03:10 PM

any help please .. ?

creating script using h264enc ..

Laserbeak 06-27-2017 04:03 PM

I have done similar things with ffmpeg. Often you do it as a one-line using find -exec or you can put it in a script.

teckk 06-27-2017 04:41 PM

Quote:

I need a command that can transfer all files inside this folder from mkv to mp4 (along with hard sub for embed subtitle)
Copy audio and video to output with change in container.
Code:

ffmpeg -i file.mkv -c:a copy -c:v copy file.mp4
Loop through all .mkv files in directory.
Code:

for i in *.mkv; do
    echo $i
done

As for subs there are several ways to do it. Look at man ffmpeg

Hard subs in the video itself? You'll need to specify the sub file and then overlay it onto the video.

Example: Overlay dvd_subs onto video (1st vid stream, 2nd audio stream, 2nd sub stream)
Code:

ffmpeg -probesize 1000000000 -analyzeduration 100000000 -i movie.vob -filter_complex "[0:0][0:4]overlay[0]" -map [0] -map 0:2 -c:a copy -c:v libx264 -b:v 2500k movie.avi
If you already have sub files along with the .mkv files, then read the man page for a while and understand how to do what you want.

If you will do a search for this on LQ there are lots of questions on this answered.


All times are GMT -5. The time now is 01:01 PM.