I've been using ffmpeg to stream m3u8 files to twitch, and similar platforms,
through this script:
#! /bin/bash
PRESET="ultrafast"
PLATFORM="rtmp://(platform_streaming_url)"
SOURCE="source of the stream(m3u8)"
STREAMING_KEY="platform_personal_streaming_key"
ffmpeg \
-re -i "$SOURCE" -vcodec libx264 -preset $PRESET -maxrate 3000k -b:v 2500k \
-bufsize 600k -pix_fmt yuv420p -g 60 -c:a aac -b:a 160k -ac 2 \
-ar 44100 -f flv -s 1280x720 "$STREAMING_KEY/$PLATFORM"
But usualy the source of those streams are private, and to stream from private sources i have to use other solutions that take a lot of my computer resources.
So is there a way to stream through ffmpeg, knowing that i have the credentials of that private stream.
Related
I've used the following command to stream mp4 file to youtube :
ffmpeg -re -i merge.mp4 \
-c:v libx264 -preset veryfast -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 \
-ar 44100 -f flv rtmp://a.rtmp.youtube.com/live2/<MYKEY>
I see the ffmpeg streams the data like that:
but yet the youtube streaming page shows nothing yet received:
Any idea what am I missing?
Hi I'm trying to stream a file to Facebook but I would like to start the streaming in 00:01:21 of the video whit the command
ffmpeg -ss 00:01:20 \
-re -i 'My_Video.mp4' -f pulse -ac 2 \
-i default -pix_fmt yuv420p -c:v libx264 -s 1280x720 \
-preset veryfast -c:a aac -b:a 160k -ar 44100 \
-threads 0 -bufsize 1000k -vb 500k -maxrate 500k -deinterlace -g 30 -r 30\
-f flv -flvflags no_duration_filesize "rtmps://live-api-s.facebook.com:443/rtmp/MY_FACEBOOK_KEY"
but the stream do not start in the 00:01:20 just start regularly in the 00:00:00.00, what could be wrong ? thank you all for your time !
my ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
I tried to stream an mp3 file to a Telegram RTMP live using the following command:
ffmpeg -re -i 1.mp3 -c copy -f mp3 rtmps://dc4-1.rtmp.t.me/s/145158:AtyF3rrME2nHEkqGA
But I couldn't hear any sound in the stream.
You should specify the codecs explicitly.
The following is the simplest working command:
ffmpeg -i your_input -c:v libx264 -c:a aac -f flv rtmps://dcx-y.rtmp.t.me/s/YOUR_KEY
Here is a more advanced example from #tgbeta:
ffmpeg -stream_loop -1 -re -i your_input -c:v libx264 -preset veryfast -b:v 3500k -maxrate 3500k -bufsize 7000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv rtmps://dcx-y.rtmp.t.me/s/YOUR_KEY
Change -f mp3 by -f flv.
Example:
ffmpeg -re -i 1.mp3 -c:a copy -f flv rtmps://dc4-1.rtmp.t.me/s/145158:AtyF3rrME2nHEkqGA
I want to stream my video to 4 destinations. My input signal needs to be recoded to "H.264 AAC", so I want to send it to my server. This works already.
Client -> Server with ffmpeg -> Destinations
Now I have a performance problem: One should get the stream in 1080p and two in 720p.
So it would make sense to first get the stream in the desired formats H.264 1080p and AAC with 30 FPS and then calculate the stream once, send it 1:1 to the two HD targets.
and create a 720p stream in parallel and send it to the two remaining destinations.
What is the best way to do this on a Ubuntu 16.04 machine?
My previous approach:
ffmpeg -i rtmp://livestream.domain.example/live/<key> \
-threads 2 -s hd1080 -preset veryfast -f flv rtmp://destination1.example/live2/<key> \
-threads 2 -s hd1080 -preset veryfast -f flv rtmp://destination2.example/live2/<key> \
-threads 1 -s hd720 -c:v libx264 -c:a aac -preset veryfast -r 30 -g 60 -b:v 3000k -f flv rtmp://destination3.example/x/<key> \
-threads 1 -s hd720 -c:v libx264 -preset veryfast -c:a aac -f flv 'rtmps://destination4.exmple/rtmp/<key>'
You can see the repetitions in the code. :-/
Use the tee muxer:
ffmpeg -i rtmp://livestream.domain.example/live/<key> \
-filter_complex "[0:v]scale=-2:1080,fps=30,split=outputs=2[1080a][1080b];[0:v]scale=-2:720,fps=30,split=outputs=2[720a][720b]" \
-map "[1080a]" -map "[1080b]" -map "[720a]" -map "[720b]" -map 0:a \
-c:v libx264 -c:a aac -preset veryfast -g 60 -b:v 3000k -maxrate 3000k -bufsize 6000k -f tee \
"[select=\'v:0,a\':f=flv:onfail=ignore]rtmp://destination1.example/live2/<key>| \
[select=\'v:1,a\':f=flv:onfail=ignore]rtmp://destination2.example/live2/<key>| \
[select=\'v:2,a\':f=flv:onfail=ignore]rtmp://destination3.example/live2/<key>| \
[select=\'v:3,a\':f=flv:onfail=ignore]rtmp://destination4.example/live2/<key>"
I can stream fine using the command
ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -framerate 30 -video_size 1280x720 \
-i :0.0+0,0 -c:v libx264 -preset veryfast -maxrate 1984k -bufsize 3968k \
-vf "format=yuv420p" -g 60 -c:a aac -b:a 128k -ar 44100 \
-f flv rtmp://live.twitch.tv/app/<stream key>
Platforms generally have a delay of ~10 seconds for viewers. When I terminate the ffmpeg command, the stream ends immediately for the viewers and they miss the last 10 seconds of video.
How can I terminate the stream without the end of the video cutting off abruptly?