0

I'm using ffmpeg to modify multiple .mp4 files.

First I use this command to change the default language from eng to fr.

ffmpeg.exe -i "imput 1.mp4" -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default "Output 2.mp4" 

Then I want to use this command to add soft subtitles from the .srt file to the .mp4.

ffmpeg.exe -i "Input 1.mp4" -i "Input 2.srt" -c copy -c:s mov_text -metadata:s:s:0 language=fr "Output 1.mp4"

These two commands work independently but I would like to combine them in one line.

I tried something like this but only the audio changes, there is no effect on subtitles.

ffmpeg.exe -i "Input 1.mp4" -i "Input 2.srt" -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default -c:s mov_text -metadata:s:s:0 language=fr Output 1.mp4"

I know there is something wrong but I can't figure it out.

Can somebody tell me what's wrong with my combined command?

Then as I said before, I'm working on multiple files (314 exactly) and each file has it's own name and it's tedious to manually change the filename each time. Is there a way to do it for each file present in a directory?

3
  • Do the movies and the subtitles that are going to be mixed together always have the same name for example "movie 22.mkv" "movie 22.srt" and is the french audio always the second in the index of audios? Commented Dec 15, 2022 at 12:59
  • Yes, exactly, it's the same name for each file, and yes, french is always the second language
    – Dimitri
    Commented Dec 15, 2022 at 14:11
  • Did the answer I posted work? Commented Dec 15, 2022 at 21:58

1 Answer 1

1

Try this inside the folder where the videos + the subtitles are open the command prompt and use this command:

for %a in (*.mkv *.mp4) do ffmpeg -i "%a" -i "%~na.srt" -map 0 -map 1:s:0 -disposition:a:0 0 -disposition:a:1 default -c copy -metadata:s:s:0 language=fr "%~na_new.%~xa"

It should create a new video with the same name as the old one but with a "new" in the name and audio and subs changed.

2
  • Hello ! I tried your solution, bur I got an error : Au caractère Ligne:1 : 4 + for %a in (*.mkv *.mp4) do ffmpeg -i "%a" -i "%~na.srt" -map 0 -map 1 ... + ~ Parenthèse ouvrant « ( » manquante après le mot clé « for ». + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword I assume that a parenthesis is missing so I tried : for (%a in (.mkv .mp4)) but it doesn't help
    – Dimitri
    Commented Dec 16, 2022 at 14:20
  • I'm looking for a video with 2 audios to make some tests cause the answer was actually based on teory, I'll update the answer as soon as possible. Commented Dec 18, 2022 at 8:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .