- image_format = NULL;
-}
-
-/* prepare dummy protocols for grab */
-static void prepare_grab(void)
-{
- int has_video, has_audio, i, j;
- AVFormatContext *oc;
- AVFormatContext *ic;
- AVFormatParameters vp1, *vp = &vp1;
- AVFormatParameters ap1, *ap = &ap1;
-
- /* see if audio/video inputs are needed */
- has_video = 0;
- has_audio = 0;
- memset(ap, 0, sizeof(*ap));
- memset(vp, 0, sizeof(*vp));
- vp->time_base.num= 1;
- for(j=0;j<nb_output_files;j++) {
- oc = output_files[j];
- for(i=0;i<oc->nb_streams;i++) {
- AVCodecContext *enc = oc->streams[i]->codec;
- switch(enc->codec_type) {
- case CODEC_TYPE_AUDIO:
- if (enc->sample_rate > ap->sample_rate)
- ap->sample_rate = enc->sample_rate;
- if (enc->channels > ap->channels)
- ap->channels = enc->channels;
- has_audio = 1;
- break;
- case CODEC_TYPE_VIDEO:
- if (enc->width > vp->width)
- vp->width = enc->width;
- if (enc->height > vp->height)
- vp->height = enc->height;
-
- if (vp->time_base.num*(int64_t)enc->time_base.den > enc->time_base.num*(int64_t)vp->time_base.den){
- vp->time_base = enc->time_base;
- vp->width += frame_leftBand + frame_rightBand;
- vp->width -= (frame_padleft + frame_padright);
- vp->height += frame_topBand + frame_bottomBand;
- vp->height -= (frame_padtop + frame_padbottom);
- }
- has_video = 1;
- break;
- default:
- av_abort();
- }
- }
- }
-
- if (has_video == 0 && has_audio == 0) {
- fprintf(stderr, "Output file must have at least one audio or video stream\n");
- exit(1);
- }
-
- if (has_video) {
- AVInputFormat *fmt1;
- fmt1 = av_find_input_format(video_grab_format);
- vp->device = video_device;
- vp->channel = video_channel;
- vp->standard = video_standard;
- vp->pix_fmt = frame_pix_fmt;
- if (av_open_input_file(&ic, "", fmt1, 0, vp) < 0) {
- fprintf(stderr, "Could not find video grab device\n");
- exit(1);
- }
- /* If not enough info to get the stream parameters, we decode the
- first frames to get it. */
- if ((ic->ctx_flags & AVFMTCTX_NOHEADER) && av_find_stream_info(ic) < 0) {
- fprintf(stderr, "Could not find video grab parameters\n");
- exit(1);
- }
- /* by now video grab has one stream */
- ic->streams[0]->r_frame_rate.num = vp->time_base.den;
- ic->streams[0]->r_frame_rate.den = vp->time_base.num;
- input_files[nb_input_files] = ic;
-
- if (verbose >= 0)
- dump_format(ic, nb_input_files, "", 0);
-
- nb_input_files++;
- }
- if (has_audio && audio_grab_format) {
- AVInputFormat *fmt1;
- fmt1 = av_find_input_format(audio_grab_format);
- ap->device = audio_device;
- if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) {
- fprintf(stderr, "Could not find audio grab device\n");
- exit(1);
- }
- input_files[nb_input_files] = ic;
-
- if (verbose >= 0)
- dump_format(ic, nb_input_files, "", 0);
-
- nb_input_files++;
- }