Hardware h264 video encoding in linux


#41

When using the below commands everything works perfectly.

sudo apt-get install gstreamer1.0-plugins-v4l2

gst-launch-1.0 -v -e --gst-debug=v4l2enc:0 videotestsrc ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1,profile=high,level\=\(string\)"5" ! v4l2enc ! queue ! filesink location=/home/linaro/enc.h264

gst-launch-1.0 -v -e --gst-debug=v4l2enc:0 videotestsrc ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1,profile=high,level\=\(string\)"5" ! v4l2enc ! h264parse ! mp4mux ! queue ! filesink location=/home/linaro/enc.mp4

I am getting an encoded video file which is playable.

But before doing the above steps I tried to compile the v4l2plugins from the source as below on the DB410C board itself.

mkdir transcoder

git clone https://git.linaro.org/landing-teams/working/qualcomm/pkg/gst-plugins-v4l2.git trasncoder/

cd transcoder

./autogen.sh

make

make install

sudo chown linaro:linaro -R /usr/local/lib/gstreamer-1.0

sudo chmod 777 -R /usr/local/lib/gstreamer-1.0

ls -l /usr/local/lib/gstreamer-1.0
-rwxrwxrwx 1 linaro linaro   1066 Feb 21 07:25 libgstv4l2dec.la
-rwxrwxrwx 1 linaro linaro 169520 Feb 21 07:25 libgstv4l2dec.so
-rwxrwxrwx 1 linaro linaro   1066 Feb 21 07:25 libgstv4l2enc.la
-rwxrwxrwx 1 linaro linaro 176792 Feb 21 07:25 libgstv4l2enc.so
-rwxrwxrwx 1 linaro linaro   1078 Feb 21 07:25 libgstv4l2trans.la
-rwxrwxrwx 1 linaro linaro 220192 Feb 21 07:25 libgstv4l2trans.so

export GST_PLUGIN_PATH=/usr/local/lib/gstreamer-1.0

gst-inspect-1.0 | grep "v4l2"
v4l2dec:  v4l2dec: V4L2 decoder
v4l2enc:  v4l2enc: V4L2 encoder
v4l2trans:  v4l2trans: V4L2 transform
video4linux2:  v4l2src: Video (video4linux2) Source
video4linux2:  v4l2sink: Video (video4linux2) Sink
video4linux2:  v4l2radio: Radio (video4linux2) Tuner
video4linux2:  v4l2deviceprovider (GstDeviceProviderFactory)
video4linux2:  v4l2video32dec: V4L2 Video Decoder

Now when I use the compiled v4l2enc plugin It was giving me the following error. Please help me to identify what went wrong with my compilation.

$ gst-launch-1.0 -v -e --gst-debug=v4l2enc:0 videotestsrc ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1,profile=high,level\=\(string\)"5" ! v4l2enc ! queue ! filesink location=/home/linaro/enc.h264
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ profile\=\(string\)high\,\ level\=\(string\)5\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ profile\=\(string\)high\,\ level\=\(string\)5\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive"
/GstPipeline:pipeline0/GstV4L2Enc:v4l2enc0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ profile\=\(string\)high\,\ level\=\(string\)5\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ profile\=\(string\)high\,\ level\=\(string\)5\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive"
/GstPipeline:pipeline0/GstV4L2Enc:v4l2enc0.GstPad:src: caps = "video/x-h264\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = "video/x-h264\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = "video/x-h264\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ framerate\=\(fraction\)30/1"
ERROR: from element /GstPipeline:pipeline0/GstV4L2Enc:v4l2enc0: GStreamer error: negotiation problem.
Additional debug info:
gstvideoencoder.c(1463): gst_video_encoder_chain (): /GstPipeline:pipeline0/GstV4L2Enc:v4l2enc0:
encoder not initialized
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = "NULL"
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = "NULL"
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = "NULL"
/GstPipeline:pipeline0/GstV4L2Enc:v4l2enc0.GstPad:src: caps = "NULL"
/GstPipeline:pipeline0/GstV4L2Enc:v4l2enc0.GstPad:sink: caps = "NULL"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = "NULL"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = "NULL"
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = "NULL"
Freeing pipeline ...

Regards,
Sunny.


[DB820c] Hardware Encoder and Decoder Support
#42

hi,

sorry, i might have missed this message …

First of all, you are using a very old thing here… so it took me some time to remember… From your log you are using the ‘master’ branch from the gst plugin git tree, and you should be using the “debian” branch instead. From what I remember it was the debian branch which was pushed into our release (in Debian/Jessie).

Note that moving forward we are no longer supporting this external Gstreamer plugin for v4l2. Instead we are using the v4l2 plugins from Gstreamer Core (e.g. gst-plugins-good). The v4l2dec is already merged in Gst core, and the v4l2enc is being developed these days. The out of tree gst plugins we used in the past won’t work with any kernel more recent than what we had in the 16.09 release (or we would need to update the plugins accordingly).


#43

Thanks for the info. :slight_smile:

I am not able to find v4l2dec plugin on gstreamer documentation. Can you please provide a link for v4l2dec plugin ?


#44

I can’t find it in the doc neither… so it must be missing… here is a link to the plugin source code:

https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/sys/v4l2/gstv4l2videodec.c


#45

Unfortunately dynamic instantiated plugins don’t show up in the documentation. Though, gst-inspect-1.0 v4l2videoNdec should give you all the details you need. This should eventually be addressed by:

https://bugzilla.gnome.org/show_bug.cgi?id=742918


#46

I don’t get it, but below is what I see under my PC. Can you please confirm in which gstreamer release the v4l2videodec plugin is included ?

user@linuxpc:~$ gst-inspect-1.0 --version
gst-inspect-1.0 version 1.8.2
GStreamer 1.8.2
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

user@linuxpc:~$ gst-inspect-1.0 | grep "v4l2"
video4linux2: v4l2src: Video (video4linux2) Source
video4linux2: v4l2sink: Video (video4linux2) Sink
video4linux2: v4l2radio: Radio (video4linux2) Tuner
video4linux2: v4l2deviceprovider (GstDeviceProviderFactory)

user@linuxpc:~$ gst-inspect-1.0 v4l2videoNdec
No such element or plugin ‘v4l2videoNdec’

user@linuxpc:~$ gst-inspect-1.0 v4l2videodec
No such element or plugin ‘v4l2videodec’


#47

it is normal. on your PC there is no v4l2 decoder driver, so there won’t be any instance of the Gst v4l2videoNdec plugin. if you run the same command on your DB410c , then you should see one instance of the plugin.


#48

Oh sorry my bad, I got confused between DB410 and DB820. This post is related to DB410 and not DB820, I am looking for v4l2 decoder and encoder plugins on DB820. Yes ndec am able to see both v4l2videodec and v4l2videoenc on DB410, I have already tested both the plugins on DB410. Thanks.


#49

Hi @ndec,

I am also facing the same thing as described here,
in the output of gst-inspect-1.0 |grep v4l2 command,
I don’t see the v4l2enc.

can you suggest me any way to use the hardware encoder provided in my DB410c board.
I am using the latest linaro build, and i did update and upgrade after fresh installation.

Could you help me out here.

Thanks,
Hinesh


#50

sorry, i missed this message earlier.

don’t you see something like that:

root@dragonboard-410c:~# gst-inspect-1.0 | grep v4l2
video4linux2:  v4l2src: Video (video4linux2) Source
video4linux2:  v4l2sink: Video (video4linux2) Sink
video4linux2:  v4l2radio: Radio (video4linux2) Tuner
video4linux2:  v4l2deviceprovider (GstDeviceProviderFactory)
video4linux2:  v4l2mpeg4dec: V4L2 MPEG4 Decoder
video4linux2:  v4l2mpeg2dec: V4L2 MPEG2 Decoder
video4linux2:  v4l2h263dec: V4L2 H263 Decoder
video4linux2:  v4l2h264dec: V4L2 H264 Decoder
video4linux2:  v4l2vp8dec: V4L2 VP8 Decoder
video4linux2:  v4l2vc1dec: V4L2 VC1 Decoder
video4linux2:  v4l2h264enc: V4L2 H.264 Encoder
video4linux2:  v4l2mpeg4enc: V4L2 MPEG4 Encoder
video4linux2:  v4l2h263enc: V4L2 H.263 Encoder
video4linux2:  v4l2vp8enc: V4L2 VP8 Encoder

There are a couple of video encoder here.

It is with Gst 1.14.2

If you don’t see that, please share more info about your build, gst version, …


#51

Hi @ndec

When I ran above mentioned command, I was getting only below outputs.

video4linux2: v4l2src: Video (video4linux2) Source
video4linux2: v4l2sink: Video (video4linux2) Sink
video4linux2: v4l2radio: Radio (video4linux2) Tuner

I am not able to find v4l2enc ( which i am looking for),
I am using the latest gst version provided in linaro latest build.( also performed update and upgrade).
Do I require to install some more set of gst plugins???

Kindly provide your suggestions.

Thanks,
Hinesh


#52

Just in case, could you check with ‘lsmod’ you have modules loaded, including venus_dec/venus_enc.
There is a known issue with last build and upgrading: After sudo apt upgrade - the wifi device is gone


#53

Hi @Loic,
I have checked with lsmod, And I Don’t find the encoder in them as well.

Thanks,