From: Hans Verkuil <hverkuil@xs4all.nl>
To: Ran Shalit <ranshalit@gmail.com>, linux-media@vger.kernel.org
Subject: Re: Using v4l2 API example as-is for video capture
Date: Mon, 11 Jan 2016 12:29:56 +0100 [thread overview]
Message-ID: <56939234.3050305@xs4all.nl> (raw)
In-Reply-To: <CAJ2oMhKLbDc1xBQgyz0Ga9K6PQ7M8OGTn7_dNywFs=3XrNrP6A@mail.gmail.com>
On 01/08/2016 07:25 AM, Ran Shalit wrote:
> Hello,
>
> I am trying to use v4l2 example from API documentation:
> inhttp://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html .
> As a start, I wanted to first try uding it with vivid (virtual device driver).
> I found excelent vivid documentation in the kernel, which is very helpful:
> https://www.kernel.org/doc/Documentation/video4linux/vivid.txt
>
> But on trying to use the example as-is for capturing video frames into
> file, and playing the file, I encounter difficulties.
> I tried the example as-is, and then tried several resolution,
> pixelformat, different inputs, but it always result with video with a
> sync problems ( the test bars of the video are keep moving in the
> horizontal axis, or the text is changing its location for one frame to
> the next).
>
> I compiled the v4l2 API example AS-IS from:
> http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html with
> minor modification in the --force part of the example (I also tried
> the example as is without modifications but it did not help), so that
> I choose hd input , and 1920x1080 resolution, V4L2_PIX_FMT_YUV420
> (also tried V4L2_PIX_FMT_YUV422P) , progressive.
>
> if (force_format) {
> input = 3; // <<-- HD input device
> if (-1==xioctl(fd,VIDIOC_S_INPUT,&input))
> {
> errno_exit("VIDIOC_S_INPUT");
> }
> fmt.fmt.pix.width = 1920;
> fmt.fmt.pix.height = 1080;
> fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; // <<-
> tried also V4L2_PIX_FMT_YUV422P
> fmt.fmt.pix.field = V4L2_FIELD_NONE; // <- trying to
> capture progressive
>
> if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt))
> errno_exit("VIDIOC_S_FMT");
>
> } else {
>
> I run the application with (the compiled code using pixelformat =
> V4L2_PIX_FMT_YUV420 trial ):
>
> ./v4l2_example -f -o -c 10 > cap_yuv420p.yuv
I'm not sure what you're doing, but this just works for me (I use yuv420p to
play this back).
Note: you can find the same code in v4l-utils in contrib/test. That's the code
I used (with you modifications).
Regards,
Hans
next prev parent reply other threads:[~2016-01-11 11:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 6:25 Using v4l2 API example as-is for video capture Ran Shalit
2016-01-08 14:03 ` Ran Shalit
2016-01-11 11:29 ` Hans Verkuil [this message]
2016-01-11 11:56 ` Ran Shalit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56939234.3050305@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=ranshalit@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox