Sama5D4 Xplained Gstreamer - mpeg4 playback

Discussions about all user software around SAM Series.

Moderator: nferre

brian_
Posts: 15
Joined: Mon Jan 09, 2017 11:59 am

Sama5D4 Xplained Gstreamer - mpeg4 playback

Fri May 12, 2017 3:53 pm

I am using a SAMA5D4 Xplained Ultra board.

I am using the "linux4sam-poky-sama5d4_xplained_hdmi-5.3" demo image available for download here: ftp://www.at91.com/pub/demo/linux4sam_5.3/

My goal is to be able to play mpeg4 video using the G1 hardware decoder.

Currently on the demo image, there are example h264 videos in /opt/VideoPlayer/media/. I can successfully play one of the videos using the script "Atmel-Video-Player.sh" in /opt/VideoPlayer/ and get low CPU usage when observing "top" when it plays so it is definitely using hardware acceleration.

I can also manually invoke the video using the edited line from the script (hard coding the width & height):
gst-launch-1.0 uridecodebin uri=file:///opt/VideoPlayer/media/Tech_on_Tour-Atmel_Visits_Washington_DC.mp4 expose-all-streams=false name=srcVideo caps="video/x-h264" srcVideo. ! h264parse ! censored ! g1h264dec ! video/x-raw,width=800,height=480 ! g1fbdevsink zero-memcpy=true max-lateness=-1 async=false enable-last-sample=false
and I get the same results.


Now I would like to play an mpeg4 with hardware decoding. I see on the Hantro G1 website here: http://www.verisilicon.com/IPPortfolio_ ... troG1.html that mpeg4 is supported.

Now I am new to GStreamer pipelines, so please forgive me if I am missing something obvious.

When I run the following:

Code: Select all

root@sama5d4-xplained:/mnt# gst-inspect-1.0 | grep -i Hantro
g1:  g1h264dec: Hantro G1 H264 decoder
I see that only a Hantro H264 decoder is being picked up. If I then run:

Code: Select all

root@sama5d4-xplained:/mnt# gst-inspect-1.0 g1h264dec       
Factory Details:
  Rank                     primary (256)
  Long-name                Hantro G1 H264 decoder
  Klass                    Codec/Decoder/Video
  Description              Decode an H264 stream
  Author                   Michael Gruner <michael.gruner@ridgerun.com>

Plugin Details:
  Name                     g1
  Description              GStreamer plug-in supporting the Hantro G1 HW accelerated decoder
  Filename                 /usr/lib/gstreamer-1.0/libgstg1.so
  Version                  0.0.0.1
  License                  LGPL
  Source module            gst-hantro-g1
  Binary package           GStreamer Hantro G1 Decoder Plug-in
  Origin URL               www.ridgerun.com

GObject
 +----GInitiallyUnowned
       +----GstObject
             +----GstElement
                   +----GstVideoDecoder
                         +----GstG1BaseDec
                               +----GstG1H264Dec

Pad Templates:
  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw
                 format: { GRAY8, YUY2, YVYU, UYVY, NV16, I420, NV12, RGB15, RGB16, BGR15, BGR16, RG
Bx, BGRx }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]

  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-h264
          stream-format: byte-stream
              alignment: { au, nal }


Element Flags:
  no flags set

Element Implementation:
  Has change_state() function: gst_video_decoder_change_state

Element has no clocking capabilities.
Element has no URI handling capabilities.

Pads:
  SINK: 'sink'
    Implementation:
      Has chainfunc(): gst_video_decoder_chain
      Has custom eventfunc(): gst_video_decoder_sink_event
      Has custom queryfunc(): gst_video_decoder_sink_query
      Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default
    Pad Template: 'sink'
  SRC: 'src'
    Implementation:
      Has custom eventfunc(): gst_video_decoder_src_event
      Has custom queryfunc(): gst_video_decoder_src_query
      Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default
    Pad Template: 'src'

Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "g1h264dec0"
  parent              : The parent of the object
                        flags: readable, writable
                        Object of type "GstObject"
  rotation            : Picture rotation
                        flags: readable, writable
                        Enum "GstG1EnumRotationType" Default: 0, "0deg"
                           (0): 0deg             - None/0 deg
                           (2): 90deg            - 90 deg/-270 deg/90 deg CCW
                           (5): 180deg           - 180 deg/180CW
                           (1): 270deg           - 270 deg/-90 deg/90 deg CW
                           (3): horflip          - Horizontal Flip/Mirror
                           (4): verflip          - Vertical Flip/Mirror
  brightness          : Output picture's brightness
                        flags: readable, writable
                        Integer. Range: -128 - 127 Default: 0 
  contrast            : Output picture's contrast
                        flags: readable, writable
                        Integer. Range: -64 - 64 Default: 0 
  saturation          : Output picture's saturation
                        flags: readable, writable
                        Integer. Range: -64 - 128 Default: 0 
  crop-x              : X coordinate of the cropping area. Must be less than the input image's width
 and multiple of 16.
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4096 Default: 0 
  crop-y              : Y coordinate of the cropping area. Must be less than the input image's heigh
t and multiple of 16.
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4096 Default: 0 
  crop-width          : Width of the cropping area. Must be at least 1/3 the output image's width an
d multiple of 8. Setting crop width or height to 0 disables cropping.
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4672 Default: 0 
  crop-height         : Height of the cropping area. Must be at least 1/3 the output image's height-
2 and multiple of 8. Setting crop width or height to 0 disables cropping.
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4672 Default: 0 
  mask1-location      : Path to the file containing the first mask. This file must be in a raw ARGB 
format
                        flags: readable, writable
                        String. Default: null
  mask1-x             : X coordinate of the first mask
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4096 Default: 0 
  mask1-y             : Y coordinate of the first mask
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4096 Default: 0 
  mask1-width         : Width of the first mask
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4096 Default: 0 
  mask1-height        : Height of the first mask
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4096 Default: 0 
  skip-non-reference  : Skip non-reference frames decoding to save CPU consumption and processing ti
me
                        flags: readable, writable
                        Boolean. Default: false
  disable-output-reordering: Prevents decoder from reordering output frames. This may reduce the num
ber of internally allocated picture buffers, but the application must reorder them externally. This 
property will take effect until the next time the codec is opened.
                        flags: readable, writable
                        Boolean. Default: false
  intra-freeze-concealment: Enables error concealment method where decoding starts at next intra pic
ture after an error in the bitstream. This property will take effect until the next time the codec i
s opened.
                        flags: readable, writable
                        Boolean. Default: false
  use-display-smoothing: Enable usage of extra frame buffers to achieve a smoother output. This can 
potentially double the number of internally allocated picture buffers. This property will take effec
t until the next time the codec is opened.
                        flags: readable, writable
                        Boolean. Default: false
Looking at the pad templates, I think this is telling me that this plugin is only for h264, which fits with the name.

So, my questions are as follows:

- Is there a separate mpeg4 part 2 decoder plugin that needs to be built/included to enable hardware decoding of mpeg4 part 2, or am I missing something with the g1h264dec plugin?

- If there is a separate plugin needed, how do I build this when building the gstreamer hantro plugins within yocto?

Thanks,

Brian.

edit: I should note that we can successfully play mpeg4 video using:

Code: Select all

gst-play-1.0 file_name --videosink g1fbdevsink
- however this is using software decoding, since the cpu is at 98% when the video is playing.
blue_z
Location: USA
Posts: 1547
Joined: Thu Apr 19, 2007 10:15 pm

Re: Sama5D4 Xplained Gstreamer - mpeg4 playback

Sat May 13, 2017 1:04 am

brian_ wrote:My goal is to be able to play mpeg4 video using the G1 hardware decoder.
MPEG4 is a broad specification, and this particular VDEC supports only a subset.
brian_ wrote:I see on the Hantro G1 website here: http://www.verisilicon.com/IPPortfolio_ ... troG1.html that mpeg4 is supported.
Be careful using generic documentation for a specific implementation of IP in a SoC.
For example, that web page mentions support for MPEG-2 (e.g. ATSC), and the Hantro VDEC in the AT91SAM9M10 can do MPEG-2, whereas the similar Hantro VDEC in the SAMA5D4 cannot.
brian_ wrote:- Is there a separate mpeg4 part 2 decoder plugin that needs to be built/included to enable hardware decoding of mpeg4 part 2, or am I missing something with the g1h264dec plugin?
Refer to the SoC datasheet for the supported codecs, which includes MPEG-4 Simple Profile, Levels 0, 0B, 1, 2, 3, 4a, 5, 6
and MPEG-4 Advanced Simple Profile, Levels 0, 1, 2, 3, 3b, 4, 5.
There is a g1-mpeg4 plugin, but I don't know how "Part 2" relates to these specifications.
brian_ wrote:- If there is a separate plugin needed, how do I build this when building the gstreamer hantro plugins within yocto?
See https://github.com/linux4sam/gst1-hantro-g1
IIRC these plugins should already be in the 5.3 demo.

Regards
brian_
Posts: 15
Joined: Mon Jan 09, 2017 11:59 am

Re: Sama5D4 Xplained Gstreamer - mpeg4 playback

Mon May 15, 2017 11:50 am

blue_z wrote:There is a g1-mpeg4 plugin, but I don't know how "Part 2" relates to these specifications.

Regards
Thanks for your response. Where did you see the information regarding the g1-mpeg4 plugin?

On the 5.3 demo I can't see it available:

Code: Select all

root@sama5d4-xplained:~# gst-inspect-1.0 | grep -i g1   
g1:  g1h264dec: Hantro G1 H264 decoder
rtp:  rtpmp1sdepay: RTP MPEG1 System Stream depayloader
libav:  avenc_mpeg1video: libav MPEG-1 video encoder
audioparsers:  mpegaudioparse: MPEG1 Audio Parser
g1fbdevsink:  g1fbdevsink: fbdev video sink
mpeg2dec:  mpeg2dec: mpeg1 and mpeg2 video decoder
I also can't seem to see any reference in the docs. It does seem to be the missing piece I need however.

Thanks,

Brian.
blue_z
Location: USA
Posts: 1547
Joined: Thu Apr 19, 2007 10:15 pm

Re: Sama5D4 Xplained Gstreamer - mpeg4 playback

Wed May 17, 2017 9:15 pm

brian_ wrote:Where did you see the information regarding the g1-mpeg4 plugin?
In the README.md file that's part of the GST1 Hantro github.
There are also numerous strings in libgstg1.so (especially before striping) that contain "mpeg4" and/or "mp4", as well as "dwl", "vp8", and "jpeg".

Regards

Return to “Software”

Who is online

Users browsing this forum: No registered users and 1 guest