Jump to content

h264 encoder


cvk

Recommended Posts

Hi.

Please help me   to understand  how hardware  encoding works   in nanopi  with H3 chipset.
I have    newest version of armbianos:

Quote

uname -a 
Linux nanopineo 5.15.93-sunxi #23.02.2 SMP Fri Feb 17 23:49:46 UTC 2023 armv7l armv7l armv7l GNU/Linux


cedrus and  related modules is  loaded    by kernel

 

Quote

lsmod
Module                  Size  Used by
rfkill                 20480  1
sunrpc                327680  1
snd_usb_audio         200704  0
sun4i_gpadc_iio        16384  0
lz4hc                  16384  0
snd_hwdep              16384  1 snd_usb_audio
industrialio           57344  1 sun4i_gpadc_iio
snd_usbmidi_lib        28672  1 snd_usb_audio
lz4                    16384  0
uvcvideo               77824  0
snd_rawmidi            28672  1 snd_usbmidi_lib
sunxi_cedrus           40960  0
videobuf2_vmalloc      20480  1 uvcvideo
snd_seq_device         16384  1 snd_rawmidi
v4l2_mem2mem           20480  1 sunxi_cedrus
sun8i_thermal          16384  0
videobuf2_dma_contig    20480  1 sunxi_cedrus
videobuf2_memops       20480  2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2         20480  3 uvcvideo,sunxi_cedrus,v4l2_mem2mem
videobuf2_common       40960  7 uvcvideo,sunxi_cedrus,videobuf2_dma_contig,videobuf2_vmalloc,videobuf2_memops,v4l2_mem2mem,videobuf2_v4l2
evdev                  20480  1
uio_pdrv_genirq        20480  0
uio                    16384  1 uio_pdrv_genirq
cpufreq_dt             20480  0
zram                   24576  3
sch_fq_codel           20480  2
usb_f_acm              20480  1
u_serial               24576  3 usb_f_acm
g_serial               16384  0
libcomposite           45056  2 g_serial,usb_f_acm
ramoops                24576  0
reed_solomon           16384  1 ramoops
pstore_blk             16384  0
pstore_zone            24576  1 pstore_blk
ip_tables              24576  0
x_tables               28672  1 ip_tables
autofs4                36864  2
sunxi                  16384  0
phy_generic            20480  2 sunxi
gpio_keys              20480  0
 


There are  following    hardware acceleration methods   and encoders 

Quote

 ffmpeg  -hide_banner  -hwaccels
Hardware acceleration methods:
vdpau
vaapi
drm

 

/usr/bin/ffmpeg  -hide_banner  -encoders  |  grep  264
 V..... libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V..... libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
 V..... h264_omx             OpenMAX IL H.264 video encoder (codec h264)
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)

 



Please   explain me what i am  doing wrong  here : 

Quote

ffmpeg  -y  -hide_banner -loglevel debug  -t 00:00:20   -f v4l2  -video_size 1280x720   -i /dev/video1  -c:v h264_vaapi      1234.mp4
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '00:00:20'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'v4l2'.
Reading option '-video_size' ... matched as AVOption 'video_size' with argument '1280x720'.
Reading option '-i' ... matched as input url with argument '/dev/video1'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_vaapi'.
Reading option '1234.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url /dev/video1.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 00:00:20.
Applying option f (force format) with argument v4l2.
Successfully parsed a group of options.
Opening an input file: /dev/video1.
[video4linux2,v4l2 @ 0x14a6100] fd:3 capabilities:84a00001
[video4linux2,v4l2 @ 0x14a6100] Current input_channel: 0, input_name: Camera 1, input_std: 0
[video4linux2,v4l2 @ 0x14a6100] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0x14a6100] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x14a6100] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0x14a6100] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x14a6100] The V4L2 driver changed the pixel format from 0x32315659 to 0x47504A4D
[video4linux2,v4l2 @ 0x14a6100] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x14a6100] The V4L2 driver changed the pixel format from 0x50323234 to 0x47504A4D
[video4linux2,v4l2 @ 0x14a6100] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x14a6100] All info found
Input #0, video4linux2,v4l2, from '/dev/video1':
  Duration: N/A, start: 14668.719509, bitrate: 147456 kb/s
  Stream #0:0, 1, 1/1000000: Video: rawvideo, 1 reference frame (YUY2 / 0x32595559), yuyv422, 1280x720, 0/1, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: output url 1234.mp4.
Applying option c:v (codec name) with argument h264_vaapi.
Successfully parsed a group of options.
Opening an output file: 1234.mp4.
[file @ 0x14acb30] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0x14a8d60] PACKET SIZE: 1843200, STRIDE: 2560
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x14af470] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x14af470] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 0:0 @ 0x14af470] Setting 'time_base' to value '1/1000000'
[graph 0 input from stream 0:0 @ 0x14af470] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x14af470] Setting 'frame_rate' to value '10/1'
[graph 0 input from stream 0:0 @ 0x14af470] w:1280 h:720 pixfmt:yuyv422 tb:1/1000000 fr:10/1 sar:0/1
[format @ 0x14af6c0] Setting 'pix_fmts' to value 'vaapi_vld'
[auto_scaler_0 @ 0x14b0420] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x14b0420] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x14af6c0] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
[AVIOContext @ 0x14ad6c0] Statistics: 0 seeks, 0 writeouts
[video4linux2,v4l2 @ 0x14a6100] Some buffers are still owned by the caller on close.
ioctl(VIDIOC_QBUF): Bad file descriptor
Conversion failed!
 


and here:
   
 

Quote

ffmpeg  -y  -hide_banner -loglevel debug  -f v4l2  -video_size 1280x720  -i /dev/video1 -vf 'format=yuyv422'       -t 00:00:20  -c:v h264_v4l2m2m      1234.mp4
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'v4l2'.
Reading option '-video_size' ... matched as AVOption 'video_size' with argument '1280x720'.
Reading option '-i' ... matched as input url with argument '/dev/video1'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument 'format=yuyv422'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '00:00:20'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_v4l2m2m'.
Reading option '1234.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url /dev/video1.
Applying option f (force format) with argument v4l2.
Successfully parsed a group of options.
Opening an input file: /dev/video1.
[video4linux2,v4l2 @ 0x1e950f0] fd:3 capabilities:84a00001
[video4linux2,v4l2 @ 0x1e950f0] Current input_channel: 0, input_name: Camera 1, input_std: 0
[video4linux2,v4l2 @ 0x1e950f0] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0x1e950f0] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x1e950f0] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0x1e950f0] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x1e950f0] The V4L2 driver changed the pixel format from 0x32315659 to 0x47504A4D
[video4linux2,v4l2 @ 0x1e950f0] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x1e950f0] The V4L2 driver changed the pixel format from 0x50323234 to 0x47504A4D
[video4linux2,v4l2 @ 0x1e950f0] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x1e950f0] All info found
Input #0, video4linux2,v4l2, from '/dev/video1':
  Duration: N/A, start: 15145.086581, bitrate: 147456 kb/s
  Stream #0:0, 1, 1/1000000: Video: rawvideo, 1 reference frame (YUY2 / 0x32595559), yuyv422, 1280x720, 0/1, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: output url 1234.mp4.
Applying option vf (set video filters) with argument format=yuyv422.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 00:00:20.
Applying option c:v (codec name) with argument h264_v4l2m2m.
Successfully parsed a group of options.
Opening an output file: 1234.mp4.
[file @ 0x1e9a390] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0x1e97d40] PACKET SIZE: 1843200, STRIDE: 2560
detected 4 logical cores
[Parsed_format_0 @ 0x1e9c100] Setting 'pix_fmts' to value 'yuyv422'
[graph 0 input from stream 0:0 @ 0x1e9c4d0] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x1e9c4d0] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 0:0 @ 0x1e9c4d0] Setting 'time_base' to value '1/1000000'
[graph 0 input from stream 0:0 @ 0x1e9c4d0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x1e9c4d0] Setting 'frame_rate' to value '10/1'
[graph 0 input from stream 0:0 @ 0x1e9c4d0] w:1280 h:720 pixfmt:yuyv422 tb:1/1000000 fr:10/1 sar:0/1
[AVFilterGraph @ 0x1e9b870] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[h264_v4l2m2m @ 0x1e99840] probing device /dev/video2
[h264_v4l2m2m @ 0x1e99840] driver 'uvcvideo' on card 'A4tech FHD 1080P PC Camera: A4t' in splane mode
[h264_v4l2m2m @ 0x1e99840] v4l2 output format not supported
[h264_v4l2m2m @ 0x1e99840] probing device /dev/video1
[h264_v4l2m2m @ 0x1e99840] driver 'uvcvideo' on card 'A4tech FHD 1080P PC Camera: A4t' in splane mode
[h264_v4l2m2m @ 0x1e99840] v4l2 output format not supported
[h264_v4l2m2m @ 0x1e99840] probing device /dev/video0
[h264_v4l2m2m @ 0x1e99840] driver 'cedrus' on card 'cedrus' in splane mode
[h264_v4l2m2m @ 0x1e99840] v4l2 capture format not supported
[h264_v4l2m2m @ 0x1e99840] Could not find a valid device
 


Thanks a lot.

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Same situation here.

 

Documenting.

kernel module sunxi-cedrus seems to work, i see it responsible for:

/dev/v4l    <=
/dev/media0 <=
/dev/video0 <=

I guess the correct ffmpeg codec might be h264_v4l2m2m, but when i use it, i always get: 

[h264_v4l2m2m @ 0x26de9c0] Could not find a valid device
[h264_v4l2m2m @ 0x26de9c0] can't configure encoder

A command example might be:

ffmpeg -i input.mp4 -an -vcodec h264_v4l2m2m -b:v 2M -pix_fmt nv21 out.mp4

So  i guess we are missing an environment variable or a library, or permissions?

 

Any help will be appreciated.

Thanks.

 

------------------------extension---------------

using:

ffmpeg -loglevel debug -i /home/garfius/input.mp4 -vf scale=1920:1080 -vcodec h264_v4l2m2m -y -an -pix_fmt nv12 -b:v 2M   test.mp4

Get:

[Parsed_scale_0 @ 0x21ed1a0] w:1024 h:768 fmt:yuvj420p sar:1/1 -> w:1920 h:1080 fmt:nv12 sar:3/4 flags:0x4
[h264_v4l2m2m @ 0x21ba660] probing device /dev/video0
[h264_v4l2m2m @ 0x21ba660] driver 'cedrus' on card 'cedrus' in splane mode
[h264_v4l2m2m @ 0x21ba660] v4l2 capture format not supported
[h264_v4l2m2m @ 0x21ba660] Could not find a valid device
[h264_v4l2m2m @ 0x21ba660] can't configure encoder

 

Edited by garfius
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines