ffmpeg, send camera mjpeg stream over TCP - ffmpeg

I am using a Zavio F-210A camera, and I am able to get its video properly via
http://192.168.X.X/video.mjpg
also, if I use ffmpeg command
ffplay -i "http://192.168.X.X/video.mjpg"
I am able to get the video stream. However, what I would like to to is to create a TCP/UDP socket with same content to another different IP address (lets say 192.168.X.Y). I have tried with
ffmpeg -i "http://192.168.2.91/video.mjpg" -c copy -f mpjpeg "tcp://127.0.0.1:1234?listen"
and when opening with
ffplay tcp://127.0.0.1:1234
It gets one single frame and then it shuts down saying
[mpjpeg # 0x55c36ad25900] Unexpected Content-Type : audio/basic
http://192.168.X.X/video.mjpg: Invalid data found when processing input
my two questions are:
How do I get the stream via ffmpeg and not a single frame with error?
How could I send it to a different IP address?
Thank you

Related

DTS Discontinuity Error while Playing Media File with RTSP Url

I am playing the media file on RTSP by fetching the streams directly from some server. I am getting DTS discontinuity in stream error. I have tried with both FFMPEG and FFPLAY.
FFMPEG
I am using the following ffmpeg command:
ffmpeg -i rtsp://media:123456#10.10.167.20/41415308b3839f2 -f wav test.wav
As an output of this command, I am getting the following error:
FFPLAY
I am using the following ffplay command:
ffplay rtsp://media:123456#10.10.167.20/41415308b3839f2
As an output of this command, I am getting the following error:
Can anyone please tell me that when this error usually occurs? Is there any reason behind this and any workaround for this?
From the libavformat/utils.c, avformat_find_stream_info function:
/* Check for a discontinuity in dts. If the difference in dts
* is more than 1000 times the average packet duration in the
* sequence, we treat it as a discontinuity. */
Also note, that RTP does not define any mechanisms for recovering for packet loss.
So, if you lose packets in such manner that the dts difference between two read packets is more than 1000 times the average packets duration you get foregoing warning.

Using ffserver to do UDP multicast streaming

Here's the deal. I'm working with IPTV hardware and I need to output a bunch of demo streams. These are MPEG2 transport stream that need to be straight up UDP Multicast streams. I have an ffmpeg command that works great:
ffmpeg -re -i /Volumes/Data/DemoVideos/GRAILrpsp.ts -acodec copy -vcodec copy -f mpegts udp://239.192.1.82:12000[ttl=1,buffer_size=2097157]
What I would like to do is convert this into an ffserver config file instead of having to start a whole bunch of ffmpeg streams and then figuring out how to get them to loop. I'm sure I can do it with the right scripting but what a pain, isn't that what ffserver is for? But I can't find any documentation on doing UDP streaming using ffserver. You can set a multicast address and port but it goes to RTP which this hardware isn't designed for. Any help would be greatly appreciated.
At the time of this post, according to the ffserver Documentation it doesn't support MPEG-TS directly in UDP:
ffserver receives prerecorded files or FFM streams from some ffmpeginstance as input, then streams them over RTP/RTSP/HTTP.

Try to find a HLS server stream live?

My goal: Stream a live HLS video in browser.
I have in a folder m3u8 files with some .ts. I can play the m3u8 in browser. But this isn't a live stream.
So i try to find a server to stream a HLS in live.
I work on Linux Ubuntu 14.04.
For example:
input /home/master.m3u8 i would like output http://127.0.0.1/master.m3u8
A flash player in browser play http://127.0.0.1/master.m3u8
Thx
You can use any HTTP server such as Nginx, Apache and others to serve your HLS stream.
To create the actual stream you can use ffmpeg:
ffmpeg -re -i <input> /path/to/web/dir/playlist.m3u8
The -re tells it to read the input file at its native framerate. By default the playlist size is 5 but you can change it using hls_list_size.
For a complete list of parameters see: https://www.ffmpeg.org/ffmpeg-formats.html#hls-1

Video streaming fails over rtp protocol

Video streaming between Unix Server (ffmpeg) and Windows client (vlc) completed without errors.
Server side:
ffmpeg -f v4l2 -r 25 -i /dev/video0 http://192.168.1.114:27018/feed1.ffm
Client side:
vlc player: Media -> Open Network Stream: http://192.168.1.114:27018/test.swf
However, video streaming has approximately 10 s. delay. For this reason, I tried using rtp instead http, but without result. Specifically, on server side I run:
ffmpeg -f v4l2 -r 25 -i /dev/video0 rtp://192.168.1.114:27018/feed1.ffm
After the stream begun, on client side I typed: rtp://#:27018 but it doesn't respond.
What I am missing? Is there any other way I could avoid delay?
Short (incomplete) solution for the problem with the RTP stream:
Setup FFMPEG with the command line:
ffmpeg -f v4l2 -r 25 -i /dev/video0 rtp://<client_ip>:<client_port>
where <client_ip> and <client_port> need to be replaced with the client's IP address and port number, respectively.
Description of the problem with the RTP stream and the solution:
Generally, when setting up an HTTP server (in this case, namely HTTP multimedia server), on the server's side, the local port and the local IP address that the server needs to listen on are specified. So when you set up FFMPEG to stream on http://192.168.1.114:27018/, it probably means that FFMPEG (the server) will listen on its one interface that has the IP 192.168.1.114 and on the port 27018. Then the client needs to connect to http://192.168.1.114:27018 to get the streams.
However, when setting up an RTP FFMPEG server, the client address(es) and port(s) are specified on the server's side, meaning (inaccurately) that the server sends the packets to the desired addresses and the clients need to listen on their ports if they want the available streams. So the FFMPEG server needs to be setup with the URL rtp://<client_ip>:<client_port> and not the URL rtp://<server_ip>:<server_port>, for the <client_ip> to be able to access the stream on his local port <client_port>.
For more info on the FFMPEG's RTP URL format and a starting point for some intriguing concepts in RTP streaming (like multicasting), visit here.

Is it possible to pull a RTMP stream from one server and broadcast it to another?

I essentially have a situation where I need to pull a stream from one Wowza media server and publish it to a Red5 or Flash Media Server instance with FFMPEG. Is there a command to do this? I'm essentially looking for something like this:
while [ true ]; do
ffmpeg -i rtmp://localhost:2000/vod/streamName.flv rtmp://localhost:1935/live/streamName
done
Is this currently possible from FFMPEG? I remembered reading something like this, but I can't remember how exactly to do it.
Yes. An example (pulling from a local server, publishing to a local server):
$ ffmpeg -analyzeduration 0 -i "rtmp://localhost/live/b live=1" -f flv rtmp://localhost:1936/live/c
analyzeduration is to make it start faster. You can also add other parameters in there to "reencode" etc. if desired.
try typing in this way:
$ffmpeg -i "[InputSourceAddress]" -f [Outputfileformat] "[OutputSourceAddress]"
The input source address can be in type rtmp, or rtsp/m3u8/etc.

Resources