Reputation: 455
I'm trying to embed subtitles into video and removing the subtitles back again without changing the video, meaning I want the output video to be the same with the original video.
I'm using the following command to embed the subtitles
ffmpeg -i original.mp4 -i original.srt \
-c:v copy -c:a copy -c:s mov_text \
-map_metadata 0:g -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a \
-movflags +faststart -threads 8 \
output.mp4
To remove the subtitles,
ffmpeg -i output.mp4 \
-c:v copy -c:a copy \
-map_metadata 0:g -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a \
-movflags +faststart -threads 8 \
-sn \
removed.mp4
The output is almost the same but I couldn't figure out what would cause the difference. When I compare the binaries, almost all of the differences are
original: 0xF3
removed: 0xF4
The bytes are incremented by 1, I think only in the header.
Can you help? Thank you in advance.
Upvotes: 2
Views: 6080
Reputation: 92928
In general, you can't expect the result of a ffmpeg remux operation to be identical to the source, especially if the source was generated by some other app.
For starters, the source generator may write metadata keys which ffmpeg's muxer does not write. There may be proprietary boxes in the source moov that ffmpeg does not write.
Finally, ffmpeg will imprint the lav library versions, but those can be skipped by supplying -fflags +bitexact
.
Note that by using copy
, the stream packets are copied so the integrity of the media streams is preserved.
Upvotes: 3