* media: videobuf2: Fails to scale H264 1080p video on 1920x1080 screen
@ 2021-08-20 8:55 trung1.dothanh
2021-08-20 14:36 ` Nicolas Dufresne
0 siblings, 1 reply; 3+ messages in thread
From: trung1.dothanh @ 2021-08-20 8:55 UTC (permalink / raw)
To: linux-media
Hello,
I am trying to play video with Gstreamer on a fullHD monitor. The board I’m using is Apalis iMX6.
Playing video works great with v4l2h264dec:
gst-launch-1.0 filesrc location=1080.mkv ! matroskademux ! h264parse \
! v4l2h264dec capture-io-mode=dmabuf \
! kmssink
However, it fails to scale video to 720p with v4l2convert:
gst-launch-1.0 filesrc location=1080.mkv ! matroskademux ! h264parse \
! v4l2h264dec capture-io-mode=dmabuf \
! v4l2convert output-io-mode=dmabuf-import \
! video/x-raw,width=1280,height=720 \
! kmssink
Added some debugs and I found that it failed at 'drivers/media/common/videobuf2/videobuf2-v4l2.c:__verify_length()'.
length = (b->memory == VB2_MEMORY_USERPTR)
? b->length : vb->planes[0].length;
if (b->bytesused > length)
return -EINVAL;
The “b->byteused” is 4177920 (= 2 x 1920 x 1088), while plane length is just 4147200 (= 2 x 1920 x 1080).
The actual frame size of H264 video is 1920x1088, so I added a bypass for this case and video can be scaled,
but that may not a correct way to fix this problem.
Is this a bug or I need to do extra steps before scale video?
Packages version in my environment are:
* Kernel: 5.10.19
* Gstreamer: 1.18.4
Thank you,
Trung
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: media: videobuf2: Fails to scale H264 1080p video on 1920x1080 screen
2021-08-20 8:55 media: videobuf2: Fails to scale H264 1080p video on 1920x1080 screen trung1.dothanh
@ 2021-08-20 14:36 ` Nicolas Dufresne
2021-08-23 1:29 ` trung1.dothanh
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Dufresne @ 2021-08-20 14:36 UTC (permalink / raw)
To: trung1.dothanh, linux-media
Le vendredi 20 août 2021 à 08:55 +0000, trung1.dothanh@toshiba.co.jp a écrit :
> Hello,
>
> I am trying to play video with Gstreamer on a fullHD monitor. The board I’m using is Apalis iMX6.
> Playing video works great with v4l2h264dec:
>
> gst-launch-1.0 filesrc location=1080.mkv ! matroskademux ! h264parse \
> ! v4l2h264dec capture-io-mode=dmabuf \
> ! kmssink
>
> However, it fails to scale video to 720p with v4l2convert:
>
> gst-launch-1.0 filesrc location=1080.mkv ! matroskademux ! h264parse \
> ! v4l2h264dec capture-io-mode=dmabuf \
> ! v4l2convert output-io-mode=dmabuf-import \
> ! video/x-raw,width=1280,height=720 \
> ! kmssink
>
> Added some debugs and I found that it failed at 'drivers/media/common/videobuf2/videobuf2-v4l2.c:__verify_length()'.
>
> length = (b->memory == VB2_MEMORY_USERPTR)
Wrong snippet ? You are using VB2_MEMORY_DMABUF according to your GStreamer
pipeline.
> ? b->length : vb->planes[0].length;
> if (b->bytesused > length)
> return -EINVAL;
>
> The “b->byteused” is 4177920 (= 2 x 1920 x 1088), while plane length is just 4147200 (= 2 x 1920 x 1080).
> The actual frame size of H264 video is 1920x1088, so I added a bypass for this case and video can be scaled,
> but that may not a correct way to fix this problem.
>
> Is this a bug or I need to do extra steps before scale video?
I'm not fully certain of what has gone wrong, since this call was added
(1.18.0), this code path is supposed to work:
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/sys/v4l2/gstv4l2transform.c#L905
GStreamer will update the driver FMT to padded width/height before calling
streamon and S_SELECTION is used to tell the scaler which part is to be used in
the scaling process.
>
> Packages version in my environment are:
> * Kernel: 5.10.19
> * Gstreamer: 1.18.4
>
> Thank you,
> Trung
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: media: videobuf2: Fails to scale H264 1080p video on 1920x1080 screen
2021-08-20 14:36 ` Nicolas Dufresne
@ 2021-08-23 1:29 ` trung1.dothanh
0 siblings, 0 replies; 3+ messages in thread
From: trung1.dothanh @ 2021-08-23 1:29 UTC (permalink / raw)
To: nicolas, linux-media
Thank you for your reply. Sorry for not make it clear.
> length = (b->memory == VB2_MEMORY_USERPTR)
> ? b->length : vb->planes[0].length;
> Wrong snippet ? You are using VB2_MEMORY_DMABUF according to your GStreamer pipeline.
That's right. "b->memory" is VB2_MEMORY_DMABUF, then "length" is " vb->planes[0].length",
which has value 4147200 (= 2 x 1920 x 1080).
My issue is the decoded frame of H264 video is 1920x1088, while plane is only 1920x1080,
and that makes __verify_length return '-EINVAL'.
I am wondering if this function should have a special check for the case like this:
fullHD H264 frame (1920x1088) with fullHD screen (1920x1080).
> I'm not fully certain of what has gone wrong, since this call was added (1.18.0), this code path is supposed to work:
> https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/sys/v4l2/gstv4l2transform.c#L905
> GStreamer will update the driver FMT to padded width/height before calling streamon and S_SELECTION is used to tell the scaler which part is to be used in the scaling process.
Thank you. I will check this code to see what I'm missing.
Thanks,
Trung
-----Original Message-----
From: Nicolas Dufresne [mailto:nicolas@ndufresne.ca]
Sent: Friday, August 20, 2021 9:36 PM
To: do thanh trung(TSDV Eng 1) <trung1.dothanh@toshiba.co.jp>; linux-media@vger.kernel.org
Subject: Re: media: videobuf2: Fails to scale H264 1080p video on 1920x1080 screen
Le vendredi 20 août 2021 à 08:55 +0000, trung1.dothanh@toshiba.co.jp a écrit :
> Hello,
>
> I am trying to play video with Gstreamer on a fullHD monitor. The board I’m using is Apalis iMX6.
> Playing video works great with v4l2h264dec:
>
> gst-launch-1.0 filesrc location=1080.mkv ! matroskademux ! h264parse \
> ! v4l2h264dec capture-io-mode=dmabuf \
> ! kmssink
>
> However, it fails to scale video to 720p with v4l2convert:
>
> gst-launch-1.0 filesrc location=1080.mkv ! matroskademux ! h264parse \
> ! v4l2h264dec capture-io-mode=dmabuf \
> ! v4l2convert output-io-mode=dmabuf-import \
> ! video/x-raw,width=1280,height=720 \
> ! kmssink
>
> Added some debugs and I found that it failed at 'drivers/media/common/videobuf2/videobuf2-v4l2.c:__verify_length()'.
>
> length = (b->memory == VB2_MEMORY_USERPTR)
Wrong snippet ? You are using VB2_MEMORY_DMABUF according to your GStreamer pipeline.
> ? b->length : vb->planes[0].length;
> if (b->bytesused > length)
> return -EINVAL;
>
> The “b->byteused” is 4177920 (= 2 x 1920 x 1088), while plane length is just w
> The actual frame size of H264 video is 1920x1088, so I added a bypass
> for this case and video can be scaled, but that may not a correct way to fix this problem.
>
> Is this a bug or I need to do extra steps before scale video?
I'm not fully certain of what has gone wrong, since this call was added (1.18.0), this code path is supposed to work:
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/sys/v4l2/gstv4l2transform.c#L905
GStreamer will update the driver FMT to padded width/height before calling streamon and S_SELECTION is used to tell the scaler which part is to be used in the scaling process.
>
> Packages version in my environment are:
> * Kernel: 5.10.19
> * Gstreamer: 1.18.4
>
> Thank you,
> Trung
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-23 1:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 8:55 media: videobuf2: Fails to scale H264 1080p video on 1920x1080 screen trung1.dothanh
2021-08-20 14:36 ` Nicolas Dufresne
2021-08-23 1:29 ` trung1.dothanh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.