문제

i want to capture some frame from a video so i used command like this:

ffmpeg -i MyVideo.mp4 -ss 1:20:12 -vframes 1 test-pic.jpg

but ffmpeg proccess frame from begin of video so this command is too slow. i research and i found some article about keyframe so i try to extract keyframe by a command like this

ffmpeg -vf select="eq(pict_type\,PICT_TYPE_I)" -i MyVideo.mp4 -vsync 2 -s 160x90 -f image2 thumbnails-%02d.jpeg

but this command also is to slow and capture too many frame. I need a linux command or c++ or python code to capture a frame that dont take long time

도움이 되었습니까?

해결책

The ffmpeg wiki states regarding fast seeking:

The -ss parameter needs to be specified before -i:

ffmpeg -ss 00:03:00 -i Underworld.Awakening.avi -frames:v 1 out1.jpg

This example will produce one image frame (out1.jpg) somewhere around the third minute from the beginning of the movie. The input will be parsed using keyframes, which is very fast. The drawback is that it will also finish the seeking at some keyframe, not necessarily located at specified time (00:03:00), so the seeking will not be as accurate as expected.

You could also use hybrid mode, combining fast seeking and slow (decode) seeking, which is kind of the middle ground.

If you want to implement this in C/C++, see the docs/examples directory of ffmpeg to get started and av_seek_frame.

I recently hacked together some C code to do thumbnails myself, which uses the hybrid mode effectively. May be helpful to you, or not.

다른 팁

Hello, Mr. Anderson.

I'm not familiar with using C++ or Python to do such a thing. I'm sure it's possible (I could probably get a good idea of how to do this if I researched for an hour), but the time it would take to implement a full solution may outweigh the time cost of finding a better frame capturing program. After a bit of Googling, I came up with:

  1. VirtualDub
  2. Camtasia
  3. Frame-shots
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top