[FFmpeg-user] Lossless cut from a h264 video with audio

Samat Galimov s at samat.me
Wed Oct 10 18:44:56 EEST 2018


Hello,

tl;dr: Q: is there a way to cut a 10 second clip from a h264 video (downloaded from youtube) to later use it in web browsers with no quality loss?

What I have tried so far: http://alpha.rawg.io/question/

Long version:

My inputs are http://alpha.rawg.io/question/cook.txt <http://alpha.rawg.io/question/cook.txt>

My first attempt is to opt-in for copy codecs using the following command:

	/usr/bin/env ffmpeg -y -ss 0:03:18 -t 0:00:10 -i cook.mp4 -c copy cook-start.mp4 &> cook-start.txt

What I've got is:
- Safari: audio/video sync is OK, beginning is OK, but additional 3 seconds of audio without video in the end
- Chrome: audio/video is out of sync

Then I tried to specify -ss as an output option:

	/usr/bin/env ffmpeg -y -i cook.mp4 -ss 0:03:18 -t 0:00:10 -c copy cook-end.mp4 &> cook-end.txt

Safari & Chrome: first 3 seconds have no video, but audio only.


Is there a clever trick to overcome this apparent keyframe location issue while not re-encoding videos? 

If there is no way to avoid re-encoding, what options should I use to minimise quality loss?

Here is the webpage to check out my results & source files: https://alpha.rawg.io/question/ <https://alpha.rawg.io/question/>

Thank you very much in advance.

Samat.


More information about the ffmpeg-user mailing list