title: FFMPEG Set Webcam Encoder C++
body: <p>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: </p>
  
  <pre><code>ffmpeg -f dshow -vcodec mjpeg -s 1280x720 -framerate 30 -i video=HX-A1:audio="Microphone (HX-A1)" outputFile.mpg
  </code></pre>
  
  <p>I've started out with the transcoding.c example and got it working for recording a virtual webcam like screen-capture-recorder. However, I need to set the encoder options for my real webcam because it defaults to 160x120 raw video, and I'd prefer a higher resolution. I'm trying the following to set the camera encoder options but it doesn't appear to be doing anything. </p>
  
  <pre><code>AVDictionary *opt = NULL;
  av_dict_set(&amp;opt, "vcodec", "mjpeg", 0);
  av_dict_set(&amp;opt, "s", "1280x720", 0);
  av_dict_set(&amp;opt, "framerate", "30", 0);
  if ((ret = avformat_open_input(&amp;ifmt_ctx, filename, inputFormat, &amp;opt)) &lt; 0) {
      av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
      return ret;
  }
  </code></pre>
  
  <p>Is there another way to set input options to tell the camera what codec to use as done in my command line example? </p>