How to spcify encoding parameters with v4l2h264enc for DragonBoard 410c

I am sorry, I forgot to say that you have to use the OE release:

https://builds.96boards.org/releases/dragonboard410c/linaro/openembedded/latest/

All right, I’d like to try out various with the OE.

However, I do not understand that hardware acceleration can not be used on Debian Build # 283 with FFmpeg or GStreamer.

Is there any information of these?

Ffmpeg was just not included in the Debian release (but you can always pull it from the sources master branch and build it yourself, there is nothing impeding it from working).

As to why you don’t have the video nodes I can’t comment without some logs- can you share the boot console or look for any error strings that mention “Venus” o “venus”?

I see, I’ll try it later.

I’ve checked the dmesg and grep “venus”, the result is as folllows;

linaro@linaro-alip:~$ dmesg | grep venus
[    1.975764] msm_iommu_ctx 1e25000.venus_ns: context venus_ns using bank 5
[    1.977940] msm_iommu_ctx 1e33000.venus_sec_pixel: context venus_sec_pixel using bank 19
[    1.978327] msm_iommu_ctx 1e34000.venus_sec_bitstream: context venus_sec_bitstream using bank 20
[    1.978700] msm_iommu_ctx 1e35000.venus_sec_non_pixel: context venus_sec_non_pixel using bank 21
[    1.979076] msm_iommu_ctx 1e36000.qcom,iommu-ctx: context venus_fw using bank 22
[    9.659969] Modules linked in: venus_core(+) msm_rng(+) qcom_camss(+) rng_core mdt_loader videobuf2_dma_sg v4l2_mem2mem videobuf2_memops videobuf2_v4l2 videobuf2_core videodev media ip_tables x_tables i2c_qcom_cci
[    9.743083] qcom-venus 1d00000.video-codec: Direct firmware load for qcom/venus-1.8/venus.mdt failed with error -2
[    9.743244]  venus_core(+)
[    9.743441] [<ffff000000b8a014>] qcom_venus_driver_init+0x14/0x1000 [venus_core]
[    9.743571] qcom-venus: probe of 1d00000.video-codec failed with error -2
linaro@linaro-alip:~$

Surely some errors are occurred. Did I failed downloading the #283 image?

I think the venus firmware files should be placed now in /lib/firmware/qcom/venus-1.8 and not in /lib/firmware.

Could you check that you have
root@linaro-alip:/lib/firmware/qcom/venus-1.8# ls -la
total 1964
drwxr-xr-x 2 root root 4096 Sep 28 00:52 .
drwxr-xr-x 3 root root 4096 Sep 28 00:52 …
-rw-r–r-- 1 root root 212 Sep 28 00:52 venus.b00
-rw-r–r-- 1 root root 6600 Sep 28 00:52 venus.b01
-rw-r–r-- 1 root root 975088 Sep 28 00:52 venus.b02
-rw-r–r-- 1 root root 5568 Sep 28 00:52 venus.b03
-rw-r–r-- 1 root root 32 Sep 28 00:52 venus.b04
-rw-r–r-- 1 root root 988880 Sep 28 00:52 venus.mbn
-rw-r–r-- 1 root root 6812 Sep 28 00:52 venus.mdt

Sorry, I’ve missed the workaround.

mkdir -p /lib/firmware/qcom/venus-1.8
cd /lib/firmware/qcom/venus-1.8/
for i in /lib/firmware/venus.*; do ln -s $i; done

Then, these error messages are disappeared.

makes sense. Gstreamer should work. and if you install ffmpeg from sources, it will work as well.

Thank you for the other day.

BTW, I am planning to experiment with various encode parameters for FFmpeg, but I can not find parameters equivalent to “extra-controls” in GStreamer.

I think that parameters such as H.264 profile, level, and quality can not be specified with the FFmpeg standard commands, but how can I specify it?

Can I use FFmpeg to grab frames directly from a camera?

In the example:
ffmpeg -loglevel debug -f rawvideo -pix_fmt nv12 -s:v 1280:720 -r 25 -i ~/Videos/raw/freeway.yuv -c:v h264_v4l2m2m out/out.h264.mp4

It appears that the encoder is encoding frames from an already recorded video. Can I do this with live video?

I tried this and FFmpeg cannot tell that the source is a video capture device, so I think I’m missing something here:
ffmpeg -loglevel debug -f v4l2 -pix_fmt nv12 -s:v 1280:960 -r 30 -i /dev/video3 -c:v h264_v4l2m2m encoded.mp4

Edit: Here’s a log from an unsuccessful run of the above command
dragonboard-410c:~$ ffmpeg -loglevel debug -f v4l2 -pix_fmt nv12 -s:v 1280:720 -r 25 -i /dev/video3 -c:v h264_v4l2m2m out.h264.mp4 ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.2.1 (Linaro GCC 6.2-2016.11) 20161016 configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape --cross-prefix=aarch64-linaro-linux- --ld='aarch64-linaro-linux-gcc --sysroot=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/dragonboard-410c' --cc='aarch64-linaro-linux-gcc --sysroot=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/dragonboard-410c' --cxx='aarch64-linaro-linux-g++ --sysroot=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/dragonboard-410c' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/work/aarch64-linaro-linux/ffmpeg/3.3.3-r0=/usr/src/debug/ffmpeg/3.3.3-r0 -fdebug-prefix-map=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/x86_64-linux= -fdebug-prefix-map=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/dragonboard-410c= --sysroot=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/dragonboard-410c' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed' --sysroot=/media/rob/a72581e8-3ca3-4dc1-b3b8-6db5464de098/qc_openEmbedded/apps_proc/build/tmp-glibc/sysroots/dragonboard-410c --enable-hardcoded-tables --libdir=/usr/lib64 --shlibdir=/usr/lib64 --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --disable-avresample --enable-bzlib --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmp3lame --disable-openssl --enable-postproc --disable-libschroedinger --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --enable-outdev=xv libavutil 55. 58.100 / 55. 58.100 libavcodec 57. 89.100 / 57. 89.100 libavformat 57. 71.100 / 57. 71.100 libavdevice 57. 6.100 / 57. 6.100 libavfilter 6. 82.100 / 6. 82.100 libswscale 4. 6.100 / 4. 6.100 libswresample 2. 7.100 / 2. 7.100 libpostproc 54. 5.100 / 54. 5.100 Splitting the commandline. 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 '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'nv12'. Reading option '-s:v' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '1280:720'. Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '25'. Reading option '-i' ... matched as input url with argument '/dev/video3'. Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_v4l2m2m'. Reading option 'out.h264.mp4' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option loglevel (set logging level) with argument debug. Successfully parsed a group of options. Parsing a group of options: input url /dev/video3. Applying option f (force format) with argument v4l2. Applying option pix_fmt (set pixel format) with argument nv12. Applying option s:v (set frame size (WxH or abbreviation)) with [ 3623.130796] 1b0c000.qcom,cci supply qcom,gdscr-vdd not found, using dummy regulator argument 1280:720. Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 25. Successfully parsed a group of options. Opening an input file: /dev/video3. [video4linux2,v4l2 @ 0x1f8b6460] fd:3 capabilities:85201000 [video4linux2,v4l2 @ 0x1f8b6460] Not a video capture device. /dev/video3: No such device

did you check this link?
https://trac.ffmpeg.org/wiki/Capture/Webcam

it seems your input device is not a video capture device.

Yeah, I got that from the error…

It doesn’t seem like any of the video interfaces are. On the DB410c how would I properly encode from the camera with ffmpeg? Is this supported?

can you open a terminal and type
$ dmesg -w -d
then plug your camera and provide the new lines printed from dmesg and the output from:

$ v4l2-ctl --list-devices

I’m sorry, I still want to implement with GStreamer instead of FFmpeg as my implementation.
There is no change in the present condition that some required parameters are not valid.
So I will rewrite them, please take care that the setting of the following parameters becomes effective.

  • h264_entropy_mode
  • h264_loop_filter_mode
  • video_gop_size
  • video_b_frames
  • h264_cpb_size

Best regards.

If I understand your problem, even if these capabilities are reported as supported, they have no effect on your stream when using gstreamer ? could you please provide the gstreamer command/pipeline you apply ?

For example, let’s focus on h264_entropy_mode.
As for the binary data resulting from encoding and encoding the following two types of pipeline, there is no difference other than the time field of the header of .mp4.

The following example is expected to be encoded by CAVLC:

gst-launch-1.0 filesrc location=test.nv12 ! \
	rawvideoparse width=1280 height=960 framerate=15/1 format=23 ! \
	v4l2h264enc extra-controls="controls,h264_entropy_mode=0,h264_profile=4,h264_level=10,video_bitrate=256000;" ! \
	h264parse ! video/x-h264,stream-format="avc",alignment="au" ! \
	mp4mux fragment-duration=10 ! filesink location=test0.mp4

Next example is expected to be encoded by CABAC, but it seems same as CAVLC.

gst-launch-1.0 filesrc location=test.nv12 ! \
	rawvideoparse width=1280 height=960 framerate=15/1 format=23 ! \
	v4l2h264enc extra-controls="controls,h264_entropy_mode=1,h264_profile=4,h264_level=10,video_bitrate=256000;" ! \
	h264parse ! video/x-h264,stream-format="avc",alignment="au" ! \
	mp4mux fragment-duration=10 ! filesink location=test1.mp4

Could you please try it?

Thanks, I don’t see any obvious usage of entropy_mode in the venus driver, value seems retrieved by the driver but not really applied (ctr->h264_entropy_mode) (cf: drivers/media/platform/qcom/venus).

We are going to clarify the status (what is really supported and what is planned to support).

Obviously entropy mode is not applied in the driver. Could you open a bug with all controls which you think are not applied at bugs.96boards.org?

To clarify my words, I though the driver would use this entropy_mode value to configure the hardware for a certain entropy encoding usage. But yes, @medianoche, could you please open a bug for non-effective v4l2 controls.

I understand. I will post a bug report.

@medianoche , I’ve attached a first patch to the bug : https://bugs.96boards.org/attachment.cgi?id=213
This should fix the entropy issue, would you be able to test it on your side (kernel and modules rebuild)?

With this patch, mediainfo reports the following:

  • with h264_entropy_mode=0
    Format settings, CABAC : No
  • with h264_entropy_mode=1
    Format settings, CABAC : Yes