Java Code Examples for org.bytedeco.javacpp.avformat.AVFormatContext#nb_streams()

The following examples show how to use org.bytedeco.javacpp.avformat.AVFormatContext#nb_streams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: testRecorder.java    From easyCV with Apache License 2.0 6 votes vote down vote up
/**
 * 从输入音视频流获取音视频格式
 * 
 * @param avfc
 */
private void getInputParam(AVFormatContext avfc) {
	// get input video and audio stream indices from ifmt_ctx
	for (int idx = 0; idx < avfc.nb_streams(); idx++) {
		System.err.println("读取流参数:"+idx);
		AVStream stream = avfc.streams(idx);
		AVCodecParameters codecpar = stream.codecpar();
		if (codecpar.codec_type() == AVMEDIA_TYPE_VIDEO) {
			AVRational frame_rate = stream.r_frame_rate();
			if (frame_rate.num() != AV_NOPTS_VALUE && frame_rate.den() != 0) {
				this.frameRate = (frame_rate.num()) / (frame_rate.den());
			}
			this.videoindex=idx;
			this.in_videoCodecpar = codecpar;
			this.in_videoStream = stream;
		} else if (codecpar.codec_type() == AVMEDIA_TYPE_AUDIO) {
			this.in_audioCodecpar = codecpar;
			this.in_audioStream = stream;
			this.audioindex=idx;
		}
	}
}
 
Example 2
Source File: GrabberTmplate.java    From easyCV with Apache License 2.0 5 votes vote down vote up
/**
 * 获取第一帧视频位置
 * @param pFormatCtx
 * @return
 */
protected int findVideoStreamIndex(AVFormatContext pFormatCtx) {
	int i = 0, videoStream = -1;
	for (i = 0; i < pFormatCtx.nb_streams(); i++) {
		AVStream stream=pFormatCtx.streams(i);
		AVCodecContext codec=stream.codec();
		if (codec.codec_type() == AVMEDIA_TYPE_VIDEO) {
			videoStream = i;
			break;
		}
	}
	return videoStream;
}
 
Example 3
Source File: FFmpegRecorder.java    From easyCV with Apache License 2.0 5 votes vote down vote up
/**
 * 获取第一帧视频位置
 * @param pFormatCtx
 * @return
 */
protected int findVideoStreamIndex(AVFormatContext pFormatCtx) {
	int i = 0;
	for (i = 0; i < pFormatCtx.nb_streams(); i++) {
		AVStream stream=pFormatCtx.streams(i);
		AVCodecContext codec=stream.codec();
		if (codec.codec_type() == AVMEDIA_TYPE_VIDEO) {
			return i;
		}
	}
	return -1;
}
 
Example 4
Source File: TestPusher.java    From easyCV with Apache License 2.0 5 votes vote down vote up
/**
 * 获取第一帧视频位置
 * 
 * @param pFormatCtx
 * @return
 */
protected int findVideoStreamIndex(AVFormatContext pFormatCtx) {
	int i = 0, videoStream = -1;
	for (i = 0; i < pFormatCtx.nb_streams(); i++) {
		AVStream stream = pFormatCtx.streams(i);
		AVCodecContext codec = stream.codec();
		if (codec.codec_type() == AVMEDIA_TYPE_VIDEO) {
			videoStream = i;
			break;
		}
	}
	return videoStream;
}
 
Example 5
Source File: GrabberTemplate4.java    From easyCV with Apache License 2.0 5 votes vote down vote up
/**
 * 查找视频通道
 * @param pFormatCtx
 * @return
 */
protected int findVideoStreamIndex(AVFormatContext formatCtx) {
	int size=formatCtx.nb_streams();
	for (int i = 0; i < size; i++) {
		AVStream stream=formatCtx.streams(i);
		AVCodecParameters codec=stream.codecpar();
		int type=codec.codec_type();
		if (type == AVMEDIA_TYPE_VIDEO) {
			return i;
		}
	}
	return -1;
}
 
Example 6
Source File: GrabberTemplate4.java    From easyCV with Apache License 2.0 5 votes vote down vote up
/**
 * 查找音频通道
 * @param pFormatCtx
 * @return
 */
protected int findAudioStreamIndex(AVFormatContext formatCtx) {
	int size=formatCtx.nb_streams();
	for (int i = 0; i < size; i++) {
		AVStream stream=formatCtx.streams(i);
		AVCodecParameters codec=stream.codecpar();
		int type=codec.codec_type();
		if (type == AVMEDIA_TYPE_AUDIO) {
			return i;
		}
	}
	return -1;
}