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.
Related
We have an NGINX RMTP module installed and while testing the same we came to know that the bitrate for the output was a around 7Mbps irrespective of the input stream's bitrate and as we have a lot of people watching these streams I would like to know how to reduce the same to about 4Mbps for this module?
Also, does NGNIX's RTMP module support H.265 instead of the standard H.264 which can help set the bitrate to about 2Mbps.
You can transcode the incoming rtmp stream with ffmpeg with maxrate & b:v in this case you can control the maximum bitrate. Here is a simple example(for this example use another app show as well):
application live {
live on;
exec_push ffmpeg -i rtmp://localhost/$app/$name -async 1 -vsync -1
-c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2000k -maxrate 3000k -f flv -preset superfast -profile:v baseline rtmp://localhost:1935/show/$name_with_maxrate
}
I've been trying to make a mosaic of two rtmp streams and resend it to Twitch, i´m using a nginx with a rtmp module and ffmpeg. I've come out with this but doesnt work:
exec /usr/bin/ffmpeg - report -i rtmp://localhost/app/input -i rtmp://localhost/app/input -filter_complex "[0:v]scale=480:-1,setsar=1[l];[1:v]scale=480:-1,setsar=1[r];[l][r]hstack;[0:a][1:a]amerge=inputs=2[a]" -map v -map "[a]" -c:v libx264 -preset veryfast -ar 44100 -f flv rtmp://live-mia.twitch.tv/app/xxxxxxxxxx
The report shows an endless loop
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
how do I get this stream working?
At last, this the code I' been able to make work
exec /usr/bin/ffmpeg - report -i rtmp://localhost/app/input -i rtmp://localhost/app/input2 -filter_complex "[0:v]scale=480:-1,setsar=1[l];[1:v]scale=480:-1,setsar=1[r];[l][r]hstack[v];[0:a][1:a]amerge=inputs=2[a]" -map "[v]" -map "[a]" -c:v libx264 -preset veryfast -ac 2 -f flv rtmp://live-mia.twitch.tv/app/xxxxxxxxxx
It must be re-encoded the stream in order to Twitch been able to shown it. Also , as im runing ffmpeg in a nginx, the nginx's user must have root permissions.
I am working on an adaptive HLS solution using Nginx RTMP module as a streaming server and VideoJs as a client. I have completed the setup i.e. NGINX configurations and client sample in VideoJs.
NGINX Configurations:
nginx.txt
I am using this Ffmpeg command to generate stream:
ffmpeg -re -i /home/user/Downloads/test.mp4 -vcodec libx264 -vprofile baseline -g 30 -acodec aac -strict -2 -f flv rtmp://192.168.1.68/live
My problem is that sometimes the Nginx does not generate .ts and .m3u8 files in /tmp/hls directory when I issue the above ffmpeg command. I have also enabled the nginx-rtmp module logs but they are only giving me access information and I am not getting any logs in error logs.
Do let me know if more information is required. Any help will be appreciated.
Thanks,
I'm using ffmpeg for transcoding my videos on my servers.
Some times ffmpeg carshes in transode during, and that process stalled on task manager and it used ram,but not consumed cpu(it seems ffmpeg crashed).
1- Is there any solution for knowing that how can I manage this process on my servers?
2- Must be handle that from web server side or can I manage it from ffmpeg side?
I mean, ffmpeg has there any property for when transcoding take a long time,that stops.
Or Can I handle this from server side(iis recycling stops the process in run time transcoding, i don't want to use that, maybe I'm wrong, just help me).
What is the best solution ?
I used this code for example:
ffmpeg -i kata.mp4 -filter_complex
[0:v]drawtext=fontfile=OpenSansRegular.ttf:text=localhost/Parsa:fontcolor
=white:r=25:box=1:boxcolor=black#0.3:boxborderw=3:fontsize=15:x=15:y=(h-text_h-
15)[v];[v]split=4[s0][s1][s2][s3];[s0]scale=hd720[v0];[s1]scale=hd480[v1];
[s2]scale=nhd[v2];[s3]scale=cga[v3] -map [v0] -map [v1] -map [v2] -map [v3] -map
a? -c:v libx264 -c:a aac -f tee -g 48 -threads 0 "
[select='v\:0,a':f=hls:hls_list_size=0]../video/720p/out.m3u8|
[select='v\:1,a':f=hls:hls_list_size=0]../video/480p/out.m3u8|
[select='v\:2,a':f=hls:hls_list_size=0]../video/360p/out.m3u8|
[select='v\:3,a':f=hls:hls_list_size=0]../video/200p/out.m3u8"
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?