Streaming raspberry pi camera via nginx-rtmp - nginx

I have compiled nginx with rtmp, and I'm trying to use to it stream a raspberry pi camera over the network. I've done a lot of googling, and there are a lot of approaches, but none seem to work for me. So far, I have this:
rtmp {
server {
listen 1935;
chunk_size 4096;
application rtmp {
live on;
record off;
exec_static /usr/bin/ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 30 -i /dev/video0 -vcodec copy rtmp://localhost/rtmp 2>>/home/pi/test.log
}
}
}
I would have expected the stream from the camera to be available on rtmp://pi_ip/rtmp, but instead, the log file reports:
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 12021.310578, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, 30 fps, 30 tbr, 1000k tbn, 2000k tbc
[NULL # 0x1ca35d0] Unable to find a suitable output format for 'rtmp://localhost/rtmp'
rtmp://localhost/rtmp: Invalid argument
Presumably there is something wrong with ffmpeg command, but I have no idea what it is.

Related

ffmpeg stream ip cam from rtsp to http

I'm trying to restream ip camera from home network to webpage (sort of video player in wordpress). I have rtsp url of camera and i want to have an output in http. It's bothering me for 2 days now and i'm not sure what i'm missing...
My ffserver.conf file:
HTTPPort 8090 # Port to bind the server to
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000 # Maximum bandwidth per client
RTSPPort 8002
# set this high enough to exceed stream bitrate
CustomLog -
<Feed cam.ffm>
File /tmp/cam.ffm
FileMaxSize 10G
ACL allow 192.168.0.0 192.168.255.255
</Feed>
<Stream cam.mpg>
Feed cam.ffm
Format mpeg
VideoCodec libx264
VideoSize 1280x720
VideoFrameRate 6
VideoBufferSize 40
AVOptionVideo flags +global_header
PreRoll 15
StartSendOnKey
VideoBitRate 4096
NoAudio
</Stream>
<Stream status.html> # Server status URL
Format status
# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>
<Redirect index.html> # Just an URL redirect for index
# Redirect index.html to the appropriate site
URL url/
</Redirect>
When i enter ffserver -f /etc/ffserver.conf, i get:
root#test:/tmp# ffserver -f /etc/ffserver.conf
ffserver version 2.6.9 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-vaapi --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
/etc/ffserver.conf:30: Setting default value for video bit rate tolerance = 1024000. Use NoDefaults to disable it.
/etc/ffserver.conf:30: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
/etc/ffserver.conf:30: Setting default value for video max rate = 8192000. Use NoDefaults to disable it.
Wed Mar 15 20:23:41 2017 FFserver started.
and when i enter ffmpeg -i rtsp://<ip of camera>:8002 http://<ip of this machine-server>:8090/cam.ffm, happens nothing.
I can also reach http://<ip of my server>:8090/status.html, but no luck with http://<ip of my server>:8090/cam.mpg.
Any suggestions?
Thank you!

Fail to get the statistics of https video using ffprobe

I want to collect the statistics of a video stream backed by https url.
on executing
ffprobe https://www.youtube.com/watch?v=YbYjtSFa5Fs
I get the following output
vagrant#kaybus:/vagrant/kaybus$ ffprobe https://www.youtube.com/watch?v=YbYjtSFa5Fs
ffprobe version N-80901-gfebc862 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
[tls # 0x3547140] A TLS packet with unexpected length was received.
https://www.youtube.com/watch?v=YbYjtSFa5Fs: Input/output error
[tls # 0x3547140] A TLS packet with unexpected length was received.
How to fix the above error?
https is listed in ffprobe's supported input and output protocols.
ffprobe -version
vagrant#kaybus:/vagrant/kaybus$ ffprobe -version
ffprobe version N-80901-gfebc862 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
Thanks
Your URL is a typical web site: it is not a direct link to a video. ffprobe supports HTTP(S), but it is not an HTML parser.

blur an mp4 video for website background

I am putting a video in the background of my web page. I want to blur the background for which I tried to put the following attribute in video tag:
<video -webkit-filter: blur(15px); -moz-filter: blur(15px);-o-filter: blur(15px);-ms-filter: blur(15px);filter: blur(15px);">
the video runs very slow due to blurring the background within HTML.
So, now I am trying to blur the original video. I tried to use ffmpeg (here):
ffmpeg -i input.avi -vf "boxblur=enable='between(t,start,end)'" -codec:a copy output.avi
But the filter used in ffmpeg seems to be deprecated. I have tried few filters of "avconv", but no filter seems to "blur" the video.
Please let me know if there is any other command line tool which I can use for this purpose or even if I am missing any filter in ffmpeg or avconv.
UPDATE: Console output for ffmpeg:
ffmpeg -i output.mp4 -vf "boxblur=enable='between(t,0,15)'" -codec:a copy output1.mp4
ffmpeg version 2.8.3 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --disable-yasm
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2015-04-08 13:38:10
encoder : Lavf54.20.4
Duration: 00:00:29.40, start: 0.000000, bitrate: 1909 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1024x1024 [SAR 16:9 DAR 16:9], 1905 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2015-04-08 13:38:10
handler_name : VideoHandler
[AVFilterGraph # 0x1db5140] No such filter: 'boxblur'
GPL
The boxblur filter license is GPL, so that requires ffmpeg to be compiled with the --enable-gpl configure option. Recompile, or just download a static build.
Alternative filters
Alternatively, you could use a different filter such as sab, smartblur, or unsharp.
Other stuff
Since the video is for the web, consider adding -movflags +faststart as an output option so the video may begin playback before it is completely downloaded by the viewer. You may also increase the -crf value (default 23), because it will be blurred you can probably use a lower quality.

ffmpeg udp live stream publish to rtmp

I need to make this chain:
JVC HM650--UDP-->localhost-->ffmpeg(copy stream)-->nginx-rtmp
On input I have UDP stream from camera (udp://#:35501) and I need it to publish to rtmp server (nginx with rtmp module). Apart everything works - I can play input on VLC, I can stream from FMLE to nginx etc. Except, this is my first time with ffmpeg and I can't get it work. So:
This is best i have got:
C:\ffmpeg\bin>ffmpeg -re -i udp://#:35501 -f flv "rtmp://192.168.1.17/live/live" -loglevel debug
ffmpeg version N-69972-g6c91afe Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnu
tls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-l
ibrtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --ena
ble-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 19.100 / 54. 19.100
libavcodec 56. 25.100 / 56. 25.100
libavformat 56. 23.100 / 56. 23.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.100 / 5. 11.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Splitting the commandline.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input file with argument 'udp://#:35501'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'rtmp://192.168.1.17/live/live' ... matched as output file.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
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 file udp://#:35501.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: udp://#:35501.
[udp # 0000000002c30760] end receive buffer size reported is 65536
[AVIOContext # 0000000002c513c0] Statistics: 0 bytes read, 0 seeks
udp://#:35501: Immediate exit requested
Received signal 2: terminating.
C:\ffmpeg\bin>
What is wrong with ffmpeg configuration?
SOLUTION:
The ffmpeg was listening on wrong version of UDP protocol:
Even IPv6 is disabled on network cards, internally in system, using # allowed ffmpeg listen at UDPv6.
By using 127.0.0.1 tells ffmpeg to use clean UDP.
Thanks, #thomas to make me think differently!
It seems that your ffmpeg command is right, it works for me. For information here is the output resulting in a well configured udp connection :
...
Opening an input file: udp://#:35501.
[udp # 0x2058c80] end receive buffer size reported is 131072
[flv # 0x20631a0] Format flv probed with size=2048 and score=100
[flv # 0x20631a0] Before avformat_find_stream_info() pos: 13 bytes read:2099 seeks:0
[flv # 0x20631a0] max_analyze_duration 5000000 reached at 5016000 microseconds
rfps: 29.916667 0.015099
rfps: 30.000000 0.000067
Last message repeated 1 times
rfps: 60.000000 0.000267
Last message repeated 1 times
rfps: 120.000000 0.001067
Last message repeated 1 times
rfps: 240.000000 0.004267
rfps: 29.970030 0.002007
rfps: 59.940060 0.008027
[flv # 0x20631a0] After avformat_find_stream_info() pos: 12110 bytes read:12110 seeks:0 frames:154
Input #0, flv, from 'udp://#:35501':
Metadata:
AspectRatioX : 1
AspectRatioY : 1
metadatacreator : GStreamer FLV muxer
creationdate : Mon Feb 23 6:51:54 2015
Duration: N/A, start: 0.002000, bitrate: N/A
Stream #0:0, 154, 1/1000: Video: h264 (High), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 1/60, 30.30 fps, 30 tbr, 1k tbn, 60 tbc
Successfully opened the file.
Parsing a group of options: output file rtmp://192.168.0.20/live/live.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: rtmp://192.168.0.20/live/live.
...
It means that your incoming stream is not well configured. Are you sure that your camera is streaming to the right protocol (udp), address (ip of the ffmpeg host) and port (35501)?
Maybe if you don't have it I have found the manual of your camera here : http://pro.jvc.com/pro/attributes/CAMERA/manual/GY-HM650U_V2.pdf (live streaming p.166)
I hope it will help!

gdcl multiplexer create file with raw video not h264

i have created one graph as per below (i am using osprey card for input live stream)
(graphedit tool)
Osprey analog video in ----> GDCL MPEG-4 mulitplexer ----> File Writer (.mp4 file)
filesize is very big; even 5 seconds file have 80 mb size.
file doesn't get played.
when i see file detail in ffmpeg with ffmpeg -i,
it will give error like stream 0, missing mandatory atoms, broken header
below is ffmpeg response.
ffmpeg.exe -i "C:\Documents and Setti
ngs\Administrator\Desktop\mp4file\mp4file.mp4"
ffmpeg version N-38938-ge01f478 Copyright (c) 2000-2012 the FFmpeg developers
built on Mar 19 2012 23:18:25 with gcc 4.6.2
configuration: --disable-static --enable-shared --enable-gpl --enable-version3
--disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzli
b --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-l
ibrtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-li
bvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-l
ibx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 51. 42.100 / 51. 42.100
libavcodec 54. 12.100 / 54. 12.100
libavformat 54. 2.100 / 54. 2.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 65.101 / 2. 65.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 7.100 / 0. 7.100
libpostproc 52. 0.100 / 52. 0.100
[mov,mp4,m4a,3gp,3g2,mj2 # 003E28E0] stream 0, missing mandatory atoms, broken h
eader
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Documents and Settings\Administrator
\Desktop\mp4file\mp4file.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isom
Duration: 00:00:00.00, bitrate: -2147483 kb/s
Stream #0:0(eng): Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 90k
tbr, 90k tbn, 90k tbc
Metadata:
handler_name :
At least one output file must be specified
do i need to make any gdcl filter settings?
please help me to solve problem.
A multiplexer is used to multiplex different streams into a single file. Most of the time this will be an audio and a video stream. But a multiplexer does not encode audio or video. If you need h.264 video, you need to add a h264 encoder to the graph. For example you can use ffdshow for that.
See also wikipedia for the mp4 file format, H.264 video compression format, and other parts of mpeg4.
If you really mean to create an uncompressed .mp4 file, take a look at the official supported formats for .mp4. Uncompressed video is probably not officially supported. But even if it is, you also need support from both the multiplexer as the player. On his website Geraint Davies has added the following note:
Note: both mux and demux filters need a small amount of code added for
each media type that is to be supported. So far I have only added a
limited set of types. If you need other types to be accepted, please
get in touch directly It's likely that only a few lines of code will
be needed.
It is probably better to use MXF for uncompressed video.

Resources