Logitech C920 FFServer H.264 streaming without re-encoding

I am trying to stream my own .H264 web feed from a Logitech C920 webcam in real time from an Odroid device (robot) via ffserver running on a separate server (CentOS 7.1), to the user's browser without reusing .H264 video.

The presence of real-time videos in the browser is a problem in itself, so for now I’m just trying to get the Logitech C920 webcam on Odroid to transmit its own .H264 mp4 real-time video via ffserver for users without having to transcode the video in the process. Obviously, I want to avoid re-encoding, as it will take too much CPU time and kill real-time video. Later, I may need to change the container to .flv or rtp so that it can play in the browser in real time. I use the Logitech C920 webcam because it can do .H264 encoding on hardware. (It was tested by saving the file directly, it works, except for the well-known jerking problem associated with the Linux kernel error: http://sourceforge.net/p/linux-uvc/mailman/message/33164469/ , but that’s completely other story)

The problem is that, however, I set ffmpeg-ffserver up as soon as ffserver is in the picture, the channel gets reencoded - even from h264 (native) to h264 (libx264) - it takes up 100% of the CPU on the Odroid device and introduces a huge delay in the video stream.

The following are the ffmpeg and ffserver settings.

Ffmpeg from an Odroid device transmitting .H264 stream to ffserver

$ ffmpeg -s 1920x1080 -f v4l2 -vcodec h264 -i /dev/video0 -copyinkf -vcodec copy http://xxxyyyy.com:8090/feed1.ffm ffmpeg version N-72744-g653bf3c Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.8 (Ubuntu/Linaro 4.8.2-19ubuntu1) configuration: --prefix=/home/odroid/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/odroid/ffmpeg_build/include --extra-ldflags=-L/home/odroid/ffmpeg_build/lib --bindir=/home/odroid/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree libavutil 54. 27.100 / 54. 27.100 libavcodec 56. 41.100 / 56. 41.100 libavformat 56. 36.100 / 56. 36.100 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 16.101 / 5. 16.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.100 / 1. 2.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 6581.606726, bitrate: N/A Stream #0:0: Video: h264 (Constrained Baseline), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 60 tbc [swscaler @ 0x11bf0b0] deprecated pixel format used, make sure you did set range correctly No pixel format specified, yuvj420p for H.264 encoding chosen. Use -pix_fmt yuv420p for compatibility with outdated media players. [libx264 @ 0x12590e0] using SAR=64/45 [libx264 @ 0x12590e0] using cpu capabilities: ARMv6 NEON [libx264 @ 0x12590e0] profile High, level 1b Output #0, ffm, to 'http://robo-car.int.thomsonreuters.com:8090/feed1.ffm': Metadata: creation_time : now encoder : Lavf56.36.100 Stream #0:0: Video: h264 (libx264), yuvj420p(pc), 160x128 [SAR 64:45 DAR 16:9], q=-1--1, 64 kb/s, 30 fps, 1000k tbn, 5 tbc Metadata: encoder : Lavc56.41.100 libx264 Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Press [q] to stop, [?] for help ^Cav_interleaved_write_frame(): Immediate exit requested00 bitrate=N/A dup=0 drop=97 Last message repeated 2140 times frame= 3723 fps=301 q=-1.0 Lsize= 396kB time=00:12:14.20 bitrate= 4.4kbits/s dup=3699 drop=103 video:321kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 23.500496% 

And / etc / ffserver.conf on the server running ffserver:

 HTTPPort 8090 # Port to bind the server to HTTPBindAddress 0.0.0.0 MaxHTTPConnections 2000 MaxClients 1000 MaxBandwidth 10000 # Maximum bandwidth per client # set this high enough to exceed stream bitrate CustomLog - <Feed feed1.ffm> # This is the input feed where FFmpeg will send File ./feed1.ffm # video stream. FileMaxSize 1G # Maximum file size for buffering video </Feed> <Stream test.mp4> Feed feed1.ffm Format mp4 NoAudio </Stream> 

As you saw in the ffmpeg section above, transcoding occurs on the Odroid device, maximizing the processors:

 Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) 

I already tried to set the VideoCodec value in the ffserver configuration directly in libx264, tried the -re option in ffmpeg, tried to use a different syntax for ffmpeg, etc. Nothing helps. Re-recording always exists, so I cannot do ffmpeg-ffserver just to broadcast the video stream as it is.

Both ffmpeg (on Odroid and on the server) were compiled yesterday (2015-06-09) from the source, so they are the latest (and the same) version.

Any idea?

EDIT: In RESUME, the problem is this: I cannot find a way to get ffserver to broadcast the h264 (native) channel coming from the Logitech C920 webcam without re-encoding.

+5
source share
3 answers

Well, this is not quite the answer, but I managed to do this by switching to vlc. Unfortunately, I was not able to get ffserver to accept the .H264 input stream as is, without re-encoding it, and even if I had, I would still have a problem with the regression of the ffmpeg-C920-linux kernel: http: // sourceforge.net/p/linux-uvc/mailman/message/33164469/

Thus, it would be wise to drop the line ffmpeg-ffserver and try vlc.

In case anyone else is interested, with vlc I managed to achieve the unlisted distribution of the root file .H264 of the C920 webcam by doing the following:

On an Odroid device, this will pick up the .H264 stream from the camera and

 streams it via http in mpeg-ts: cvlc v4l2:///dev/video0:chroma=h264:width=1920:height=1080 --sout '#standard{access=http,mux=ts,dst=[ip of odroid]:8080,name=stream,mime=video/ts}' -vvv 

On the CentOS 7 server, the stream from Odroid and multicast are taken, so consumers can connect to it, instead of trying to connect to the Odroid device with much more limited bandwidth (wifi):

 vlc http://[ip of odroid]:8080 --sout '#standard{access=http,mux=ts,dst=[ip of centos server]:8080,name=stream,mime=video/ts}' -vvv 

Now I can play this stream in real time from the VLC player on the device:

 http://[ip of centos server]:8080 

But yes, this is not a solution to the original ffmpeg-ffserver problem, but rather a workaround using vlc for the same.

+3
source

Another thing that I noticed in your config is that you code to high profile in libx264 - "libx264 @ 0x12590e0] profile High, level 1b"

Try setting up your profile on baseline or main , which will significantly reduce processor overhead. High mode is for encoding files such as Blu-ray discs.

+1
source

You can remove -vcodec h264 as I see that you mention two video codec -vcodec h264 and again -vcodec copy . And one more thing ffserver does not support mp4 streaming. Try converting it to webm or flv . See Start Streaming Simple mp4 with ffserver

0
source

All Articles