Firefly Open Source Community

Title: Using Gstreamer to decode 4K video to 1080p [Print This Page]

Author: arnstein    Time: 7/28/2017 20:45
Title: Using Gstreamer to decode 4K video to 1080p
Hello,

I have tried both the Firefly Ubuntu image and also making my own following the guide at http://rockchip.wikidot.com/linux-user-guide , but I am not able to use vpudec in Gstreamer.
Doing ls /dev I can find vpu_service and rkvdec.
In the build script for rockchip-linux it also installs rockchip_mpp libraries(https://github.com/rockchip-linu ... er/mk-rootfs.sh#L69).
How can I enable the VPU to do the 4K decoding? And how can I enable 1080p h264 encoder?
Author: vinchi9    Time: 7/29/2017 00:27
Hello,
I was able to use the hardware decoder and encoder through rockchip-gstreamer plugin. It adds mppvideodec decoder and mpph264enc encoder to gstreamer. Both the encoder and the decoder worked, but the encoded video had really bad quality. I searched in the gstreamer-rockchip sources and I managed to get the hardware encoder working in gstreamer with good video quality. The only way I was able to set video quality was by changing hardcoded values in gstreamer-rockchip source code and then recompiling the rockchip gsteamer plugin.
This way I can set the QP and control the video quality, but I cannot directly control the bitrate, because changing the bitrate in source code seems to have no effect. If low QP is set the encoded video has good quality, but the bit rate is really high. 1080p encoded video with similar quality as the original 1080p video has bitrate 28Mb/s compared to 4Mb/s original video.

In a nutshell, I am able to use the hardware encoder and decoder, but the encoded video bitrate is really high and I haven't figured out yet how to fix this.
Does anyone know how to fix the problem with high bitrate?

Author: arnstein    Time: 7/29/2017 19:18
I am able to compile the mpp and rkximage part of the rockchip-gstreamer plugin, however, after it is done I do not find mppvideodec and mpph264enc available in Gstreamer when doing gst-inspect.
Author: arnstein    Time: 8/7/2017 18:21
If I specify with --gst-plugin-path=/usr/local/lib/gstreamer-1.0/ I get the following message:

(gst-plugin-scanner:18102): GStreamer-WARNING **: Failed to load plugin '/usr/local/lib/gstreamer-1.0/libgstrockchipmpp.so': /usr/local/lib/gstreamer-1.0/libgstrockchipmpp.so: undefined symbol: gst_pad_get_task_state

How can I fix this?
Author: isle    Time: 8/14/2017 10:19
How about use Firefly Ubuntu image ?
Author: arnstein    Time: 8/14/2017 15:14
It is important for me to be able to choose which software etc. to flash on the image. That's why I choose to use the rockchip-linux rootfs script. Can you provide a similar script to generate your Firefly Ubuntu image? That way I can add the software and settings I need in my script.
Author: isle    Time: 8/15/2017 09:32
Last edited by isle In 8/15/2017 09:43 Editor

Hi, if you want modify our firmware, do like this:
1 unpack the firmware : http://wiki.t-firefly.com/index. ... android_firmware/en
    then get the rootfs image.
2 mount and choot :
   
  1. mkdir temp
  2. sudo mount linuxroot.img temp
  3. sudo chroot temp
Copy the code

3 do what you want,
4 make your rootfs : http://wiki.t-firefly.com/index. ... /en#make_the_rootfs
Author: arnstein    Time: 8/15/2017 16:28
Thank you,
this works, but it is not a satisfactory solution for me. I want to be able to automate building several images with different settings (for example different SSIDs on wifi). With this method I would have to do this for each image separately.
Author: arnstein    Time: 8/15/2017 20:31
By the way, are you able to provide an Ubuntu image with working mppvideodec and mpph264enc in Gstreamer?
Author: isle    Time: 8/17/2017 10:38
arnstein Posted at 8/15/2017 16:28
Thank you,
this works, but it is not a satisfactory solution for me. I want to be able to automate ...

https://github.com/rockchip-linux/rk-rootfs-build
Author: arnstein    Time: 8/17/2017 18:58
Thank you,

this is what I am using. But then mppvideodec and mpph264enc are not enabled.
Author: korinel    Time: 1/16/2018 14:15
Have there been any more developments on this?  I've been hoping for hardware encoding on the RK3399 since the Kickstarter.
Author: korinel    Time: 1/19/2018 06:59
It took a while, but I managed to compile mpp & gstreamer-rockchip on a fresh version of gstreamer.  The trick on ubuntu was to track down all of the dependencies for gstreamer1.0 and its plugins, install those separately, then do everything from git source.  However, I'm completely new to gstreamer, which seems far more complex than ffmpeg.  Does anyone know how to use streamer for say transcoding to h.264 from an mpeg-2 transport stream?  I'd appreciate any pointers.
  -Karl
Author: korinel    Time: 1/21/2018 09:21
I managed to construct a gst-launch-1.0 pipeline to test the mpph264enc plugin to gstreamer, but unfortunately hit a wall.  Perhaps something is wrong in the kernel?  Any suggestions?

xxxxxxxx@firefly:/mnt/dvr/tmp$ gst-launch-1.0 videotestsrc ! mpph264enc ! h264parse ! mp4mux ! filesink location=test.mp4 -e
Setting pipeline to PAUSED ...
mpi: mpp version: 1a795b0 author: Herman Chen [mpp_dec]: Fix mpp_frame memory leak on reset
hal_h264e_api: vcodec type 00000000 can not find H.264 encoder device
mpp_hal: mpp_hal_init hal h264e_rkvenc init failed ret -1
mpp_hal: mpp_hal_init could not found coding type 7
mpp_enc: mpp_enc_init could not init hal
mpp_rt: NOT found ion allocator
mpp_rt: found drm allocator
mpp: error found on mpp initialization
Pipeline is PREROLLING ...
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913328
mpp: command 320005 param 0x7f9a4291d0 ret -3
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913264
mpp: command 320005 param 0x7f9a429210 ret -3
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913184
mpp: command 320005 param 0x7f9a429260 ret -3
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913344
mpp: command 320005 param 0x7f9a4291c0 ret -3
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913184
mpp: command 320005 param 0x7f9a429260 ret -3
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913408
mpp: command 320005 param 0x7f9a429180 ret -3
mpp: Assertion mEnc failed at control_enc:756
mpp_enc: mpp_enc_control found NULL input enc (nil) cmd 320005 param -1706913408
mpp: command 320005 param 0x7f9a429180 ret -3
Freeing pipeline ...

Author: korinel    Time: 2/2/2018 00:16
This seems to be the critical line:

  1. hal_h264e_api: vcodec type 00000000 can not find H.264 encoder device
Copy the code


Are there any kernel requirements?  This is what I'm running:

  1. mitchekl@firefly:~$ cat /proc/version
  2. Linux version 4.4.16 (firefly@tchip-server) (gcc version 4.9.x-google 20140827 (prerelease) (GCC) ) #20 SMP PREEMPT Sat Mar 18 15:19:16 CST 2017
Copy the code


Thanks!




Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) Powered by Discuz! X3.1