Here’s a table that shows how that expression evaluates on a per-frame basis. ![]() It should seek to 4.6, the nearest previous keyframe, but what actually happens is it seeks to 3.56, two keyframes before the given timestamp. In other words it’s saying “if the current time t is greater than (the total number of keyframes so far * 3), force a keyframe” – which has the effect of forcing one keyframe every 3 seconds. I want it to cut starting 5 seconds in until the end of the video so I did this: ffmpeg -ss 5 -i 'input.mp4' -c:v copy -c:a copy -avoidnegativets makezero out.mp4. Walking through that, we’re providing a gte (greater than or equal) expression which returns 1 on the first frame we hit at each 3 second interval. This is what I used: ffmpeg -i in.mp4 -force_key_frames "expr:gte(t,n_forced*3)" out.mp4 As the documentation explains, you can issue an expression to force a keyframe at the required interval. Getting it to work properly is just matter of inserting keyframes where they’re needed, and this is quite easily done on the command line with ffmpeg. Forcing keyframes with an ffmpeg expression It turns out this is simply a keyframing issue with the video file itself, in that our video didn’t have keyframes placed correctly around the points we’d actually be jumping to. ![]() Doing a jwplayer().seek(3) for example might not actually take you to the 3 second mark, but somewhere nearby, or perhaps would even cause the video to start playing from the beginning. ![]() The video is served up in JW Player, and one issue we were having was with it not always seeking accurately. It feels a bit like you’re inside a 3D model but it’s actually just playing through a video, jumping to the appropriate “chapter” depending on which direction you navigate in. The interaction is a bit like Google Streetview in that you can click forwards and backwards through a virtual world. We’ve been building an interesting 3D interactive at SHOWstudio recently where you can take a tour around the inside of a building.
0 Comments
Leave a Reply. |