JenyaKirmiza / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Grabbing AVFrames with FFmpegFrameGrabber #399

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

I need to open a video file and store it's frames in an ArrayList. The problem 
is. that FFmpegFrameGrabber only allows me to grab either IplImage
or Frame and neither of those types store information about frame's timecode, 
picture type (intra coded, predicted, bi-directional) and MacroBlocks.
I need this infromation to further work with gained frames in order to 
determine which one of them are keyframes (I know FFmpegFrameGrabber allows for 
some basic kind of keyframe detection but the program I'm writing is part of my 
thesis and unfortunately the keyframe extraction has to be a bit more advanced 
than this).

I've been trying to understand the way the FFmpegFrameGrabber works so that I 
could figure out how to modify it to grab AVFrames instead but to no avail.

So my question is whether such a modification is possible?

What version of the product are you using? On what operating system?

Lastest version, Windows 7.

Please provide any additional information below.

Original issue reported on code.google.com by glere...@gmail.com on 22 Dec 2013 at 11:29

GoogleCodeExporter commented 9 years ago
The source code is available, so modifying FFmpegFrameGrabber.java in the way 
you need to shouldn't be too difficult. The AVFrame object is available as a 
field variable, so exposing that should be all you need AFAIK.

If that's not what you are looking for, please explain a bit more clearly how 
you would have FFmpegFrameGrabber modified, thanks!

Original comment by samuel.a...@gmail.com on 23 Dec 2013 at 4:03

GoogleCodeExporter commented 9 years ago
Thank you for responding.

So to be more specific - I have been going through the source code trying to 
get my head around it and figure out how it works. But that's pretty much my 
problem as I'm not very experienced programmer and FFmpeg itself seems horribly 
complicated to me plus the whole code is written in a very different style than 
what I'm used to from Java and C#, which I take it is the result of you trying 
to make this whole thing resemble C++ as much as possible.

Specifically, I need to either modify the existing grabFrame method so that it 
would return AVFrame instead of Frame or create a new method AVFrame 
grabAVFrame(). The overall functionality would be the same, all I need is the 
different return type.

Original comment by glere...@gmail.com on 23 Dec 2013 at 1:01

GoogleCodeExporter commented 9 years ago
Well, there are two `AVFrame` fields, one is `picture` and the other is 
`samples_frame`. The `picture` gets updated on a call to `grab()`, so try to 
call `grab()` and `picture` should contain the info you are seeking... Is that 
it?

Original comment by samuel.a...@gmail.com on 23 Dec 2013 at 1:46

GoogleCodeExporter commented 9 years ago
Yes, that seems to work. That's actually much easier a solution than I thought 
it would be.

Thank you very much for your help.

Original comment by glere...@gmail.com on 23 Dec 2013 at 2:51

GoogleCodeExporter commented 9 years ago
In the newly released JavaCV 0.7, I've added a new `Frame.opaque` field, which 
`FFmpegFrameGrabber` fills with the corresponding raw `AVFrame` object, so that 
should take care of this issue.

Please let me know if this is not satisfactory in some way, thanks!

Original comment by samuel.a...@gmail.com on 7 Jan 2014 at 12:46