3D视频中,有的是上下格式的,但是无论是裸眼3D还是3D眼镜都需要左右格式的,下面就是转换的算法,利用ffmpeg解码,进行YUV切割,实现左右视频交织,可以在裸眼3D手机或者pad上观看3D效果。必须要先熟悉YUV数据格式。
FILE *yuvFile = fopen("yuv_file_width.yuv","ab");
if(!yuvFile)
return 0;
av_register_all();
AVFormatContext *pFormat = NULL;
if (avformat_open_input(&pFormat ,SRC_FILE,NULL,NULL) < 0)
{
return 0;
}
AVCodecContext * video_dec_ctx = NULL;
AVCodec *video_dec = NULL;
if (avformat_find_stream_info(pFormat,NULL) < 0)
{
return 0;
}
av_dump_format(pFormat,0,SRC_FILE,0);
int index = -1,i = 0;
for (i=0;i<pFormat->nb_streams;i++)
{
if (pFormat->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
{
index = i;
break;
}
}
if (-1 == index)
{
printf("can't find t