Keep (copy) subtitle stream while re-encoding video?

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Post Reply
BlackPlatypus
Beginner
Beginner
Posts: 4
Joined: Wed Jan 13, 2021 4:39 pm

Keep (copy) subtitle stream while re-encoding video?

Post by BlackPlatypus » Fri Jun 09, 2023 12:40 am

Hi!
I have .mp4 and .mkv files with embedded subtitles; for example created with

Code: Select all

ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng out.mp4
Now I would like to convert these files, re-encoding the video and audio streams, but keeping the subtitle stream.
I would expect the Mode "Stream Copy" to do just that, but in all my tests I couldn't get it to work.
No subtitle stream is included in the output.

How do I do this correctly?

verealistic
Beginner
Beginner
Posts: 1
Joined: Tue Oct 03, 2023 12:56 pm

Re: Keep (copy) subtitle stream while re-encoding video?

Post by verealistic » Tue Oct 03, 2023 12:59 pm

There is a mistake in your fomular that makes no result spacebar clicker

Jiyahana
Beginner
Beginner
Posts: 5
Joined: Wed Jan 10, 2024 5:38 pm
Contact:

Re: Keep (copy) subtitle stream while re-encoding video?

Post by Jiyahana » Tue Jan 16, 2024 6:40 pm

Hey try this for better understanding.

Code: Select all

ffmpeg -i input.mp4 -i subtitle.srt -c:v [libx264] -c:a [aac] -c:s mov_text -metadata:s:s:0 language=eng -map 0 -map 1 -strict experimental output.mp4
Ex.

Code: Select all

ffmpeg -i input.mp4 -i subtitle.srt -c:v libx264 -c:a aac -c:s mov_text -metadata:s:s:0 language=eng -map 0 -map 1 -strict experimental output.mp4
I hopes It will help for understanding.

Jiyahana
Beginner
Beginner
Posts: 5
Joined: Wed Jan 10, 2024 5:38 pm
Contact:

Re: Keep (copy) subtitle stream while re-encoding video?

Post by Jiyahana » Wed Jan 24, 2024 8:00 pm

Hey, Blackplatypus please look
Ex.

Code: Select all

ffmpeg -i input.mp4 -i subtitle.srt -c:v [video_codec] -c:a [audio_codec] -c:s mov_text -metadata:s:s:0 language=eng output.mp4
and please chenge video_codec or audio_codec.

Jiyahana
Beginner
Beginner
Posts: 5
Joined: Wed Jan 10, 2024 5:38 pm
Contact:

Re: Keep (copy) subtitle stream while re-encoding video?

Post by Jiyahana » Mon Feb 05, 2024 11:24 pm

Please try this syntax for stream copy during video re-encoding
Ex.

Code: Select all

ffmpeg -i input.mp4 -i subtitle.srt -c:v [video_codec] -c:a [audio_codec] -c:s mov_text -metadata:s:s:0 language=eng -map 0 -map 1 -strict -2 out.mp4

namagama37
Beginner
Beginner
Posts: 1
Joined: Tue Jan 23, 2024 6:09 pm

Re: Keep (copy) subtitle stream while re-encoding video?

Post by namagama37 » Mon Feb 26, 2024 6:09 pm

ffmpeg -i input.mp4 -i subtitle.srt -map 0:v -map 0:a -map 1:s -c:v libx264 -c:a aac -c:s mov_text -metadata:s:s:0 language=eng output.mp4

Post Reply