First steps to extracting some video with Gstreamer 1.2.1

Lasse Laursen gazoo at 42.dk
Thu Dec 5 01:27:12 PST 2013


On 02-12-2013 20:06, Tim Müller wrote:
> You might find
>
> http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/examples/snapshot/snapshot.c
>
> interesting. (You'll get an RGB frame, which of course you don't have to
> feed it to GdkPixbuf, but can pass to OpenGL as well). If you want to do
> smooth video playback rather than extract specificc frames, then there
> may be better solutions.
Hey Tim - Thanks a ton for the code link. It allowed me to fairly 
quickly push through to getting a first frame out. Just to balance my 
requests for help a little with some good news, I thought I'd splice in 
the first ever video frame I've extracted via gStreamer in my 
Application, so I'm pretty much over the moon about that right now. 
Here's my frame:

http://picpaste.com/videoframe-uqUZCbJ7.bmp

It's from an open source video of an old dancing boxing match recording. 
Currently not exactly sure why it's upside down and backwards. Possibly 
due to the imdebug tool I'm using to look at it. Regardless - now on to 
bigger and better things. I have 2 questions this time around!

1) My program is mainly audio centered, so I'll be using it as kind of a 
baseline for how video is played and at what frame-rate. The audio is 
currently hard-locked at 44100 hz and I thought to try and divide that 
by 30. Which gives me a pretty nice even number of 1470. The point of 
that exercise is of course to determine use a hardlocked 30 fps video 
format which then has every frame on-screen for exactly 1470 audio samples

Nice and simple in my opinion and a good jumping off point. If I've 
understood video formats correctly, all I need to do is throw in a video 
conversion filter in the pipeline that goes to 30 fps and then I can 
extract every keyframe, perhaps?

Or should I perhaps use 'gst_element_seek_simple' with it's nano-second 
parameter and give it 1/30th of a second for every frame I wish to extract?

2) This leads me into the 2nd question. If I'm intent on essentially 
extracting approx 30 frames a second from every video I load, is the 
approach used in the code you linked above the best way to go about 
this? It feels as though I'm perhaps misusing the pipeline by having it 
on pause and jumping between frames and then snatching frames via the 
pre-roll. I'm guessing it's possible to let it play through the file and 
possibly grab a frame every 1/30th of a second?

In case someone is wondering why I'm going through the trouble of 
getting all this data out instead of just using gStreamer to handle the 
playback I thought I'd just spend a few lines on that:

- I'd like total control for now. So I'm focusing on small videos that 
can fit entirely in memory in an uncompressed state, allowing me to make 
quick jumps.
- The gStreamer API is still fairly daunting, and integrating it with my 
GUI even more so. Just getting some data out and passing that around is 
good enough for me currently.
- A few other minor reasons not worth mentioning for now.

Anyway - I'm still on cloud 9 for having just one frame make it through! 
Whopee! :D

Thanks Tim!

Regards,
Lasse


More information about the gstreamer-devel mailing list