Post subject: Streaming encodes directly to Twitch.tv
Masterjun
He/Him
Site Developer, Skilled player (1988)
Joined: 10/12/2010
Posts: 1185
Location: Germany
BizHawk has an option to use FFmpeg to encode video, and it currently lets you customize options and flags. This can be used to directly stream to Twitch.tv, without using any other software. As usual, configure your encode settings by going to File -> AVI/WAV -> Config and Record AVI/WAV. Choose FFmpeg writer. Now select [Custom], enter the custom options. For initial testing I recommend using these options (replace {STREAM_KEY} with your actual stream key):
-codec:v libx264 -pix_fmt yuv420p -f flv "rtmp://live.twitch.tv/app/{STREAM_KEY}" -f null
A resulting file won't be created, so when the window pops up asking you to save a file, just enter whatever you want (but you might need to change the automatic filetype here*). Quick explanation for the options used:
  • -codec:v libx264 | Use the libx264 codec. (Twitch requirement)
  • -pix_fmt yuv420p | Use the YUV420p pixel format. (Twitch requirement)
  • -f flv | Use the FLV file format. (Streaming recommendation)
  • "rtmp://live.twitch.tv/app/{STREAM_KEY}" | Output to Twitch. It is recommended to change live.twitch.tv to the correct server URL for your location.
  • -f null | Use the null file format for the second output (i.e. don't save a file).
Of course, you can (and should) add other options for optimal streaming. It is important to mention that this will stream the encode output, not the real time emulator: If you fast-forward, the stream will keep playing in regular console framerate. And if you pause the emulator or simply can't reach the console framerate, the stream will catch up and then buffer or drop the connection. Useful Links: Twitch.tv Broadcast Requirements Twitch.tv Broadcast Guidelines Twitch.tv Server Choices FFmpeg Streaming Guide FFmpeg Full Documentation
* We trick the emulator into outputting two things, because we need to change the filename to a URL. We specifiy two formats (two -f options), and it thinks the whole part after the first -f is the file extension. Windows doesn't allow " or / characters in filenames, so you get an error.
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
adelikat
He/Him
Emulator Coder, Site Developer, Site Owner, Expert player (3573)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
Thank you so much for this information!. This is pretty cool.
It's hard to look this good. My TAS projects
Spikestuff
They/Them
Editor, Publisher, Expert player (2643)
Joined: 10/12/2011
Posts: 6439
Location: The land down under.
Did a test with my quality Australian Internet™. People might need to consider adding a bitrate variable. Twitch also has a section dedicated to their encoding specs -b:v | specifies the target (average) bit rate for the encoder to use (-b:a for audio) -minrate | specifies a minimum tolerance to be used -maxrate | specifies a maximum tolerance. this is only used in conjunction with bufsize -bufsize | specifies the decoder buffer size, which determines the variability of the output bitrate You can use abbreviations like K for kBit/s and M for MBit/s. A constant bit rate would ask for the min, max and buf to be all the same values. It's also recommended to use the presets, ffmpeg defaults you to medium, which is conveniently the best for x264 Twitch. It's a tradeoff between compression efficiency and encoding speed. For streaming veryfast is usually the recommended one. -preset veryfast -preset faster -preset fast -preset medium Another thing to note, is that it looks like roughly the first 5 seconds will be lost. Don't know how to go about this other than padding which unfortunately I forgot the command to on ffmpeg. -- If for whatever reason you want to see the test and what I gathered. Video Used: Tetris 99 - 150 Lines Mode (8:40 test) Twitch Video - Will be deleting eventually as it was more of a test. (Probably automatically from twitch in 30 days) Refrence from YouTube What was used was the original video, not a download. Duration : 8 min 41 s Bit rate mode : Variable Bit rate : 20.0 Mb/s Maximum bit rate : 40.0 Mb/s A bit overkill for Twitch.
WebNations/Sabih wrote:
+fsvgm777 never censoring anything.
Disables Comments and Ratings for the YouTube account. Something better for yourself and also others.
Player (98)
Joined: 12/12/2013
Posts: 379
Location: Russia
Spikestuff wrote:
Another thing to note, is that it looks like roughly the first 5 seconds will be lost. Don't know how to go about this other than padding which unfortunately I forgot the command to on ffmpeg.
I tried this way:
ffmpeg -f lavfi -t 5 -i color=c=black:s=480x360 -f lavfi -t 5 -i anullsrc=channel_layout=stereo:sample_rate=44100 -i d:\qwe.mp4 -filter_complex "[0:v][1:a][2:v][2:a] concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" d:\asd.mp4
for plain files it worked for me. you need to set correct picture dumensions and audio sample rate though. I don't know better way.
Spikestuff
They/Them
Editor, Publisher, Expert player (2643)
Joined: 10/12/2011
Posts: 6439
Location: The land down under.
Something else I learnt with premade footage and not emulation (which might lead to the same result depending on a few factors). A premade video let's say that's an hour long will jump around for the entire video and be done for instance in 40 minutes. The archived video will be an hour. A placebo or vframes might assist in this situation.
WebNations/Sabih wrote:
+fsvgm777 never censoring anything.
Disables Comments and Ratings for the YouTube account. Something better for yourself and also others.
Post subject: Re: Streaming encodes directly to Twitch.tv
Editor, Player (69)
Joined: 6/22/2005
Posts: 1050
Masterjun wrote:
It is important to mention that this will stream the encode output, not the real time emulator: If you fast-forward, the stream will keep playing in regular console framerate.
This means that fast-forwarding will generate the same amount of data but over a shorter time period, right, just like dumping an AVI at various emulator speeds?
Current Projects: TAS: Wizards & Warriors III.
Post subject: Re: Streaming encodes directly to Twitch.tv
Masterjun
He/Him
Site Developer, Skilled player (1988)
Joined: 10/12/2010
Posts: 1185
Location: Germany
Dacicus wrote:
This means that fast-forwarding will generate the same amount of data but over a shorter time period, right, just like dumping an AVI at various emulator speeds?
Yes!
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)