ffmpeg调dshow使用Kinect录视频音画不同步关于时间戳踩的坑

建立数据集收数据准备用Microsoft Kinect V2采集color视频,节省预算所以没有直接买一个好用的usb camera,从此开始被这个老古董折磨

注意一定要安装kinect runtime2.2,这个是单独安装的,Kinect SDK2.0装完虽然能用但是不好用,pykinect可能报错

然后不想弄了,直接上ffmpeg命令行

ffmpeg -rtbufsize 2000M -f dshow -video_size 1920x1080 -framerate 30 -sample_rate 96000 -sample_size 16 -channel_layout stereo -audio_buffer_size 50 -use_video_device_timestamps false -i video="Kinect V2 Video Sensor":audio="麦克风阵列 (2- Xbox NUI Sensor)" -c:v hevc_nvenc -preset p7  -profile:v main10 -level 4.1 -tier main -b:v 8000k -pix_fmt p010le -c:a flac -ar 96000 -ac 2 -sample_fmt s16 rawvideo.mkv

只有装了runtime2.2后才能看到dshow设备Kinect V2 Video Sensor

特性:

超大缓冲区

96khz音频flac

英伟达HEVC硬件编码 ,预设p7最佳质量,main10编码,层级level4.1@main,8M码率,10位色深YUV420采样

为什么要用HEVC_NVENC?因为想折腾一下不让显卡歇着,代价是支持的格式更少了,我心心念念的YUV422p10le得用libx265

原本想用YUV444p16le但是windows默认不支持,搞太先进了数据集怕没人会用

踩坑:

1,FFMPEG各个参数的修饰关系一定要清楚,针对输入的参数要放在-i前面,在指定

int _tmain(int argc, _TCHAR* argv[]) { currentAudioClock = 0; currentVideoClock = 0; currentBufferClock = 0; //currentPlayClock=0; CurrentVolume = SDL_MIX_MAXVOLUME; if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); return 1; } SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); SDL_EventState(SDL_USEREVENT, SDL_IGNORE); atexit(SDL_Quit);// 注册SDL_Quit,当退出时用,使得退出时程序自动清理 //flag=2; //给音视频队列分配空间 videoQueue = (VideoQueue *)av_mallocz(sizeof(VideoQueue)); audioQueue = (AudioQueue *)av_mallocz(sizeof(AudioQueue)); //初始化音视频队列 VideoQueueInit(videoQueue); AudioQueueInit(audioQueue); char* url = "G:/上海滩.mp4"; //char* url = "G:/2014年5月26日17 12 00至2014年5月26日17 14 59.avi"; //char* url = "H:/视频/不当交易.The.Unjust.BD.MiniSD-TLF.mkv"; //char* url = "E:/BaiduMusic/Songs/Love Story - Taylor Swift.mp3"; decodeTid = SDL_CreateThread(DecodePacket, "DecodePacket", (void*)url); PlayVideoTid = SDL_CreateThread(PlayVideo, "PlayVideo", NULL); PlayAudioTid = SDL_CreateThread(PlayAudio, "PlayAudioTid", NULL); int tid; SDL_WaitThread(decodeTid, &tid); printf("decodeTid %d\n", tid); SDL_WaitThread(PlayVideoTid, &tid); printf("PlayVideoTid %d\n", tid); SDL_WaitThread(PlayAudioTid, &tid); printf("PlayAudioTid %d\n", tid); SDL_DestroyMutex(audioQueue->audioMutex); SDL_DestroyCond(audioQueue->audioCond); SDL_DestroyMutex(videoQueue->videoMutex); SDL_DestroyCond(videoQueue->videoCond); av_free(videoQueue); av_free(audioQueue); return 0; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值