lundi 15 juillet 2019

how to add subtitles with ffmpeg on mp4 file

ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4
 
ffmpeg -i yourVideo.mp4 -i yourSubtitle.srt -c:v copy -c:a copy 
-c:s mov_text -metadata:s:s:0 language=eng yourOutputVideo.mp4 

several subtitles:
Add as many "-i file.srt" as language subtitles you have.
Important stuff here what matters is to add as many "-map x" as requested subtitles,
here in the example "-map 1 -map 2" is used because we add two subtitles files.  
Then add "-metadata:s:s:x" where x matches the map index -1. 
ffmpeg -i Clean.mp4 -i spanish.srt -i english.srt 
-c:s mov_text -c:v copy -c:a copy -map 0:v -map 0:a -map 1 -map 2 
-metadata:s:s:0 language=spa -metadata:s:s:1 language=eng With2CC.mp4
 
 
example:
ffmpeg -i The.Mandalorian.S01E06.WEBRip.x264-ION10.mp4 -i Subs/2_Danish.srt 
-i Subs/3_German.srt -i Subs/4_English.srt -i Subs/5_Spanish.srt 
-i Subs/6_French.srt -i Subs/7_Italian.srt -i Subs/8_Dutch.srt 
-i Subs/9_nor.srt -i Subs/10_Polish.srt -i Subs/11_Portuguese.srt 
-i Subs/12_Portuguese.srt -i Subs/13_Finnish.srt -i Subs/14_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 
-metadata:s:s:0 language=dnk -metadata:s:s:1 language=ger 
-metadata:s:s:2 language=eng -metadata:s:s:3 language=esp 
-metadata:s:s:4 language=fra -metadata:s:s:5 language=ita 
-metadata:s:s:6 language=nld -metadata:s:s:7 language=nor 
-metadata:s:s:8 language=pol -metadata:s:s:9 language=prt 
-metadata:s:s:10 language=prt -metadata:s:s:11 language=fin 
-metadata:s:s:12 language=swe 
The.Mandalorian.S01E06.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 "${...