[Libav-user] Set Webcam Encoder C API

Casey Price cprice1317 at gmail.com
Wed Oct 21 19:44:19 CEST 2015


I'm trying to capture a webcam stream using the FFMPEG C API in windows. I
can do what I want using the following command line options:

    "ffmpeg -f dshow -vcodec mjpeg -s 1280x720 -framerate 30 -i
video=HX-A1:audio="Microphone (HX-A1)" outputFile.mpg"


I've started out with the transcoding.c example and got it working for
recording another dshow device like screen-capture-recorder. However, I
need to set the encoder options for my real webcam as done above in the
command line because it defaults to 160x120 and raw video. I've tried using
an AVDictionary when I open the input format context but it does not appear
to be doing anything.

    AVDictionary *opt = NULL;
av_dict_set(&opt, "vcodec", "mjpeg", 0);
av_dict_set(&opt, "s", "1280x720", 0);
        av_dict_set(&opt , "framerate", "30", 0);
if ((ret = avformat_open_input(&ifmt_ctx, filename, inputFormat, &opt)) <
0) {
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
return ret;
}

How should I be telling the camera what codec to use as done in my command
line example?


Casey Price
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20151021/8d45885d/attachment.html>


More information about the Libav-user mailing list