Revision 5d3d238f

View differences:

libavdevice/v4l2.c
442 442
    struct video_data *s = s1->priv_data;
443 443
    struct v4l2_input input;
444 444
    struct v4l2_standard standard;
445
    struct v4l2_streamparm streamparm = { 0 };
446
    struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
445 447
    int i;
446 448

  
449
    streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
450

  
447 451
    if (ap->channel>=0) {
448 452
        /* set tv video input */
449 453
        memset (&input, 0, sizeof (input));
......
490 494
    }
491 495

  
492 496
    if (ap->time_base.num && ap->time_base.den) {
493
        struct v4l2_streamparm streamparm = { 0 };
494
        struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
495

  
496 497
        av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n",
497 498
               ap->time_base.num, ap->time_base.den);
498
        streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
499 499
        tpf->numerator = ap->time_base.num;
500 500
        tpf->denominator = ap->time_base.den;
501 501
        if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) {
......
511 511
                   "The driver changed the time per frame from %d/%d to %d/%d\n",
512 512
                   ap->time_base.num, ap->time_base.den,
513 513
                   tpf->numerator, tpf->denominator);
514
            ap->time_base.num = tpf->numerator;
515
            ap->time_base.den = tpf->denominator;
516 514
        }
517 515
    } else {
518
        /* if timebase value is not set in ap, read the timebase value
519
         * from the driver and set it in ap */
520
        struct v4l2_streamparm streamparm = { 0 };
521
        struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
522

  
523
        streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
516
        /* if timebase value is not set in ap, read the timebase value from the driver */
524 517
        if (ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) {
525 518
            av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno));
526 519
            return AVERROR(errno);
527 520
        }
528
        ap->time_base.num = tpf->numerator;
529
        ap->time_base.den = tpf->denominator;
530 521
    }
522
    ap->time_base.num = tpf->numerator;
523
    ap->time_base.den = tpf->denominator;
531 524

  
532 525
    return 0;
533 526
}

Also available in: Unified diff