Skip to content

Commit 6638905

Browse files
authored
* Add FrameRecorder.videoProfile property (pull #2361)
1 parent ce447cf commit 6638905

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Add `FrameRecorder.videoProfile` property ([pull #2361](https://github.com/bytedeco/javacv/pull/2361))
23
* Upgrade dependencies for OpenCV 4.12.0, FFmpeg 8.0
34

45
### June 30, 2025 version 1.5.12

src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ public synchronized void startUnsafe() throws Exception {
609609
if (gopSize >= 0) {
610610
video_c.gop_size(gopSize); /* emit one intra frame every gopSize frames at most */
611611
}
612+
if (videoProfile >= 0) {
613+
video_c.profile(videoProfile);
614+
}
612615
if (videoQuality >= 0) {
613616
video_c.flags(video_c.flags() | AV_CODEC_FLAG_QSCALE);
614617
video_c.global_quality((int)Math.round(FF_QP2LAMBDA * videoQuality));
@@ -651,7 +654,9 @@ public synchronized void startUnsafe() throws Exception {
651654
} else if (video_c.codec_id() == AV_CODEC_ID_H264) {
652655
// default to constrained baseline to produce content that plays back on anything,
653656
// without any significant tradeoffs for most use cases
654-
video_c.profile(AV_PROFILE_H264_CONSTRAINED_BASELINE);
657+
if (videoProfile < 0) {
658+
video_c.profile(AV_PROFILE_H264_CONSTRAINED_BASELINE);
659+
}
655660
}
656661

657662
// some formats want stream headers to be separate

src/main/java/org/bytedeco/javacv/FrameRecorder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static FrameRecorder create(String className, String filename, int width,
108108

109109
protected String format, videoCodecName, audioCodecName;
110110
protected int imageWidth, imageHeight, audioChannels;
111-
protected int pixelFormat, videoCodec, videoBitrate, imageScalingFlags, gopSize = -1;
111+
protected int pixelFormat, videoCodec, videoBitrate, imageScalingFlags, gopSize = -1, videoProfile = -1;
112112
protected double aspectRatio, frameRate, videoQuality = -1;
113113
protected int sampleFormat, audioCodec, audioBitrate, sampleRate;
114114
protected double audioQuality = -1;
@@ -205,6 +205,13 @@ public void setGopSize(int gopSize) {
205205
this.gopSize = gopSize;
206206
}
207207

208+
public int getVideoProfile() {
209+
return videoProfile;
210+
}
211+
public void setVideoProfile(int videoProfile) {
212+
this.videoProfile = videoProfile;
213+
}
214+
208215
public double getAspectRatio() {
209216
return aspectRatio;
210217
}

0 commit comments

Comments
 (0)