ffmpeg编码器支持情况

ffmpeg 音视频编码器需要查看支持才能用否则打不开编码器。

下面代码将展示查看ffmpeg中音频支持声道,采样率,样本情况;视频支持输入yuv格式情况,具体看下面代码。

int audio_support(AVCodec * pCodec,int *channel,int * playout,int *samplePerSec,AVSampleFormat_t * sample_fmt)
{
	//支持的声道
	if(NULL != pCodec->channel_layouts)
	{
		uint64_t layout = av_get_default_channel_layout(*channel);
		if(0 == layout)
		{
			return 0;
		}

		int i = 0;	
		int j = 0;
		while(0 != pCodec->channel_layouts[j])
		{
			printf("pCodec->channel_layouts[j] : %d\n",pCodec->channel_layouts[j]);
			++j;
		}
		while(0 != pCodec->channel_layouts[i])
		{
			if(layout == pCodec->channel_layouts[i])
			{
				break;
			}
			++i;
		}
		//未找到
		if(0 == pCodec->channel_layouts[i])
		{
			*playout = pCodec->channel_layouts[i-1];
			*channel = av_get_channel_layout_nb_channels(*playout);
		}
	}

	//支持的采样率
	if(NULL != pCodec->supported_samplerates)
	{
		int i = 0;
		int j = 0;
		while(0 != pCodec->supported_samplerates[j])
		{
			printf("pCodec->supported_samplerates[j] : %d\n",pCodec->supported_samplerates[j]);
			++j;
		}
		while(0 != pCodec->supported_samplerates[i])
		{
			if(*samplePerSec == pCodec->supported_samplerates[i])
			{
				break;
			}
			++i;
		}
		//未找到
		if(0 == pCodec->supported_samplerates[i])
		{
			*samplePerSec = pCodec->supported_samplerates[i-1];
		}
	}

	//支持的样本
	if(NULL != pCodec->sample_fmts)
	{
		int i = 0;
		int j = 0;
		while(-1 != pCodec->sample_fmts[j])
		{
			printf("pCodec->sample_fmts[j] : %d\n",pCodec->sample_fmts[j]);
			++j;
		}
		while(-1 != pCodec->sample_fmts[i])
		{
			if(*sample_fmt == pCodec->sample_fmts[i])
			{
				break;
			}
			++i;
		}
		//未找到
		if(-1 == pCodec->sample_fmts[i])
		{
			*sample_fmt = (AVSampleFormat_t)pCodec->sample_fmts[i-1];
		}
	}

	return 1;
}

int video_support(AVCodec * pCodec,AVPixelFormat * video_pixelfromat)
{
	//支持的yuv格式
	if(NULL != pCodec->pix_fmts)
	{
		int i = 0;
		int j = 0;
		while(0 != pCodec->pix_fmts[j])
		{
			printf("pCodec->pix_fmts[j] : %d\n",pCodec->pix_fmts[j]);
			++j;
		}
		while(0 != pCodec->pix_fmts[i])
		{
			if(*video_pixelfromat == pCodec->pix_fmts[i])
			{
				break;
			}
			++i;
		}
		//未找到
		if(-1 == pCodec->pix_fmts[i])
		{
			*video_pixelfromat = pCodec->pix_fmts[i-1];
		}
	}
	return 1;
}
输入支持情况如图:


上面是音频编码器支持的采样率,样本,以及视频支持的输入yuv格式。

交流请加QQ群:62054820
QQ:379969650



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>