<>Linux下查看音视频设备
1、视频输入设备:
命令查看:ls /sys/class/video4linux/
执行结果如下:
如果系统存在video4linux文件夹说明已安装过视频驱动,video4linux目录下每个链接文件代表一个视频设备
查看video0下有哪些文件:ls /sys/class/video4linux/video0
执行结果如下:
读取name文件信息:USB 2.0 CAMERA 为video0视频设备的名称
2、音频输入设备:
命令查看音频输入设备:cat /proc/asound/cards
转载下:
https://blog.csdn.net/tang_chuanlin/article/details/86081102
<https://blog.csdn.net/tang_chuanlin/article/details/86081102>
https://www.cnblogs.com/rushoutasia/p/6409639.html
<https://www.cnblogs.com/rushoutasia/p/6409639.html>
<>ffmpeg采集音视频设备
1、采集视频设备USB 2.0 CAMERA:
linux: is->filename="/dev/video0"
windows: is->filename="video=USB 2.0 CAMERA"
补充:
通过SDL2.0渲染YUV420p:
int rtp_playinit(){ avdevice_register_all(); av_register_all(); #if
USED_NETWORK avformat_network_init(); #endif SDL_SetMainReady(); if (SDL_Init
(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) { av_log(NULL,
AV_LOG_FATAL, "Could not initialize SDL - %s\n", SDL_GetError()); #if
USED_NETWORK avformat_network_deinit(); #endif return -1; } return 0; } static
int sdl_window_init(rtpVideoState *is){ int videoWidth=is->video_ctx->width;
int videoHeight=is->video_ctx->height; int
access=SDL_TEXTUREACCESS_STREAMING;//SDL_TEXTUREACCESS_STREAMING Uint32
format=SDL_PIXELFORMAT_YV12; if(is->hwnd==NULL){ return -1; }
is->sdl_Window=SDL_CreateWindowFrom(is->hwnd); if(is->sdl_Window){
SDL_ShowWindow(is->sdl_Window); fprintf(stdout,"SDL_CreateWindow OK\n");
fflush(stdout); }else{ fprintf(stdout,"SDL_CreateWindow failed\n");
fflush(stdout); return -1; } is->sdl_Render =
SDL_CreateRenderer(is->sdl_Window,-1,0); if(is->sdl_Render==NULL){
fprintf(stdout,"SDL_CreateRenderer: failed\n"); fflush(stdout); return -1; }
is->sdl_Texture = SDL_CreateTexture(is->sdl_Render, format,
access,videoWidth,videoHeight); if(is->sdl_Texture==NULL){
fprintf(stdout,"SDL_CreateTexture: failed\n"); fflush(stdout); return -1; }
return 0; } static void sdl_window_deinit(rtpVideoState *is){
if(is->sdl_Texture){ SDL_DestroyTexture(is->sdl_Texture); is->sdl_Texture=NULL;
} if(is->sdl_Render){ SDL_DestroyRenderer(is->sdl_Render); is->sdl_Render=NULL;
} if(is->sdl_Window){ SDL_DestroyWindow(is->sdl_Window); is->sdl_Window=NULL; }
}
<>渲染部分代码:
SDL_UpdateYUVTexture(decoder->sdl_Texture, NULL, pFrameYUV->data[0],
pFrameYUV->linesize[0],pFrameYUV->data[1],
pFrameYUV->linesize[1],pFrameYUV->data[2], pFrameYUV->linesize[2]); //
SDL_UpdateTexture(decoder->sdl_Texture,
NULL,pFrameYUV->data[0],pFrameYUV->linesize[0]);
SDL_RenderClear(decoder->sdl_Render);
SDL_RenderCopy(decoder->sdl_Render,decoder->sdl_Texture, NULL,NULL);
SDL_RenderPresent(decoder->sdl_Render );
注:SDL_ShowWindow(is->sdl_Window); 缺少这一行,第二次用同句柄初始化将黑屏,画面不出来。
单做下笔记,如有不对请打脸!!!
热门工具 换一换