After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 700285 - v4l2: set pixel-aspect-ratio for capture devices only
v4l2: set pixel-aspect-ratio for capture devices only
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal enhancement
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2013-05-14 11:48 UTC by Michael Olbrich
Modified: 2013-06-04 15:38 UTC
See Also:
GNOME target: ---
GNOME version: ---

patch (1.78 KB, patch)
2013-05-14 11:48 UTC, Michael Olbrich
rejected Details | Review
improve pixel aspect ratio handling (6.47 KB, patch)
2013-06-04 06:43 UTC, Michael Olbrich
committed Details | Review

Description Michael Olbrich 2013-05-14 11:48:10 UTC
Created attachment 244159 [details] [review]

I'm not quite sure if this is correct. However without this I have been unable play video files with a different pixel-aspect-ratio on a v4l2sink.
The v4l2sink doesn't realy know what aspect ratio is used to show the frames, so I don't think we gain anything from enforcing it.
Comment 1 Sebastian Dröge (slomo) 2013-05-28 16:50:46 UTC
Is there a way to specify or get the pixel-aspect-ratio of output devices? Otherwise it should really be forced to 1/1, because you won't be able to guarantee that videos are shown with the correct aspect ratio in the end.
Comment 2 Sebastian Dröge (slomo) 2013-05-28 16:51:34 UTC
For example, is it possible to tell v4l2 that the 100x100 frames should be displayed as 200x100?
Comment 3 Michael Olbrich 2013-05-29 10:04:56 UTC
Well, there are some ioctls to define a output rectangle. However, I'm not really sure how and when they are supposed to be used, and the implementations are, as far as I can tell not really consistent.
There are newer ones, but I'm not sure if there are actually used anywhere.
Also, if you consider TV outputs, I'm not sure if assuming that the real pixel aspect ratio is 1/1 makes sense.

Anyways, I don't really have a strong opinion either way. I just want to play strange video files with a pixel aspect ration other than 1/1 on embedded hardware, where scaling the video is just not acceptable. If there is any other way to ignore it, then I'm happy with that too.
Comment 4 Sebastian Dröge (slomo) 2013-05-29 10:12:46 UTC
How do you make sure that the output uses the correct pixel-aspect-ratio in your case, i.e. scales stuff accordingly?

I agree that something needs to be done here, just fixing it to 1/1 is not ideal. Just not sure what V4L2 offers us to properly implement that here...
Comment 5 Nicolas Dufresne (ndufresne) 2013-05-29 13:48:12 UTC
According to VLC people, this information if part of VIDIOC_CROPCAP. I have not looked in depth, so this is left as an excersize, see
Comment 6 Michael Olbrich 2013-05-31 09:25:27 UTC
I missed that one. That seems to be the way to go. Maybe In combination with pixel-aspect-ratio/force-aspect-ratio like xvimagesink?
That way the application can overwrite it in case the driver does not provide it.
Comment 7 Sebastian Dröge (slomo) 2013-06-01 06:53:46 UTC
Yes, sounds like the way to go :)

Is there something similar for capture devices too or are they always outputting 1/1 pixel-aspect-ratio?
Comment 8 Michael Olbrich 2013-06-04 06:43:33 UTC
Created attachment 245980 [details] [review]
improve pixel aspect ratio handling

How about this patch?

Is g_param_spec_string correct for a fraction? All elements that have a 
pixel-aspect-ratio property use it.

VIDIOC_CROPCAP is for both capture and output devices. From the documentation of the ioctl: "This ioctl must be implemented for video capture or output devices that support cropping and/or scaling and/or have non-square pixels, and for overlay devices."
Comment 9 Sebastian Dröge (slomo) 2013-06-04 15:38:26 UTC
commit 74d217c44be6007d83a3e270300f0708b5fe895c
Author: Michael Olbrich <>
Date:   Tue Jun 4 08:26:33 2013 +0200

    v4l2: improve pixel aspect ratio handling
    Instead of just assuming a aspect ratio of 1/1 use VIDIOC_CROPCAP to ask
    the device.
    This also add a pixel-aspect-ratio property to overwrite the value from the
    driver and a force-aspect-ratio property to ignore it.