capture RTSP stream and forward to RTMP - nginx

I am trying to tunnel RTSP h264 encoded data to nginx RTMP server witth ffmpeg, but its not working
my cmd line:
ffmpeg -y -i rtsp://192.168.1.84:6880/test.264 -c:v copy -an -map 0:0 -f mp4 -rtmp_buffer 100 -rtmp_live live rtmp://localhost/live/streamNam
VLC is able to decode rtsp://192.168.1.84:6880/test.264 fine.. Are there any additional options I can forward to ffmpeg for simple tunneling operation? Right now it stalls for a good amount of time doing probing - how to get rid of that too?

Related

how to get the delay of ffmpeg?

I'm using ffmpeg to do some work on a network like this:
RtmpServer1 -- FfmpegServer -- RtmpServer2
I put a 6mins.mp4 on RtmpServer1(10.10.1.1) and play it on RtmpServer2(10.10.2.2) by this instruction:
ffmpeg -i rtmp://10.10.1.1:1935/play/6mins.mp4 -vcodec copy -c:v libx264 -f flv rtmp://10.10.2.2:1935/live
I would like to know is there a way to test the length of the time ffmpeg use to decode, compress and encode?(the duration from ffmpeg server get the data to the ffmpeg server send it out)
I tried tcpdump to listen on the both two eth ports(one for get and one for send) of ffmpeg server. But I can't match RTMP packets by pairs("pairs" means the packets containing the same data, one "got" packet matches one "sent" packet). I'd also like to know if there's a way to match the RTMP packets by their content(data).
I tried to use tcpdump on both of the input and output eths and get when the rtmp streamings starts and ends. It is helpful in some way.

RTMP proxy to crop original video and send it to another RTMP server

I need to crop the video from an RTMP stream and send it to another RTMP server which always change. My understanding is that I should use nginx-proxy and ffmpeg, can anybody help me on how to set it up?
I suppose that i need to send the stream to an endpoint like /stream/:stream-key/:next-server-ip process the stream with ffmpeg and then send it to the :next-server-ip, what language should I use in the backend for this?
There are 2 strategies for processing such task:
"Pull"
You have some published rtmp stream and use ffmpeg to pull it, convert and send result to another server:
ffmpeg -i rtmp://source-server/stream -filter:v "crop=out_w:out_h:x:y" -vcodec h264 -acodec copy -f flv rtmp://next-server/stream
"Push"
RTMP stream is pushed to your server which processes it and sends result to another server. For such task you can use nginx-rtmp module for nginx and setup ffmpeg command using exec_push directive:
application src {
live on;
exec_push ffmpeg -i rtmp://localhost/src/$name -filter:v "crop=out_w:out_h:x:y" -vcodec h264 -acodec copy -f flv rtmp://next-server/stream 2>>/var/log/ffmpeg-$name.log;
}
When someone start to stream to rtmp://your-server/src/stream_name this ffmpeg command will be executed and the processing will begin
For additional information about video cropping and related ffmpeg parameters see https://video.stackexchange.com/a/4571

how to play nginx & rtmp based hls live stream on a remote machine

I have installed nginx, rtmp and ffmpeg based hls live streaming working on ubuntu machine. I use this command to stream hls
sudo ffmpeg -re -i sample.mp4 -vcodec libx264 -vprofile high -g 30 -acodec aac -strict -2 -f flv rtmp://localhost/show/stream2
when I try to play this stream using VLC using following commands on the same machine it works well.
http://myIp:8080/hls/stream2.m3u8
or
http://localhost:8080/hls/stream2.m3u8
However when I try to access from remote computer connected to same WIFI, not able to play. VLC gives an error that unable to play the file.
Solution to this problem has to be in two places
1. open ports in ufw
2. enable pings in home router

Using ffmpeg to transcode/transmux HLS to RTMP for nginx simulcast not working

I want to take an HLS stream and transcode it to RTMP and simulcast it with the nginx RTMP module.
It's not working, however (I have it placed in the application section of the RTMP module).
exec ffmpeg -i -re http://<HLS>.m3u8 -acodec aac -vcodec libx264 -f flv rtmp://localhost/live/test;
When I try to view my RTMP stream in VLC, it is not loading. I have tried several variations of that ffmpeg directive, none have worked. Any advice? If you need to see more of my config file, I can provide that, but this server has been working previously perfectly when sending video over via a Teradek encoder. This new wrinkle is just not working.
EDIT: Just had a thought. It’d probably help to have the codec information of the incoming HLS stream. Here it is:
Video Codec: H264 - MPEG-4 AVC
Resolution: 640x360
Frame rate: 24
Decoded format: Planar 4:2:0 YUV
Audio Codec: MPEG AAC Audio (mp4a)
Channels: Stereo
Sample rate:48000Hz
If you run in terminal
ffmpeg -i -re http://<HLS>.m3u8 -acodec aac -vcodec libx264 -f flv rtmp://localhost/live/test;
are you able to play the stream in VLC?

Detect Live streaming stopped and resume in nginx

I'm trying to use Nginx to do live stream to combine two stream into one, so I need to spawn FFMpeg, like so
ffmpeg -i "rtmp://in/1" -i "rtmp://in/2" -filter_complex "overlay=70:50" -vcodec libx264 -preset ultrafast -f flv rtmp://out
However, is there a way to detect if one of the incoming stream drops, and I can continue the stream? From what I'm reading, it is not possible, and ffmpeg task will be killed.

Resources