H.264 encoding with i.MX8QXPMEK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

H.264 encoding with i.MX8QXPMEK

Jump to solution
2,289 Views
Kazuma_Sasaki
Senior Contributor I

<Test Environment>

Board : i.MX8QXPMEK Silicon Rev.B0

BSP : L4.14.78_1.0.0_ga

Camera : MINISASTOCSI

Using Device Tree : fsl-imx8qxp-mek-mipi-ov5640.dtb

<Question>

I am testing H.264 encoding with following command.

When I check CPU utilization during H.264 encoding, CPU consumed around 100% as below log.

Should I use any other command to use hardware encodere?

<Test Command>

# killall weston

# gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=300 ! 'video/x-raw,format=(string)NV12,width=1920,height=1080,framerate=(fraction)30/1' ! queue ! v4l2h264enc ! avimux ! filesink location=test.avi &

# top

top - 01:08:06 up 0 min,  1 user,  load average: 1.02, 0.30, 0.11
Tasks: 100 total,   1 running,  53 sleeping,   0 stopped,   0 zombie
%Cpu0  :100.0 us,  0.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  1.4 us,  2.9 sy,  0.0 ni, 95.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1309460 total,   721564 free,   444364 used,   143532 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   765992 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
3918 root      20   0  431580  26420  24152 S 100.0  2.0   0:03.14 gst-launch+

Best Regards,

Kazuma Sasaki.

Tags (1)
1 Solution
1,824 Views

Hi kazumasasaki‌,

My team sent me the following answer:

"source is MIPI camera and you are encoding the camera source to H264 and saving in some location, software should take more CPU usage then 25%."

So just to clarify, when you see 100% in the top command, actually it means you are using 25%, i.e., real_percentual = (top_percentual / number_of_cores).

However, I was verifying the possibility of applying zero copy to the Gstreamer pipeline and got about 4% (1% real) by applying the properties as below:

$ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=300 io-mode=dmabuf ! 'video/x-raw,format=(string)NV12,width=1920,height=1080,framerate=(fraction)30/1' ! queue ! v4l2h264enc output-io-mode=dmabuf-import ! avimux ! filesink location=test.avi

Please, let me know if it helps.

Best Regards,

Marco Franchi

View solution in original post

0 Kudos
4 Replies
1,825 Views

Hi kazumasasaki‌,

My team sent me the following answer:

"source is MIPI camera and you are encoding the camera source to H264 and saving in some location, software should take more CPU usage then 25%."

So just to clarify, when you see 100% in the top command, actually it means you are using 25%, i.e., real_percentual = (top_percentual / number_of_cores).

However, I was verifying the possibility of applying zero copy to the Gstreamer pipeline and got about 4% (1% real) by applying the properties as below:

$ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=300 io-mode=dmabuf ! 'video/x-raw,format=(string)NV12,width=1920,height=1080,framerate=(fraction)30/1' ! queue ! v4l2h264enc output-io-mode=dmabuf-import ! avimux ! filesink location=test.avi

Please, let me know if it helps.

Best Regards,

Marco Franchi

0 Kudos
1,824 Views
Kazuma_Sasaki
Senior Contributor I

Hi Marco Antonio Franchi,

I appreciate your support. My issue  solved.

I've confirmed CPU utilization decrease to around 3%  by your solution.


$ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=300 io-mode=dmabuf ! 'video/x-raw,format=(string)NV12,width=1920,height=1080,framerate=(fraction)30/1' ! queue ! v4l2h264enc output-io-mode=dmabuf-import ! avimux ! filesink location=test.avi


Regarding CPU utilization displayed by top command,

When I execute following test command, CPU will consum 100%. then, I executed it in parallel.

Here is my test result. based on my following trial, I think that top command displayed cpu utilization up to 400% with i.MX8QXP.

# yes >> /dev/null &

# top

top - 01:38:04 up 30 min,  1 user,  load average: 1.08, 1.14, 1.14
Tasks: 111 total,   2 running,  59 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  : 23.8 us, 76.2 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  1.2 sy,  0.0 ni, 98.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2799988 total,  2223212 free,   362252 used,   214524 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  2333356 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
11172 root      20   0    1804    364    304 R  98.8  0.0   0:04.95 yes
11173 root      20   0    3632   2124   1672 R   3.5  0.1   0:00.08 top

# yes >> /dev/null & (2nd)

# top

top - 01:38:47 up 31 min,  1 user,  load average: 1.61, 1.26, 1.18
Tasks: 112 total,   3 running,  59 sleeping,   0 stopped,   0 zombie
%Cpu0  : 16.4 us, 82.8 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.4 hi,  0.4 si,  0.0 st
%Cpu1  : 17.8 us, 82.2 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.8 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2799988 total,  2223212 free,   362236 used,   214540 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  2333364 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
11172 root      20   0    1804    364    304 R 100.0  0.0   0:47.31 yes
11174 root      20   0    1804    376    316 R  99.6  0.0   0:07.96 yes
11175 root      20   0    3632   2128   1672 R   0.8  0.1   0:00.08 top

# yes >> /dev/null & (3rd)

# yes >> /dev/null & (4th)

# top

top - 01:39:58 up 32 min,  1 user,  load average: 2.98, 1.73, 1.36
Tasks: 114 total,   5 running,  59 sleeping,   0 stopped,   0 zombie
%Cpu0  : 22.1 us, 77.9 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  : 18.5 us, 81.5 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  : 24.1 us, 75.9 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  : 22.6 us, 77.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.3 hi,  0.0 si,  0.0 st
KiB Mem :  2799988 total,  2222716 free,   362716 used,   214556 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  2332884 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
11174 root      20   0    1804    376    316 R 100.0  0.0   1:19.32 yes
11176 root      20   0    1804    344    280 R 100.0  0.0   0:11.50 yes
11178 root      20   0    1804    360    300 R  99.7  0.0   0:09.19 yes
11172 root      20   0    1804    364    304 R  99.3  0.0   1:58.54 yes
11179 root      20   0    3636   2136   1676 R   0.3  0.1   0:00.10 top

# yes >> /dev/null & (5th)

# top

top - 01:40:41 up 33 min,  1 user,  load average: 4.25, 2.21, 1.53
Tasks: 115 total,   6 running,  59 sleeping,   0 stopped,   0 zombie
%Cpu0  : 19.5 us, 80.5 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  : 19.4 us, 80.6 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  : 22.0 us, 77.7 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.3 hi,  0.0 si,  0.0 st
%Cpu3  : 20.0 us, 79.7 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.3 hi,  0.0 si,  0.0 st
KiB Mem :  2799988 total,  2222592 free,   362824 used,   214572 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  2332784 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
11176 root      20   0    1804    344    280 R  92.5  0.0   0:51.14 yes
11174 root      20   0    1804    376    316 R  85.9  0.0   1:58.99 yes
11172 root      20   0    1804    364    304 R  82.3  0.0   2:37.14 yes
11180 root      20   0    1804    384    324 R  79.3  0.0   0:14.39 yes
11178 root      20   0    1804    360    300 R  57.7  0.0   0:47.36 yes
11181 root      20   0    3636   2252   1792 R   1.0  0.1   0:00.18 top
 3627 systemd+  20   0   80124   1568   1268 S   0.3  0.1   0:00.77 systemd-ti+

Best Regards,

Kazuma Sasaki.

0 Kudos
1,824 Views

Hi kazumasasaki‌,

I reproduced your tests and even using g2d plugins, it is consuming 100% of CPU.

Let me check internally if we have something about it on v4l2h264enc side and I update you asap.

Best Regards,

Marco Franchi

1,824 Views
karina_valencia
NXP Apps Support
NXP Apps Support

marcofranchi‌, can you help with this case?

0 Kudos