Power & Source of Big Ideas

nanoPi Duo2 use of h.264 encoding

Moderators: chensy, FATechsupport

I have connected the "NanoPi Duo2" with the Camera "OV5640" and try to stream a video over the network or simply create a video-file for testing.
(The OV5640 is the matching 5MP Camera Module for the NanoPi Duo2.)

In the Wiki I got the information to use the Linux-3.4 image to have the ability for hardware-encoding.
So I use the "nanopi-duo2_sd_friendlycore-xenial_3.4_armhf_20181218.img" Rom.

From the Wiki:
"If you use a H3 boards with Linux-3.4 based ROM you can use the ffmpeg utility to hardware-encode stream data and this can greatly release CPU's resources and speed up encoding: "

Then I have tried the command:
ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 \
-b:v 64k -c:v cedrus264 test.mp4


But this do not work, I get an error message.
pi@NanoPi-Duo2:~$ ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 -b:v 64k -c:v cedrus264 test.mp4

ffmpeg version 2.3.git Copyright (c) 2000-2014 the FFmpeg developers
built on Sep 6 2016 11:47:46 with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2
libavutil 54. 6.100 / 54. 6.100
libavcodec 56. 0.101 / 56. 0.101
libavformat 56. 2.100 / 56. 2.100
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 0.102 / 5. 0.102
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 1455213710.221003, bitrate: 331776 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 331776 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[cedrus264 @ 0xf5a560] VE Open error.
Output #0, mp4, to 'test.mp4':
Stream #0:0: Video: h264, q=2-31, 128 kb/s, 30 fps
Metadata:
encoder : Lavc56.0.101 cedrus264
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (cedrus264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height


I have try it without hardware acceleration, removed the "-c:v cedrus264" in the string and then I get an mpeg2 software-encoded stream with high CPU-Load and a low framerate or I use only a 640x480 Image. :-(

Why does the example from the Wiki does not work?
With "sudo" it is working.

Code: Select all

pi@NanoPi-Duo2:~$ sudo ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 -b:v 512k -c:v cedrus264 test.mp4
ffmpeg version 2.3.git Copyright (c) 2000-2014 the FFmpeg developers
  built on Sep  6 2016 11:47:46 with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
  configuration: --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2
  libavutil      54.  6.100 / 54.  6.100
  libavcodec     56.  0.101 / 56.  0.101
  libavformat    56.  2.100 / 56.  2.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.102 /  5.  0.102
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1547911317.031117, bitrate: 331776 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 331776 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[VDPAU SUNXI] VE version 0x1680 opened.
Output #0, mp4, to 'test_512.mp4':
  Metadata:
    encoder         : Lavf56.2.100
    Stream #0:0: Video: h264 (cedrus264) ([33][0][0][0] / 0x0021), nv12, 1280x720, q=2-31, 512 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.0.101 cedrus264
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (cedrus264))
Press [q] to stop, [?] for help
frame=  901 fps= 30 q=30.0 Lsize=   60728kB time=00:00:30.03 bitrate=16564.5kbits/s dup=450 drop=0   
video:60723kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.008099%
pi@NanoPi-Duo2:
Hi,
I am also developing a video streaming device by using nano pi neo core 2.
I am also using FFmpeg command to capture video. I am facing issues with internet connectivity.

I am using TP-LINK USB WIFI dongle ( TL- WN725N ) to connect to the high-speed internet. TPLINK dongle on its package, claims it can provide 150mps network speed. However, I am getting 5 to 8 Mbps, provided I have a 25 Mbps upload and download speed plan.

and It loses network connectivity frequently, which causes inconsistent video streaming.
When I make a ping request to the SBC from a second computer within the same network, it gives loss -10-12% pings request.


Can you guide me on this problem?

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 2 guests