11

I'm attempted to stream an already recorded video file to twitch servers using FFMPEG but I only get audio so far no video. I've tried several settings, and different files (avi,etc) but I still get audio only. Here is my FFMPEG settings:

 ffmpeg -re -i test.mp4  -vcodec libx264 -preset fast -crf 30 -acodec aac -ab 128k -ar 44100 -strict experimental -f flv rtmp://live-dfw.twitch.tv/app/"TWITCHKEY"

Has anyone nailed this? I'm using ffmpeg 0.8.17-6:0.8.17-1 under Ubuntu.

Fight Fire With Fire
  • 1,626
  • 3
  • 19
  • 28
  • Impossible to say without the complete console output from your command. There was never a "ffmpeg 0.8.17" from FFmpeg, so you're probably using the old, buggy, dead counterfeit "`ffmpeg`" from the Libav fork. – llogan Nov 24 '15 at 02:43

2 Answers2

14
ffmpeg -re -i ~/INPUT_FILE -vcodec libx264 -profile:v main -preset:v medium -r 30 -g 60 -keyint_min 60 -sc_threshold 0 -b:v 2500k -maxrate 2500k -bufsize 2500k -filter:v scale="trunc(oha/2)2:720" -sws_flags lanczos+accurate_rnd -acodec libfdk_aac -b:a 96k -ar 48000 -ac 2 -f flv rtmp://live.twitch.tv/app/STREAM_KEY

But please read the Twitch Rules of conduct before you post that Charle Sheen video.

szatmary
  • 29,969
  • 8
  • 44
  • 57
10

I'm not sure this needs so many options as the other answer. I have

ffmpeg -re -nostdin -i "$file" \
    -vcodec libx264 -preset:v ultrafast \
    -acodec aac \
    -f flv rtmp://live.twitch.tv/app/STREAM_KEY

and it seems to be working ok so far. ultrafast seems to be making my server melt less too.

The -re flag tells ffmpeg to read settings from the input file, so don't see why -r , -g etc are needed.

Dharman
  • 30,962
  • 25
  • 85
  • 135
BaronVonKaneHoffen
  • 1,902
  • 1
  • 21
  • 29
  • I'll point out here that in March 2021, ffmpeg has bugs that keep it from being able to send to secure RTMP servers, like rtmps://. Please see here (https://trac.ffmpeg.org/ticket/6471 "RTMPS stream does not work") for more info. – Lemon Cat Mar 23 '21 at 19:09
  • working for me on Ubuntu 20.04 LTS. thanks. The `$file` can also be a remote video url, such as these ones: https://gist.github.com/jsturgis/3b19447b304616f18657 – guoqiao Aug 13 '22 at 22:08