Question

I want to edit an input mp4 file with audio video subtitle streams, i can successfully cut video and audio streams by: 1- Convert each part to a new mp4 file 2- Convert mp4 files to mpg files

ffmpeg -i out00.mp4 -qscale:v 0 intermediate1.mpg
ffmpeg -i out01.mp4 -qscale:v 0 intermediate2.mpg

3- Merge mpg files

ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg

4- Convert the mpg file back to mp4

ffmpeg -i intermediate_all.mpg  -f mp4 output.mp4

and i can extract the subtitle stream to srt file, but i can't cut parts of the subtitle file, do you have an idea how to do this?

Was it helpful?

Solution

Ok it works after long searching trip, here what i did:

1- Download latest FFMPEG from here (this was causing alot of problems for me).

2- Add the subtitle to the input files:

ffmpeg -i "input.mkv" -i subtitles.srt -c copy -c:s srt -metadata:s:s:1 language=eng -map 0 -map 1 -map_metadata 0 output.mkv

3- Cut the parts you need as you did normally ffmpeg will cut subtitle stream also

ffmpeg -i input.mkv -ss 00:00:00 -t 00:01:35 -c copy -map 0:0 -map 0:1 -map 0:2 -qscale:0:V 0 -y out0.mkv

4- Join the cut files using concat demux:

ffmpeg  -f concat -i mylist.txt  -c copy output.mkv

where mylist.txt contains:

file out0.mkv

file out1.mkv

And enjoy :).

OTHER TIPS

I think you have to edit the srt manually (text and timecode the text needs to appear at) and remux it to your final video with a command like:

ffmpeg -i EditedSource.mp4 -i EditedSub.srt -c copy -map 0:a -map 0:v -map 1:s output.mp4

And instead of creating these intermediate files, have you tried:

ffmpeg -i out00.mp4 -i out01.mp4 -filter_complex '[0][1]concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]'  output.mp4
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top