mercredi 17 juillet 2019

how to add subtitles to mkv file with ffmpeg

If needed, convert from mp4 to mkv:
ffmpeg -i src.mp4 -acodec copy -vcodec copy output.mkv

Optionaly convert srt file to .ass :)
ffmpeg -i subtitles.srt subtitles.ass
 
Then add some .ass to the mkv file:

ffmpeg -i mymovie.mkv -vf ass=subtitles.ass mysubtitledmovie.mkv
 
Or if srt

ffmpeg -i video.mkv -vf subtitles=subtitles.srt out.avi
 

Extract srt from mkv

ffmpeg -i the.winchesters.mkv -map 0:s:0 The.Winchesters.srt  
 
the simple example:
ffmpeg -i file.mkv -f srt -i file.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt output.mkv
 
 
The fat example:
ffmpeg -i The.Mandalorian.S01E01.WEBRip.x264-ION10.mp4 
-i Subs/2_English.srt -i Subs/3_English.srt -i Subs/4_Danish.srt 
-i Subs/5_Dutch.srt -i Subs/6_Finnish.srt -i Subs/7_French.srt 
-i Subs/8_German.srt -i Subs/9_Italian.srt -i Subs/10_nor.srt 
-i Subs/11_Polish.srt -i Subs/12_Portuguese.srt -i Subs/13_Portuguese.srt 
-i Subs/14_Spanish.srt -i Subs/15_Spanish.srt -i Subs/16_Swedish.srt 
-c:s mov_text -c:v copy -c:a copy -map 0:v -map 0:a -map 1 -map 2 -map 3 
-map 4 -map 5 -map 6 -map 7 -map 8 -map 9 -map 10 -map 11 -map 12 -map 13 
-map 14 -map 15
-metadata:s:s:0 language=eng -metadata:s:s:1 language=eng 
-metadata:s:s:2 language=dnk -metadata:s:s:3 language=nld 
-metadata:s:s:4 language=fin -metadata:s:s:5 language=fra 
-metadata:s:s:6 language=ger -metadata:s:s:7 language=ita 
-metadata:s:s:8 language=nor -metadata:s:s:9 language=pol 
-metadata:s:s:10 language=bra -metadata:s:s:11 language=bra 
-metadata:s:s:12 language=esp -metadata:s:s:13 language=spa 
-metadata:s:s:14 language=swe The.Mandalorian.S01E01.WEBRip.x264-ION10-subs.mp4  

Aucun commentaire:

Enregistrer un commentaire

bash script to convert all mp4 in a folder to mkv files with ffmpeg

 #!/bin/bash for i in *.mp4; do   echo "$i" "${i%%.*}.mkv"   ffmpeg -i "$i" -vcodec copy -acodec copy "${...