To stream your MP4 video file to Owncast using FFmpeg, follow these steps:
1. Locate Your Owncast RTMP Credentials
- In your Owncast admin dashboard (
http://your-server:8080/admin
), go to Configuration → Stream Keys. - Copy the Stream URL (e.g.,
rtmp://your-server/live
) and Stream Key (e.g.,abc123-secret-key
).
2. Basic FFmpeg Command
fffmpeg -re -stream_loop -1 -i video.mp4 \
-map 0:v -map 0:a \
-c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k -g 60 -pix_fmt yuv420p \
-c:a aac -b:a 128k -ar 44100 \
-f flv 'rtmp://localhost:1935/live/key'
Explanation of Flags:
-re
: Read input at native frame rate (avoids streaming too fast).-stream_loop -1
: Loop the video infinitely (remove this to stream once).-c:v libx264
: Use H.264 video codec.-preset veryfast
: Balances speed and compression efficiency.-b:v 2500k
: Video bitrate (adjust based on your video resolution).-g 60
: Keyframe interval (2 seconds for 30fps; critical for seeking).-pix_fmt yuv420p
: Ensures compatibility with players.-c:a aac
: Use AAC audio codec.-f flv
: Output format for RTMP.
3. Advanced Options
a. Hardware Acceleration (if supported):
ffmpeg -hwaccel cuda -re -i input.mp4 -c:v h264_nvenc ... (rest of the command)
Replace cuda
/h264_nvenc
with your GPU's acceleration method (e.g., vaapi
for Intel).
b. No Looping (stream once):
Remove -stream_loop -1
.
c. Custom Resolution (e.g., 720p):
Add -vf "scale=1280:720"
before -c:v libx264
.
4. Verify the Stream
- Run the FFmpeg command in your terminal.
- Visit your Owncast instance at
http://your-server:8080
to watch the stream.
5. Troubleshooting
- Codec Errors: Ensure your FFmpeg supports
libx264
andaac
(install withffmpeg -codecs | grep -E 'libx264|aac'
). - Connection Issues: Check firewall rules (RTMP typically uses port 1935).
- Quality Adjustments: Lower
-b:v
if bandwidth is limited (e.g.,1000k
for 720p).
0 Comments