Stream from file .avi - Nginx + Rtmp - nginx

I want stream to rtmp server. I try:
ffmpeg.exe -f dshow -i "myvideo.avi" -s 480x288 -r 10 -vcodec libx264 -b:v 30k -pix_fmt yuv420p -acodec libvo_aacenc -ac 1 -b:a 4k -f flv rtmp://ip/live/test
And did not work... Error:
http://i.stack.imgur.com/06Rcf.png
how to do? Thx

Related

End FFMPEG execution when RTMP input is closed

I have an RTMP arut server inside which I call a python script to run an FFMPEG command and create HLS packaging.
Problem is that when I stop the RTMP stream, FFMPEG still run processes in background.
FFMPEG string is like this:
ffmpeg -re -v verbose -i rtmp://localhost:1935/live/testlive -rw_timeout 500 -http_persistent 1 -method PUT -http_user_agent test -f hls -hls_list_size 5 -hls_flags discont_start+delete_segments -vf "scale=426:trunc(ow/a/2)*2" -c:a libfdk_aac -ar 48000 -c:v h264 -profile:v main -crf 24 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type event -preset veryfast -b:v 300k -maxrate 856k -bufsize 1200k -b:a 128k -vcodec libx264 -hls_segment_filename http://mystream/123/v1/testlive/0_%03d.ts http://mystream/123/v1/testlive/index.m3u8
The RTMP server should send an NetStream.Play.Stop event to subscribers (or disconnect them) to signal end of stream. If you are using the nginx rtmp module, look at the play_restart or idle_streams directives.

I can't use libx265 or hevc with ffmpeg in nginx

exec_push /usr/bin/ffmpeg -re -i rtmp://10.254.20.186:1935/$app/$name ar 44100 -vcodec libx264 -g 25 -f flv rtmp://10.254.20.186/live/$name_hi;
I can use this code in my nginx server. this is code running but dont run while write libx264 instead libx265.
The interesting thing is that I can run the following commands on my linux computer without problems.
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -c:a aac -b:a 128k output.mp4
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -c:a aac -b:a 128k output.mp4
ffmpeg -i input.mp4 -c:v hevc -crf 28 -c:a aac -b:a 128k output264tt.mp4
ffmpeg -i input.mp4 -c:v h264 -crf 28 -c:a aac -b:a 128k output264tt.mp4

Can't livestream with FFmpeg on Nginx?

I am trying to livestream through RTMP on FFmpeg in Nginx. Doing sudo ffmpeg -re -f video4linux2 -i test.mp4 -vcodec libx264 -vprofile baseline -acodec aac -strict -2 -f flv rtmp://localhost/show/stream gives me ioctl(VIDIOC_QUERYCAP): Inappropriate ioctl for device
test.mp4: Inappropriate ioctl for device
Am I even doing this right?

watermark on transcoding rtmp video nginx

Hello i am transcoding video with rtmp and i want to put some text...i put Arial.ttf in my home directory of the server but doesnt work.. this is my command..
-map 0:0 -map 0:1 -strict -2 -crf 26 -vcodec libx264 -preset superfast
-acodec aac -b:a 128k -vf scale=-1:720 -aspect 16:9 -g 50 -r 30 -ar 48000
-ac 2 -vf drawtext="fontfile=/home/Arial.ttf: text='TEXT': fontcolor=white: fontsize=24: box=1: boxcolor=black: x=10:y=10"
-f flv
can someone help me please?
thanks
Make sure you include absolute path to font and file is there:
drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:
text='Test Text': x=100: y=50: fontsize=24: fontcolor=yellow#0.2:
box=1: boxcolor=red#0.2"
Redirect output to a log file and see if command outputs any errors.
You can also include a watermark image instead:
-i /path/to/watermark.png -filter_complex "overlay=main_w-overlay_w-4:4"

Use FFMPEG to restream RTMP source to YouTube - no video stream in output

I am attempting to grab the .m3u8 file from an nginx-rtmp server and pass it along to YouTube rtmp. I believe this to be possible (for example here: https://stackoverflow.com/a/11978820/1552594 although this is on the same host). The command I am using is:
ffmpeg -analyzeduration 0 -i \
http://source.rtmp.server/hls/stream.m3u8 -pix_fmt yuv420p \
-f flv rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx
However the output contains only audio and YouTube doesn't like it. The command produces following:
As you can see no Video stream in output metadata, stream mapping shows only audio and the trace shows 0kb of Video for 651kb of Audio
Any help much appreciated
MORE INFO
Improved version of the command lifted from this article:
https://judge2020.com/restreaming-a-m3u8-hls-stream-to-youtube-using-ffmpeg/
"Restreaming a m3u8 HLS stream to Youtube using FFMPEG" AKA exactly what I am trying to do.
The command I am sending is now:
ffmpeg -re -i "http://source.rtmp.server/hls/stream.m3u8" \
-strict -2 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -flags \
+global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv \
"rtmp://a.rtmp.youtube.com/live2/xxx-xxxx-xxxx-xxxx"
I got pretty much exactly the same response except with the Audio being read and output using aac codec.
MORE MORE INFO
I have found that adding a mapping can force the video stream into the output:
ffmpeg -re -i "http://source.rtmp.server/hls/stream.m3u8" \
-strict -2 -c:v copy -c:a -map 0:0 -map 0:1 -ar 44100 -ab 128k -ac 2 \
-flags +global_header -bsf:a aac_adtstoasc -bufsize 1000k \
-f flv "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx"
This throws up the error that has presumably been resulting in the video stream being silently dropped:
Finally worked it out. The last issue above was a red herring and was due to missing a codec argument for the audio -c:a.
The complete working command is as follows:
ffmpeg -probesize 100M -analyzeduration 20M -re \
-i "http://source.rtmp.server/hls/stream.m3u8" -strict -2 -c:v \
libx264 -pix_fmt yuv420p -c:a aac -map 0:0 -map 0:1 -ar 44100 \
-ab 128k -ac 2 -b:v 2567k -flags +global_header -bsf:a aac_adtstoasc \
-bufsize 1000k -f flv "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx"
The important parts are -probesize and -analyeduration - these need tweaking until they work. The -re flag is important to indicate restreaming. The various video codec declarations are also important - -c:v libx264 -pix_fmt yuv420p or it will throw errors about the output size being 0x0. Finally the map flags ensure that both streams are included in the output: -map 0:0 -map 0:1

Resources