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-linux/rk-rootfs-build/blob/master/mk-rootfs.sh#L69).
How can I enable the VPU to do the 4K decoding? And how can I enable 1080p h264 encoder?

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?

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.

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?

How about use Firefly Ubuntu image ?

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.

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 :

mkdir temp
sudo mount linuxroot.img temp
sudo chroot temp

3 do what you want,
4 make your rootfs : http://wiki.t-firefly.com/index. … /en#make_the_rootfs

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.

By the way, are you able to provide an Ubuntu image with working mppvideodec and mpph264enc in Gstreamer?

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

Thank you,

this is what I am using. But then mppvideodec and mpph264enc are not enabled.

Have there been any more developments on this? I’ve been hoping for hardware encoding on the RK3399 since the Kickstarter.

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

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 …

This seems to be the critical line:

hal_h264e_api: vcodec type 00000000 can not find H.264 encoder device

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

mitchekl@firefly:~$ cat /proc/version
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

Thanks!

Your article is simply remarkable, thank you for sharing! Strengthen your IT expertise with free 1Y0-204 online lab simulation. Good luck and best wishes!

This article is truly inspiring, and it has given me a new understanding of the related topic. It’s nearly time for my MCE-Dev-201 pdf files exam – wish me all the best!

The article gave me so much value in such a short time. I’m offering the Frequent PDII-JPN Updates resources for free—good luck!

The article provided me with so much to ponder. We offer you access to the rich content of CSPAI reliable study questions ppt for free, hoping it benefits you.