Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim4:applications:hardware-encoding

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
products:sbc:vim4:applications:hardware-encoding [2022/08/07 22:49]
olivia [Introduction]
products:sbc:vim4:applications:hardware-encoding [2024/04/19 04:15]
nick [H265 Hardware Encoding]
Line 8: Line 8:
  
 <WRAP important > <WRAP important >
-Support only Amlgoic 5.4 Kernel.+Only supoport Amlgoic 5.4/5.15 Kernel.
 </WRAP> </WRAP>
  
 +===== Encoding with Amlogic Library =====
  
-===== H264 Hardware Encoding ===== 
  
-```sh +==== H264 Hardware Encoding ==== 
-aml_enc_test 1080p.nv12 dump.h264 1920 1080 30 30 6000000 100 1 0 2 4+ 
 +<tabbox VIM4> 
 + 
 +```shell 
 +aml_enc_test 1080p.nv12 dump.h264 1920 1080 30 30 6000000 100 1 0 2 4
 ``` ```
 +
 +<tabbox VIM3/3L>
 +
 +```shell
 +amvenc_test 1080p.nv12 dump.h264 1920 1080 30 30 6000000 100 1 0 2 4
 +```
 +</tabbox>
 +
  
 The encoded file is ''dump.h264''. The encoded file is ''dump.h264''.
  
-===== H265 Hardware Encoding =====+==== H265 Hardware Encoding ====
  
-```sh + 
-aml_enc_test 1080p.nv12 dump.h265 1920 1080 30 30 6000000 100 1 0 2 5+ 
 +<tabbox VIM4> 
 + 
 +```shell 
 +aml_enc_test 1080p.nv12 dump.h265 1920 1080 30 30 6000000 100 1 0 2 5
 ``` ```
 +
 +<tabbox VIM3/3L>
 +
 +```shell
 +amvenc_test 1080p.nv12 dump.h265 1920 1080 30 30 6000000 100 1 0 2 5
 +```
 +</tabbox>
 +
  
 The encoded file is ''dump.h265''. The encoded file is ''dump.h265''.
  
-===== JPEG Hardware Encoding =====+==== JPEG Hardware Encoding ====
  
  
-```sh +```shell 
-jpeg_enc_test 1080p.nv12 dump.jpg 1920 1080 100 3 0 16 16 0+jpeg_enc_test 1080p.nv12 dump.jpg 1920 1080 100 3 0 8 8 0
 ``` ```
  
 The encoded file is ''dump.jpg''. The encoded file is ''dump.jpg''.
 +
 +===== Encoding with Gstreamer =====
 +
 +==== Install Gstreamer Encoder Plugins ====
 +
 +You need to install the gstreamer encoder plugins:
 +
 +```shell
 +sudo apt update
 +sudo apt install gstreamer-aml
 +```
 +
 +Check the gstreamer encoder plugins:
 +
 +```shell
 +$ gst-inspect-1.0 | grep aml
 +amljpegenc:  amljpegenc: Amlogic JPEG image encoder
 +amlvenc:  amlvenc: Amlogic h264/h265 Multi-Encoder```
 +
 +  * ''amlvenc'' is the gstreamer hardware encoder plugin for ''H264''/''H265''.
 +  * ''amljpegenc'' is the gstreamer hardware encoder plugin for ''jpeg''.
 +
 +==== H264 Hardware Encoding  ====
 +
 +Here is an example to decode H264 file to NV12 and then encode to H264.
 +
 +Decoding & encoding:
 +
 +```shell
 +gst-launch-1.0 filesrc location=/home/khadas/bbb_sunflower_1080p_60fps_normal.mp4 ! qtdemux name=d d.video_0 ! h264parse ! v4l2h264dec ! video/x-raw,format=NV12 ! amlvenc ! h264parse ! filesink location=/home/khadas/h264dec.h264
 +```
 +
 +Another example to decode video from USB camera and encode to H264:
 +
 +```shell
 +gst-launch-1.0 v4l2src device=/dev/video0 io-mode=mmap num-buffers=300 ! image/jpeg,width=1920,height=1080,framerate=30/1 ! jpegdec ! amlvenc ! h264parse ! filesink location=test_0.h264
 +```
 +
 +==== H265 Hardware Encoding  ====
 +
 +Here is an example to decode H264 file to NV12 and then encode to H265.
 +
 +Decoding & encoding:
 +
 +
 +```shell
 +gst-launch-1.0 filesrc location=/home/khadas/bbb_sunflower_1080p_60fps_normal.mp4 ! qtdemux name=d d.video_0 ! h264parse ! v4l2h264dec ! video/x-raw,format=NV12 ! amlvenc ! h265parse ! filesink location=/home/khadas/h264dec.h265
 +```
 +
 +Another example to decode video from USB camera and encode to H265:
 +
 +```shell
 +gst-launch-1.0 v4l2src device=/dev/video0 io-mode=mmap num-buffers=300 ! image/jpeg,width=1920,height=1080,framerate=30/1 ! jpegdec ! amlvenc ! h265parse ! filesink location=test_0.h265
 +```
 +
 +==== JPEG Hardware Encoding  ====
 +
 +Read one frame YUY2 format data from USB camera and encode to jpeg file.
 +
 +```shell
 +gst-launch-1.0 -v v4l2src device=/dev/video0 io-mode=mmap num-buffers=1 ! video/x-raw,format=YUY2,width=640,height=480 ! amljpegenc ! filesink location=1.jpg
 +```
 +
 +===== Library Source Code =====
 +
 +  * H264/H265 [[gh>numbqq/encoder_libs_aml/tree/yocto-202311/multiEnc | Library Source Code of H264/H265 ]], check REDME to build.
 +  * JPEG [[gh>numbqq/encoder_libs_aml/tree/yocto-202311/jpeg | Library Source Code of JPEG]], check REDME to build.
 +
Last modified: 2024/04/21 21:36 by nick