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 740360 - vaapiencode_h264 does not keep SAR information
vaapiencode_h264 does not keep SAR information
Status: RESOLVED FIXED
Product: gstreamer-vaapi
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gstreamer-vaapi maintainer(s)
gstreamer-vaapi maintainer(s)
Depends on:
Blocks: 731852
 
 
Reported: 2014-11-19 12:30 UTC by tdlmarek
Modified: 2014-11-27 09:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
encoder: h264: fix pixel-aspect-ratio in encoded stream (1.65 KB, patch)
2014-11-26 14:21 UTC, Gwenole Beauchesne
none Details | Review

Description tdlmarek 2014-11-19 12:30:45 UTC
Hello.

I am trying to encode an mpeg2 http stream (captured from DVB-T) into h264 to reduce required bandwidth. When using software x264enc, everything works as expected. Once I switch to vaapiencode_h264, SAR information is lost and the picture gets deformed.

This is the very basic gstreamer pipeline I am using with VA-API:
gst-launch-1.0 -v souphttpsrc location=http://10.0.180.147:3000/T-8395-273-260 \
! tsdemux \
! queue \
! mpegvideoparse \
! mpeg2dec \
! videoconvert \
! avdeinterlace \
! vaapiencode_h264 \
! vaapiparse_h264 config-interval=1 \
! mpegtsmux \
! tcpserversink host=10.0.0.26 port=5000

VLC (that I am using to capture the output) debug shows this:
main debug: original format sz 720x576, of (0,0), vsz 720x576, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x


When I use exactly the same pipeline but the 264 encoder (I even keep the vaapiparse_h264):
gst-launch-1.0 -v souphttpsrc location=http://10.0.180.147:3000/T-8395-273-260 \
! tsdemux \
! queue \
! mpegvideoparse \
! mpeg2dec \
! videoconvert \
! avdeinterlace \
! x264enc \
! vaapiparse_h264 config-interval=1 \
! mpegtsmux \
! tcpserversink host=10.0.0.26 port=5001

VLC debug shows this:
main debug: original format sz 720x576, of (0,0), vsz 720x576, 4cc I420, sar 64:45, msk r0x0 g0x0 b0x0


The latter is correct, DVB-T is actually broadcasted as 720x576 stretched to 64:45. vaapiencode_h264 does not seem to retain this information.

This behavior is the same for gstreamer1-vaapi package from debian/jessie repositories, gstreamer-vaapi-0.5.9.tar.bz2 compiled from sources and also the latest git master branch of vaapi / gstreamer-vaapi.
Comment 1 Gwenole Beauchesne 2014-11-26 14:21:16 UTC
Created attachment 291549 [details] [review]
encoder: h264: fix pixel-aspect-ratio in encoded stream

Could you please try the attached patch? This should now really emit aspect ratio information. Thanks.
Comment 2 sreerenj 2014-11-27 09:11:47 UTC
Tested with the sample file http://samples.mplayerhq.hu/MPEG2/dothack2.mpg and the patch LGTM. Will push it.
Comment 3 tdlmarek 2014-11-27 09:29:44 UTC
Hello Gwenole.

I can also confirm that the patch seems to do the trick. The SAR information is now preserved and the video displays correctly, tested on a live DVB-T stream.

Thank you for the swift fix.

Marek
Comment 4 sreerenj 2014-11-27 09:34:41 UTC
Thanks for testing!

commit 88b481e5306177f4cde2d9787beda89735c06a20
Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date:   Thu Nov 27 11:13:20 2014 +0200

    encoder: h264: fix pixel-aspect-ratio in encoded stream.
    
    Really report sample aspect ratio (SAR) as present, and make it match
    what we have obtained from the user as pixel-aspect-ratio (PAR). i.e.
    really make sure VUI parameter aspect_ratio_info_present_flag is set
    to TRUE and that the indication from aspect_ratio_idc is Extended_SAR.
    
    This is a leftover from git commit a12662f.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740360