Skip to content

Commit

Permalink
Update CHANGELOG.md and fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Nov 27, 2024
1 parent a591258 commit 39fc586
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add `FrameFilter.videoFilterArgs/audioFilterArgs` properties to support multiple different inputs ([pull #2304](https://github.com/bytedeco/javacv/pull/2304))
* Ensure `FFmpegFrameGrabber.start()` skips over streams with no codecs ([issue #2299](https://github.com/bytedeco/javacv/issues/2299))
* Add `FFmpegLogCallback.logRejectedOptions()` for debugging purposes ([pull #2301](https://github.com/bytedeco/javacv/pull/2301))

Expand Down
15 changes: 8 additions & 7 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ public synchronized void startUnsafe() throws Exception {
frame = new Frame();
default_layout = new AVChannelLayout().retainReference();

if (videoFilterArgs!=null && videoInputs!=videoFilterArgs.length){
if (videoFilterArgs != null && videoInputs != videoFilterArgs.length) {
throw new Exception("The length of videoFilterArgs is different from videoInputs");
}
if (audioFilterArgs!=null && audioInputs!=audioFilterArgs.length){
if (audioFilterArgs != null && audioInputs != audioFilterArgs.length) {
throw new Exception("The length of audioFilterArgs is different from audioInputs");
}
if (image_frame == null || samples_frame == null || filt_frame == null) {
Expand Down Expand Up @@ -348,15 +348,15 @@ private void startVideoUnsafe() throws Exception {

/* buffer video source: the decoded frames from the decoder will be inserted here. */
AVRational r = av_d2q(aspectRatio > 0 ? aspectRatio : 1, 255);
String argsBase = String.format(Locale.ROOT, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d:frame_rate=%d/%d",
imageWidth, imageHeight, pixelFormat, time_base.num(), time_base.den(), r.num(), r.den(), frame_rate.num(), frame_rate.den());
buffersrc_ctx = new AVFilterContext[videoInputs];
setpts_ctx = new AVFilterContext[videoInputs];
for (int i = 0; i < videoInputs; i++) {
String name = videoInputs > 1 ? i + ":v" : "in";
outputs[i] = avfilter_inout_alloc();

String args=videoFilterArgs!=null && videoFilterArgs[i]!=null ? videoFilterArgs[i]:argsBase;
String args = videoFilterArgs != null && videoFilterArgs[i] != null ? videoFilterArgs[i]
: String.format(Locale.ROOT, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d:frame_rate=%d/%d",
imageWidth, imageHeight, pixelFormat, time_base.num(), time_base.den(), r.num(), r.den(), frame_rate.num(), frame_rate.den());
ret = avfilter_graph_create_filter(buffersrc_ctx[i] = new AVFilterContext().retainReference(), buffersrc, name,
args, null, filter_graph);
if (ret < 0) {
Expand Down Expand Up @@ -454,8 +454,9 @@ private void startAudioUnsafe() throws Exception {

/* buffer audio source: the decoded frames from the decoder will be inserted here. */
av_channel_layout_default(default_layout, audioChannels);
String aargs = audioFilterArgs!=null && audioFilterArgs[i]!=null ?audioFilterArgs[i]:String.format(Locale.ROOT, "channels=%d:sample_fmt=%d:sample_rate=%d:channel_layout=%d",
audioChannels, sampleFormat, sampleRate, default_layout.u_mask());
String aargs = audioFilterArgs != null && audioFilterArgs[i] != null ? audioFilterArgs[i]
: String.format(Locale.ROOT, "channels=%d:sample_fmt=%d:sample_rate=%d:channel_layout=%d",
audioChannels, sampleFormat, sampleRate, default_layout.u_mask());
ret = avfilter_graph_create_filter(abuffersrc_ctx[i] = new AVFilterContext().retainReference(), abuffersrc, name,
aargs, null, afilter_graph);
if (ret < 0) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/bytedeco/javacv/FrameFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public static FrameFilter createDefault(String filtersDescr, int imageWidth, int
protected double frameRate;
protected double aspectRatio;
protected int videoInputs;
protected String[] videoFilterArgs;

protected String afilters;
protected int audioChannels;
protected int sampleFormat;
protected int sampleRate;
protected int audioInputs;
protected String[] videoFilterArgs ;
protected String[] audioFilterArgs ;
protected String[] audioFilterArgs;

public String getFilters() {
return filters;
Expand Down Expand Up @@ -101,6 +101,14 @@ public void setVideoInputs(int videoInputs) {
this.videoInputs = videoInputs;
}

public String[] getVideoFilterArgs() {
return videoFilterArgs;
}

public void setVideoFilterArgs(String[] videoFilterArgs) {
this.videoFilterArgs = videoFilterArgs;
}

public int getAudioChannels() {
return audioChannels;
}
Expand Down Expand Up @@ -129,14 +137,6 @@ public void setAudioInputs(int audioInputs) {
this.audioInputs = audioInputs;
}

public String[] getVideoFilterArgs() {
return videoFilterArgs;
}

public void setVideoFilterArgs(String[] videoFilterArgs) {
this.videoFilterArgs = videoFilterArgs;
}

public String[] getAudioFilterArgs() {
return audioFilterArgs;
}
Expand Down

0 comments on commit 39fc586

Please sign in to comment.