Hacker News new | past | comments | ask | show | jobs | submit login

I love ffmpeg, a single command of `ffmpeg -ss 01:15:42 -to 01:16:00 -i example.mp4 -c copy output.mp4` will let you create a video clip at a certain point in time from a larger video without decoding/encoding it.

I wrote a blog post and made a demo video the other day going over using this feature at: https://nickjanetakis.com/blog/create-video-clips-with-ffmpe...




i understand that this is the fastest way to extract frames, but it is limited by key frame availability in the original file (i.e.) you can only start the output from a keyframe.

in this case, it is important to be aware that the times you specify may not be extracted exactly. it will be off by a few frames based on keyframe availability. the only way to extract exact frames is to re-encode. :)


This is true. Do you have a use case where being off by a few frames might be a deal breaker?

Personally I've created dozens of clips using this method and it always turns out ok. It gives you about ~1 second precision on where you want to make your cuts. After I create the clips I can play things back normally, complete with an ability to seek to specific points successfully.


>> Do you have a use case where being off by a few frames might be a deal breaker?

Yes, in action recognition tasks (machine learning), e.g., if you have a large video with temporal annotations (start/end times where an action occurs) you may want to extract clips to sense-check the annotations. Being exact is important.


yeah it probably doesn't matter in practice. you may run into some audio sync issues.

but the ~1 second precision that you see is by accident where the source file happens to have a keyframe every 1 second. that may not be the case always. :)


Fundamentally (ignoring ffmpeg incantations), I think there are four options:

1. re-encode the whole thing

2. re-encode just the first GOP

3. start a bit early or late

4. include the full first GOP but use an edit list to instruct the player to skip to the timestamp of interest


yeah these are pretty much the options. i believe the ffmpeg command that OP suggested would do option 3.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: