I've a C920 HD camera connected to a Raspberry Pi 4 and my goal is to be able to access a stream of that camera anytime from my phone / laptop both connected to my network with a VPN.
Now, I managed to use ffmpeg like this:
ffmpeg -f v4l2 -input_format h264 \
-video_size 1920x1080 \
-i /dev/video4 \
-copyinkf -codec copy \
-f mpegts udp://192.168.1.10:5000?pkt_size=1316
On the computer 192.168.1.10 I can launch VLC go into "Network Transmission" and type udp://#:5000 in oder to watch the stream.
This is a single stream and from what I understand my RPi is just "shooting" the frames at that computer whatever it is connected or not, how can I have a proper stream (maybe rtmp?) that I can watch in multiple devices?
Please note: I'm using -copyinkf -codec copy in order to avoid transcoding and other operations that might result in a very high CPU usage. Can I do it this way also?
Thank you.
Nginx can be configured to host an RTMP video stream that will be used to play the stream coming from ffmpeg in all my devices. For this we need to install libnginx-mod-rtmp and configure nginx for RTMP:
apt install libnginx-mod-rtmp
Append the following to /etc/nginx/nginx.conf:
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 127.0.0.1;
deny publish all;
application live {
live on;
record off;
}
}
}
systemctl restart nginx
Point ffmpeg to the nginx server:
ffmpeg -f v4l2 -input_format h264 \
-video_size 1920x1080 \
-i /dev/video4 \
-copyinkf -codec copy \
-f flv rtmp://127.0.0.1/live/stream
I also changed the output format to flv in order to improve compatibility with players.
Enjoy.
Related
I am trying to stream a video called "bbb.mp4" with ffmpeg and visualize it with VLC.
On the OS X Terminal, I do the following:
ffmpeg -re -i bbb.mp4 -an -c:v copy -f mpegts udp://#127.0.0.1:2222
I am video streaming it on the IP address 127.0.0.1 using the port 2222. Once I run this, it shows that it is streaming the video:
But when I visualize it using VLC by going File > Open Network... > Network:
I cannot see anything, even though the code is running in the Terminal:
It does not open. Do you know if I am doing anything wrong?
Try adding packet_size at the end. For example:
ffmpeg -re -i bbb.mp4 -an -c:v copy -f mpegts udp://127.0.0.1:2222?pkt_size=1316
And of course, at VLC:
udp://127.0.0.1:2222?pkt_size=1316
Iam trying to capture video from Panasonic DC-GH5 camera to serve this and access from browser withoud ffserver because ffserver is deprecated
Iam using Ubuntu 20.04
#gphoto2 -v
gphoto2 2.5.23 gcc, popt(m), exif, cdk, aa, jpeg, readline
libgphoto2 2.5.25 standard camlibs (SKIPPING lumix), gcc, ltdl, EXIF
libgphoto2_port 0.12.0 iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, EXIF, USB, serial without locking
Iam try this code
ffmpeg -f video4linux2 -s 640x480 -r 30 -i /dev/video0 -thread_queue_size 512 -ac 1 -f alsa -i pulse -f webm -listen 1 -seekable 0 -multiple_requests 1 http://localhost:8090
and embed
<video src="http://localhost:8090"></video>
in index.php but don`t appear anything.
If anyone knows a way to make a server for a specific port I would appreciate it
Thank you.
I use nginx rtmp and followig command:
ffmpeg -fflags +igndts -hide_banner -i https://ch.iptvmate.net/ec6e5689ffd6f9690102640bddd2f9e7.m3u8 -c copy -f hls -hls_time 4 -hls_flags append_list+delete_segments -hls_list_size 6 -hls_segment_filename 'hls/ch2/file%03d.ts' hls/ch2/playlist.m3u8
It streams but not live, it has recorded one period of the channel and this link streams this period again and again. Is the command correct? I just created the folder called ch2 and it is.
If you are trying to push stream as rtmp, HLS parameters are not required.
Simple way to re-stream via rtmp into nginx:
ffmpeg -fflags +igndts -hide_banner -i https://ch.iptvmate.net/ec6e5689ffd6f9690102640bddd2f9e7.m3u8 -c copy -f flv rtmp://127.0.0.1/live/stream
Afterwards, you can configure your live block in Nginx to have HLS.
application live {
live on;
hls on;
hls_path /tmp/hls;
}
Eventually, you would like to have chunks over HTTP:
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
Try http://127.0.0.1/hls/stream.m3u8 when configuration is successful and ffmpeg is running.
We're using a Raspicam to stream live video to a client using Wowza Streaming Engine. We use FFMPEG to encode and send to Wowza and we can succesfully watch the RTMP stream using JWPlayer. This is the FFMPEG command used:
ffmpeg -t 0 -s 320x240 -f video4linux2 -i /dev/video0 -b:v 250k -tune zerolatency -preset ultrafast -f flv -r 15 rtmp://wowzaaddress:1935/live/live
To be able to watch the stream on mobile devices we want to use RTSP or HLS which Wowza provides links to, however when we use those links (provided on the Test Player) nothing happens and we can't even open them to test for example in VLC. We have already added the extra ports on our web server to see if that was the problem and still didn't work.
Does anybody know what the problem is or what could we be doing wrong?
So I have a (live)video stream on udp://10.5.5.100:8463 and I copy it to udp://localhost:1000.
ffmpeg -f mpegts -i "udp://10.5.5.100:8554?fifo_size=10000" -f mpegts -vcodec copy udp://localhost:1000/go
And it works fine in VLC but Wirecast doesn't accept udp://..., but it accepts rtsp://...
but I don't now much about ffmpeg, so I only changed udp to rtsp
ffmpeg -f mpegts -i "udp://10.5.5.100:8554?fifo_size=10000" -f mpegts -vcodec copy rtsp://localhost:1000/go
But it doesn't work and outputs this
rtsp://localhost:1000/go: Protocol not found
Thank you for answers!!
If you put '-f rtsp' instead of '-f mpegts' ffmpeg will try to establish connection to this url.
Proper solution with ffmpeg suite will be complex and include 'ffserver' as rtsp server and 'ffmpeg' as media stream source for the ffserver.
Much more simpler solution is to try vlc:
cvlc -vvv udp://10.5.5.100:8554?fifo_size=10000 --sout '#rtp{sdp=rtsp://localhost:1000/go}'
It starts RTSP server on localhost:1000 and retransmits data from UDP to the clients connected to this RTSP server.