2014-06-24 2 views
0

Essayer d'ouvrir web cam en utilisant ffmpeg (ffplay -f video4linux2/dev/video0 fonctionneLibav et web cam capture

pFormatCtx = NULL; 
    av_register_all(); 
    avcodec_register_all(); 
    avformat_network_init(); 


    const char  device[]  = "/dev/video0"; 
    const char  formatName[] = "video4linux"; 

if (!(pFormat = av_find_input_format(formatName))) { 
    printf("can't find input format %s\n", formatName); 
    return ; 
} 

if (avformat_open_input(&pFormatCtx, device, pFormat, NULL)!=0) { 
    printf("can't find open input file %s\n", device); 
    return ; 
} 

mais pFormat est toujours 0;

Mise à jour: Et comment se MJPEG de web cam?

Répondre

0

Vous devez appeler avdevice_register_all() au début.

pFormatCtx = NULL; 
av_register_all(); 
avdevice_register_all(); 
avcodec_register_all(); 
avformat_network_init(); 

const char  device[]  = "/dev/video0"; 
const char  formatName[] = "video4linux"; 

if (!(pFormat = av_find_input_format(formatName))) { 
    printf("can't find input format %s\n", formatName); 
    return ; 
} 

if (avformat_open_input(&pFormatCtx, device, pFormat, NULL)!=0) { 
    printf("can't find open input file %s\n", device); 
    return ; 
} 
Questions connexes