How to push mp3 to srs with ffmpeg? - ffmpeg

I push my MP3 file like this:
ffmpeg.exe -re -stream_loop -1 -i ./ring.mp3 -c copy -f mp3 rtmp://${domain}/live/test
But the PotPlayer couldn't accept it well.

For FFmpeg, the format you should use flv instead of mp3, like this:
ffmpeg.exe -re -stream_loop -1 -i ./ring.mp3 -c copy \
-f flv rtmp://${domain}/live/test
# Or transcode the sample file of SRS
ffmpeg -re -i srs/trunk/doc/source.flv -vn -c:a libmp3lame \
-f flv rtmp://localhost/live/test
Then play by ffplay:
ffplay rtmp://localhost/live/test
Recommend to use AAC instead MP3, because AAC is more widely used, so you could transcode to aac by:
ffmpeg -f flv -i rtmp://localhost/live/livestream -c:v copy -c:a aac \
-f flv -y rtmp://localhost/live/test2
Note that WebRTC use opus as audio codec.

Related

Ffmpeg Add image overlay on rmtp stream

I have a m3u8 input and I convert it to a rmtp stream using this command:
ffmpeg -re -i "https://<url>.m3u8" -af asetpts=N/SR/TB -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -f flv -flvflags no_duration_filesize -s 1920x1080 "rtmp://<url>"
But I would like to add my logo on the top right part of the stream, I didn't manage to do it, do someone know how to do it?
Thanks

ffmpeg stream an audio file to Telegram rtmp server

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

Command to stream MPEG-1 video

I'm trying to stream MPEG-1 video over FFMPEG with
ffmpeg -i "out.ts" -f flv -listen 1 -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app
The out.ts file is a MPEG-1 video encoded with
ffmpeg -i out.avi -f mpegts -codec:v mpeg1video -b:v 1500k -r 30 -bf 0 -codec:a mp2 -b 0 -q 5 -t 1 out.ts
When I try to open the stream with VLC: rtmp://localhost:1935/live/app media is not playing. What's the command to stream MPEG-1 video over FFMPEG?
RTMP does not have support for mpeg1 video or mpeg2 audio. You can see the complete list if supported code in the fly specification under the VIDEODATA header.
https://www.adobe.com/content/dam/acom/en/devnet/flv/video_file_format_spec_v10.pdf
To stream MPEG-1 video using ffmpeg:
ffmpeg -re -y -i out.ts -an -f rtp_mpegts rtp://127.0.0.1:1234
Credit to: https://ffmpeg.org/pipermail/ffmpeg-user/2015-October/028879.html
(Although the source video is 720p, the stream in VLC looks like 360p and no audio is streamed, any idea would be appreciated)

How to re-stream h265 RTSP stream using FFMPEG

I have written a small piece of code to re-stream camera RTSP stream on Nginx stream server using FFMPEG.
Everything working fine, my re-stream RTSP on to Nginx stream server using following FFMPEG command:
ffmpeg -rtsp_transport tcp -i 'rtsp://212.78.10.88:554/stream' -f lavfi -i aevalsrc=0 -vcodec copy -acodec aac -map 0:0 -map 1:0 -shortest -strict experimental -f flv rtmp://localhost:1935/live/stream
My basic problem is H265 and H265+. FFMPEG failed to re-stream H265 format streams. I tried differently command params but no luck.
Any body know how to re-stream H265 and + in FFMPEG?
Finally, I solved the issue to re-stream h265 stream.
I just used following arguments in command to solve this issue.
-c:v libx264 -pix_fmt yuv420p
and final command is:
ffmpeg -rtsp_transport tcp -i 'rtsp://212.78.10.88:554/stream' -f lavfi -i aevalsrc=0 -vcodec copy -acodec aac -map 0:0 -map 1:0 -c:v libx264 -pix_fmt yuv420p -shortest -strict experimental -f flv rtmp://localhost:1935/live/stream

ffmpeg error when I make TS file

I use ffmpeg to make video from audio/image to mp4.
I want merge/concatenate two mp4 video.
I have this to make mp4 video:
ffmpeg -i "background.png" -i "audio.mp3" -y -r 30 -b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 "result.mp4"
This, it works!
To concatenate two mp4 video, I must pass by ts files.
ffmpeg -i "result.mp4" -codec copy -bsf:v hevc_mp4toannexb intermediate1.ts
But, I have this error:

Resources