I'm using ffmpeg to do RTSP to RTMP streaming, the input is an sdp file describing one video stream and one audio stream, when I test the RTSP using ffplay,it works fine
ffplay -protocol_whitelist "file,udp,rtp" -strict -2 -i media.sdp
but when I switch to ffmpeg to do streaming, I got lot of packet missing errors
ffmpeg -protocol_whitelist "file,udp,rtp" -strict -2 -i media.sdp -c copy -f flv "rtmp://liveaddress"
error log:
[sdp # 000001f1f4cea400] max delay reached. need to consume packet
[sdp # 000001f1f4cea400] RTP: missed 321 packets
[sdp # 000001f1f4cea400] max delay reached. need to consume
[sdp # 000001f1f4cea400] RTP: missed 14 packets
[sdp # 000001f1f4cea400] max delay reached. need to consume packet
[sdp # 000001f1f4cea400] RTP: missed 7 packets
the sdp file:
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 58.12.100
m=video 5555 RTP/AVP 96
c=IN IP4 127.0.0.1
b=AS:2000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LAINoBQBbsBagICAoAAAfSAAOpgR4wZUA=,aM4fIA==; profile-level-id=42c020
m=audio 6666 RTP/AVP 96
c=IN IP4 127.0.0.1
b=AS:125
a=rtpmap:96 MPEG4-GENERIC/44100/2
a=fmtp:96 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1210
After some research on the web, I have found a solution:
add a -buffer_size command arg to ffmpeg cause my H264 video from RTSP server has variable bit rate I guess.
I had a similar problem, solved with -rtsp_transport tcp -protocol_whiteliste rtp,file,udp,tcp
Related
Is there any command line options that I can use to tell ffplay the video stream format of the RTP stream?
With a simple SDP file like bellow, I can play the stream very well.
c=IN IP4 0.0.0.0
m=video 9170 RTP/AVP 96
a=rtpmap:96 H264/90000
I'm already searching for a solution for several days how to convert an MJPEG rtp stream to MP4 rtp stream.
Already tried something like this:
ffmpeg -i rtsp://192.168.10.8:554/stream1/mobotix.mjpeg -rtsp_transport tcp -f H264 udp://192.168.10.5:8554
ffmpeg then shows me like it's doing something...
frame= 612 fps= 11 q=25.0 size= 3243kB time=00:00:56.00 bitrate= 474.4kbits/s dup=275 drop=0 speed=0.981x
Then I tried with VLC to open udp://192.168.10.5:8554
but it opens nothing simply the bar is running left/right forever.
Do I need something like Simple RTP-Server (https://github.com/ossrs/srs) and then stream to that?
Best would be, when ffmpeg could host rtp itself...
Here is what I used to stream a local mkv to RTP
ffmpeg -re -thread_queue_size 4 -i input.mkv -strict -2 -vcodec copy -an -f rtp rtp://127.0.0.1:6005 -acodec copy -vn -sdp_file my_sdp_file -f rtp rtp://127.0.0.1:7005
I then had to copy the generated sdp file to the client and used ffmpeg to save the stream to disk
ffmpeg -protocol_whitelist "file,rtp,udp" -i my_sdp_file -strict -2 saved_rtp_stream.mp4
For completeness, here are the contents of the sdp file
$ cat my_sdp_file
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 57.83.100
m=video 6005 RTP/AVP 96
c=IN IP4 127.0.0.1
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z01AHuiAWh7f+AEAANiAAAH0gABdwHAwABAFgABVc0lGAPFi0SA=,aOvssg==; profile-level-id=4D401E
m=audio 7005 RTP/AVP 97
c=IN IP4 127.0.0.1
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1190
I need some help getting ffplay to receive and decode a Real Time stream encoded in h264.
I'm trying to make a point-to-point stream between computer A receiving video frames from a Kinect and computer B running ffplay to show the livestream.
These are the commands I'm running on both computers.
Computer A (RPI 3)
ffmpeg -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 640x480 -i - -threads 4 -preset ultrafast -codec:v libx2 64 -an -f rtp rtp://192.168.0.100:2000
This is what ffmpeg outputs:
fps= 14 q=12.0 size=856kB time=00:00:05.56 bitrate=1261.4kbits/s speed=0.54x
The out stream runs in between 10-20 frames. It's not good, but I can work with that.
Computer B
ffplay -protocol_whitelist "file,udp,rtp" -probesize 32 -sync ext -i streaming.sdp
streaming.sdp
v=0
0=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.0.100
t=0 0
a=tool:libavformat 57.56.100
m=video 2000 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
I'm getting the stream, but at about 0.0001fps which is clearly bad. My guess is I'm missing something on the ffplay command, since ffmpeg shows a more stable and fast stream, but I can't seem to find what I'm missing.
The problem wasn't on ffmpeg, but on the code I wrote that was grabbing the data from the device. I was receiving the same frame multiple times, and blocking the thread capturing data, making most of the frames a duplicate of the first one.
i am trying to stream and receive my webcam feed on two terminal on same laptop.For this purpose I am using the following commands:-
foo.sdp:
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 55.2.100
m=video 1235 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
Transmitting:
ffmpeg -re -i /dev/video0 -r 24 -b 50k -s 858x500 -f mulaw -f rtp rtp://127.0.0.1:3000> foo.sdp
Receiving:
ffplay -i foo.sdp
While transmission seems to be working fine , but when i am using receiving command I am getting en error :
Protocol not on whitelist 'file,crypto'!/0
foo.sdp: Invalid data found when processing input
try add
-protocol_whitelist file,udp,rtp
https://www.ffmpeg.org/ffmpeg-protocols.html#Protocol-Options
https://lists.ffmpeg.org/pipermail/ffmpeg-user/2016-February/030853.html
I have a rtp live stream whit h.254 video, I want to copy it to file I use:
avconv -i rtp://#192.168.0.34:60005 -an -acodec copy -vcodec copy abc.mp4
But I have an error:
[rtp # 0x1f6cfe0] Unable to receive RTP payload type 96 without an SDP file describing it
That's ok, because avconv don't know what is inside.
My sdp file:
v=0
o=- 20966096445 1 IN IP4 0.0.0.0
t=0 0
a=type:broadcast
a=control:*
a=x-qt-text-nam:brovotech
a=x-qt-text-inf:live/sub
a=range:npt=0-
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:8
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4d001e;sprop-parameter-sets=Z00AHpWoLASZ,aO48gA==
How can I attach sdp file for FFmpeg? Or set some arguments that will describe the stream?
Just use avconv -i camera.sdp
camera.sdp:
...
o=- 20966096445 1 IN IP4 my_ip
...
m=video my_port RTP/AVP 96