Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get Frame Type( I、P、B)by JavaCV #1729

Closed
steeveen opened this issue Dec 7, 2021 · 9 comments
Closed

How to get Frame Type( I、P、B)by JavaCV #1729

steeveen opened this issue Dec 7, 2021 · 9 comments

Comments

@steeveen
Copy link
Contributor

steeveen commented Dec 7, 2021

Frame frame=ffmpegGrameGrabber.grabFrame(false,true,true,false,false);
But all frame.opaque.pict_type()==AV_PICTURE_TYPE_NONE

@steeveen steeveen changed the title How to get Frame Type( I How to get Frame Type( I、P、B)by JavaCV Dec 7, 2021
@saudet
Copy link
Member

saudet commented Dec 7, 2021

It's not currently copied, but it shouldn't be too hard to fetch that information around this line:
https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java#L1402
Contributions are welcome!

@steeveen
Copy link
Contributor Author

steeveen commented Dec 7, 2021

I’m not very familiar with its code.... It seems that I should add an attribute like pictType in Frame Class? and then assign picture.pict_type() to it?

@saudet
Copy link
Member

saudet commented Dec 7, 2021

Sounds reasonable, yes.

@steeveen
Copy link
Contributor Author

steeveen commented Dec 7, 2021

OK, I will have a try

@steeveen
Copy link
Contributor Author

steeveen commented Dec 9, 2021

I am adding pictType to Frame class. And adding pkt_dts, pts to it at the same time. which I think it might be useful.
But I met some problem when testing it. Idea tell me some class in the source code doesn't exist. Such as FLYCAPTURE_OK,FlyCaptureInfoEx
I think this maybe caused by maven? Some change on pom? or by pulling mistaken branch?(I made the change on master)
Can you give me some help?
Or I can just PR the commit to this repo?After all these changes are very simple

image

@saudet
Copy link
Member

saudet commented Dec 9, 2021

That file shouldn't get compiled, you can ignore it.

I don't think we should expose dts and pts. AFAIK that's only useful for packets, not frames, right?

In any case, a reference to the original AVFrame is in Frame.opaque, so you could access it that way in your code without modifying JavaCV, if that's OK with you?

@steeveen
Copy link
Contributor Author

steeveen commented Dec 9, 2021

Yes. Frame.opaque is a good way to access the unused attributes.
But my motivation for adding them is that I find frame.opaque.pts always return Long.MIN_VALUE. As opaque.pkt_dts returning Long.MIN_VALUE. frame.opaque.pict_type returning 0.
Haven't you encountered this problem?

saudet added a commit that referenced this issue Dec 10, 2021
@saudet
Copy link
Member

saudet commented Dec 10, 2021

Ah, yes, you're right, those fields are not getting set in that AVFrame. I've added a call to av_frame_copy_props() in commit 33bea56, that should do it. Please give it a try with the snapshots: http://bytedeco.org/builds/

@saudet saudet added bug and removed help wanted labels Dec 11, 2021
@steeveen
Copy link
Contributor Author

Hi,saudet.
I have commited the change. https://github.com/bytedeco/javacv/pull/1730
You can have a look at the PR.

anotherche pushed a commit to anotherche/javacv that referenced this issue Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants