ffmpeg stream an audio file to Telegram rtmp server - ffmpeg

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

Related

ffmpeg streaming to youtube

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?

How to stream from a private m3u8 server using ffmpeg

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.

live streamming using ffmpeg for more than stream on the same time

I'm using this command to stream video in ffmpeg but when I stream more than 3 or 4 streams at the same time interruption happen although the process in my device doesn't exceed 50%
I tried to use ffmpeg lib for each stream but interruption still happened
this is my command :
ffmpeg -re -i test.mp4 -i logo.png -vcodec libx264 -pix_fmt yuv420p -vb 2000000 -g 60
-vprofile main -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb
-strict experimental -filter_complex "[0][1]overlay=0:0"
-pass 1 -f mpegts udp://127.0.0.1:1234?pkt_size=1316

FFMPEG stream_loop with Overlay

Doing live streaming using the FFMPEG.
I want to do endless loop on input stream.
Use the -stream_loop -1 option, but not work. How can I do it?
-re -stream_loop -1 -i "Background.mp4" -f image2pipe -i pipe:0 -filter_complex "[0:v][1:v] overlay=0:0" -acodec aac -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v main -s 1280x720 -bufsize 8000k -maxrate 4000k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv "URL"
My suggestion is that you use a bash script to loop the script so it repeats itself forever. To do this you create a file and name it for example: Loop.sh
Open the file and format it like this:
#!/bin/bash
while true
do
ffmpeg "Background.mp4" -f image2pipe -i pipe:0 -filter_complex "[0:v][1:v] overlay=0:0" -acodec aac -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v main -s 1280x720 -bufsize 8000k -maxrate 4000k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv "URL"
done
Save the file and using the terminal (assuming you're using linux or Mac) make it executable. cd into the directory and use command
sudo chmod +x Loop.sh
Now you can run the script by simply typing ./Loop.sh and it will execute forever (until you stop it).
while true to equal anything like while 1=1 or any combinations of variables that will result true.

Create MP4 video from multiple images + musics using FFMPEG command

I have created video with multiple images and single music file. It's working fine
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-000.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;
But when I tried with multiple music files it throws and error in terminal.
Command:
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-%03d.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;
Error:
/<<dir path>>/music3-%03d.mp3: No such file or directory
There's no audio sequence demuxer. To combine multiple audio files in your command, you'll have to use the concat demuxer.
First, create a text file with the list of files
file 'music3-000.mp3'
file 'music3-001.mp3'
file 'music3-002.mp3'
...
Then run
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg \
-f concat -i list.txt \
-c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental
-shortest /<<dir path>>/video/output.mp4

Resources