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

improve disposition properties #1925

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -990,17 +990,25 @@ public synchronized void startUnsafe(boolean findStreamInfo) throws Exception {
}

// Find the first stream with the user-specified disposition property
boolean videoStreamFound = false;
boolean audioStreamFound = false;
int nb_streams = oc.nb_streams();
for (int i = 0; i < nb_streams; i++) {
AVStream st = oc.streams(i);
AVCodecParameters par = st.codecpar();
if (videoStream < 0 && par.codec_type() == AVMEDIA_TYPE_VIDEO && st.disposition() == videoDisposition) {
videoStream = i;
videoStreamFound = true;
} else if (audioStream < 0 && par.codec_type() == AVMEDIA_TYPE_AUDIO && st.disposition() == audioDisposition) {
audioStream = i;
audioStreamFound = true;
}
}

// resets the disposition value if a stream with the specified disposition value isnt found, so the user would know
if(!videoStreamFound) setVideoDisposition(AV_DISPOSITION_DEFAULT);
if(!audioStreamFound) setAudioDisposition(AV_DISPOSITION_DEFAULT);

// Find the first video and audio stream, unless the user specified otherwise
video_st = audio_st = null;
AVCodecParameters video_par = null, audio_par = null;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/bytedeco/javacv/FrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import static org.bytedeco.ffmpeg.global.avformat.AV_DISPOSITION_DEFAULT;

/**
*
* @author Samuel Audet
Expand Down Expand Up @@ -180,7 +182,7 @@ public static enum SampleMode {
SENSOR_PATTERN_BGGR = (1L << 32) | 1;

protected int videoStream = -1, audioStream = -1;
protected int videoDisposition = 0, audioDisposition = 0;
protected int videoDisposition = AV_DISPOSITION_DEFAULT, audioDisposition = AV_DISPOSITION_DEFAULT;
protected String format = null, videoCodecName = null, audioCodecName = null;
protected int imageWidth = 0, imageHeight = 0, audioChannels = 0;
protected ImageMode imageMode = ImageMode.COLOR;
Expand Down