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

Add direct access to frame pict type in Frame Class #1730

Merged
merged 5 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add new `Frame.pictType` field set to `I`, `P`, `B`, etc by `FFmpegFrameGrabber` ([pull #1730](https://github.com/bytedeco/javacv/pull/1730))
* Set metadata for `AVFrame.opaque` in `FFmpegFrameGrabber` with call to `av_frame_copy_props()` ([issue #1729](https://github.com/bytedeco/javacv/issues/1729))
* Add `charset` property to `FrameGrabber` and `FrameRecorder` to use for metadata from FFmpeg ([pull #1720](https://github.com/bytedeco/javacv/pull/1720))
* Call `Frame.close()` on temporary clones in `Java2DFrameUtils` to prevent premature deallocations ([issue #1716](https://github.com/bytedeco/javacv/issues/1716))
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ public synchronized Frame grabFrame(boolean doAudio, boolean doVideo, boolean do
done = true;
frame.timestamp = timestamp;
frame.keyFrame = picture.key_frame() != 0;
frame.pictType = (char)av_get_picture_type_char(picture.pict_type());
}
}
} else if (doAudio && audio_st != null && pkt.stream_index() == audio_st.index()) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/bytedeco/javacv/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class Frame implements AutoCloseable, Indexable {
/** A flag set by a FrameGrabber or a FrameRecorder to indicate a key frame. */
public boolean keyFrame;

/** The type of the image frame ('I', 'P', 'B', etc). */
public char pictType;

/** Constants to be used for {@link #imageDepth}. */
public static final int
DEPTH_BYTE = -8,
Expand Down Expand Up @@ -125,6 +128,7 @@ public Frame(int width, int height, int depth, int channels, int imageStride) {
this.imageDepth = depth;
this.imageChannels = channels;
this.imageStride = imageStride;
this.pictType = '\0';
this.image = new Buffer[1];
this.data = null;
this.streamIndex = -1;
Expand Down Expand Up @@ -216,6 +220,7 @@ public Frame clone() {
newFrame.imageChannels = imageChannels;
newFrame.imageStride = imageStride;
newFrame.keyFrame = keyFrame;
newFrame.pictType = pictType;
newFrame.streamIndex = streamIndex;
newFrame.opaque = new Pointer[3];
if (image != null) {
Expand Down