Skip to content

Instantly share code, notes, and snippets.

@arjunae
Last active June 28, 2020 22:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arjunae/53da098d6d1d973cf2e2d024618c3e3a to your computer and use it in GitHub Desktop.
Save arjunae/53da098d6d1d973cf2e2d024618c3e3a to your computer and use it in GitHub Desktop.
VLC 3.0 and FFMPEG settings for streaming to YouNow (02.2018)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Streaming Setup Recommendations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deactivate AntiVirus Software during Streaming
2) Open Audio->Speaker and set the Quality to 16Bit / 44100 (CD Quality)
3) Tweak Advanced Energy Settings->Multimedia
4) Open System->Services and stop Services which are unneeded for Streaming.
5) Start OBS with the parameter --enable-gpu
6) Start Streaming Software (FFMPEG / OBS) with "Aboveormal" Priority
7) Remove unused Protocols/Clients within Network Adapter settings.
8) Tweak your Router to prio Port 80 (HLS) 443 and 1935 (RTMPS / RTMP)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OBS-Studio Stream Settings for streaming directly to YouNow
-Tuned for use in a 2012 Thinkpad (4MB RAM , Intel Graphics)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Video Settings:
Scale: 544:306
FPS: 24 (NTSC) or even 20 looks OK.
Output->Audio Settings:
Track1-X: 96kbt
Output->Video Settings: (advanced)
Quality: CBR
Bitrate: 300
Buffers: 0
Tune: Superfast
Profile: Baseline
(Custom x264 Opts: Subme=6 Rc-lookahead=20 Ref=3)
Important: Start OBS with the parameter --enable-gpu
References:
...The OBS inluded "Browser Source" is a CEF Engine. (Chromium)
...If you plan to stream Flash Content using it, then make sure your system has the [Opera_and_Chromium based Flash Plugin] installed.
https://get.adobe.com/de/flashplayer/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FFMPEG Settings for Streaming any DirectShow VideoSource to a Streaming Platform.
-Tuned for use in a 2012 Thinkpad (4MB RAM , Intel Graphics)
- with a 2Mbt Uplink (attached over Wlan) with old Hardware.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(Used OBS here as an Example)
ffmpeg
-threads 4
-hwaccel dxva2 (std DirectX Accel. If you have a NVIDIA Card, you can also use NVENC)
-r 30
-f dshow -s 640x360 -i video="OBS-Camera":audio="virtual-audio-capturer"
-tune fastdecode (optional, reduces load)
-ar 44100 (flv format doesnt support 48khz !?! )
-vf scale=400:300 (scales to 4:3 use 568:320 for 16:10) (optional - reduces load)
-ac 1 (optional- encode mono, reduces load)
-ab 96k (Audio Bitrate, optionally choose 128 for higher Quality)
-vcodec libx264
-preset ultrafast
-pix_fmt yuv420p (need that for Virtual OBS-Webcam)
-profile:v baseline
-level 1
-b:v 200k
-f flv "rtmp://stream.younow.com/liveapp/.....Key" ( works with other portals too.)
ffmpeg -threads 4 -hwaccel dxva2 -r 30 -f dshow -s 640x360 -i video="OBS-Camera":audio="virtual-audio-capturer" -ar 44100 -ab 96k -ac 1 -vcodec libx264 -preset ultrafast -tune fastdecode -pix_fmt yuv420p -profile:v baseline -level 1 -b:v 200k -f flv "rtmp://stream.younow.com/liveapp/41934897_1_75191dcda2738c1570ebd014e48ae57f"
Footnotes:
Note for Windows Systems. Watch CPUs peak load while streaming. (performance Monitor)
Optionally change ffmpegs process priority to a higher value and or temporarly deactivate other services.
...That 'virtual-audio-capturer' is a DirectShow Device provided by:
https://github.com/rdp/virtual-audio-capture-grabber-device
... The Device "OBS-Camera" is a DirectShow Device provided by:
https://obsproject.com/forum/resources/obs-virtualcam.539/
...Found another Reference related to Streaming using both, VLC and FFMPEG:
https://gist.github.com/revolunet/320db93516ec19eb931b
...And another one, listing many h264 Options and mapps to the standard Profiles:
http://web.archive.org/web/20120814041026/http://dev.gentoo.org/~beandog/x264_preset_reference.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VLC Settings for Streaming a WebSource (eg YouTube) to a Streaming Platform.
- Tuned for use in a 2012 Thinkpad (4MB RAM , Intel Graphics)
- with a 2Mbt Uplink (attached over Wlan) with old Hardware.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Options:
vlc https://www.youtube.com/watch?v=OTGGIupcnYM --loop
--live-caching=0
--sout-x264-preset=ultrafast
--sout-x264-crf=15
--sout-transcode-threads 4 (for a dualcore System wt Hyperthreading)
--sout-keep
--sout #gather:transcode{vcodec=h264,vb=500,acodec=mp3,ab=96,channels=1}
:std{access=rtmp,mux=ffmpeg{mux=flv},dst=rtmp://stream.younow.com/liveapp/STREAM_KEY}
--sout-keep
vlc https://www.youtube.com/watch?v=OTGGIupcnYM --loop --live-caching=0 --sout-x264-preset=ultrafast --sout-x264-crf=15 --sout-transcode-threads 8 --sout #gather:transcode{vcodec=h264,vb=500,acodec=mp3,ab=96,channels=1}:std{access=rtmp,mux=ffmpeg{mux=flv},dst=rtmp://stream.younow.com/liveapp/..........} --sout-keep
Remark:
Normally you should see your Stream lag-free (when you view it the first time.)
You may see 1 Second Lags when eg switchig to another Streamer and then back to yours.
Theyre caused by YouNows Flash based RTMP Player (not easy fixable.)
Thats why YouNow says that viewing your owm stream can introduce lags.
Testing showed that any other people viewing your stream are not affected by those Lags.
However- The followig method should be a safe and lag free Way to view your stream:
Download "VLC" and "Streamlink" and feed it with your Stream URL. -> All Okay.
streamlink --stream-url https://www.younow.com/[UserName] live
{shows rtmp://pullstream.younow.8686c.com/live/Stream-177144884}
StreamLink: https://github.com/streamlink/streamlink
----------------------------------------------------------------
Finally -> Heres a Link to YouNows current Project (probably their YouNowApp Successor)
Platform: https://www.propsproject.com/de/
App: "Rize" within the PlayStore
.....Couldnt Sleep, was bored and wrote a funny anonymous Youtube(playlist)-OBS Stream Chain....
https://github.com/arjunae/youtube_playlist_localhost
By writing the above Article, VLC was at 3.0 and FFMPEG at 20160517-git-af3e944 (win64)
----------------------
Network settings tweaking
----------------------
Out of Curiousity in trying other Services than YouNow - I experienced some Problems viewing Twitch Streams.
A simple check using Taskmanagers Performance View showed volatile downstream rate movin between nearly zero to 2.5 Mbps.
The first fix that bettered the Situation with the Browser app was to deactivate Anniversary Updates "Window Auto Tuning" Feature.
see: <https://www.thewindowsclub.com/window-auto-tuning-in-windows-10>
After deactivating with netsh int tcp set global autotuninglevel=disabled
The rates lower limit was about 1 Mbps and allowed 720px Streams to be viewed without buffering issues.
Secondly - i found another mentions worth Tool to try "TCP-Optimizer".
Volatile Bandwith can be a result from a Bandwith Cap configured by eg a provider policing.
Using Tcp-Optimizers "Optimal" Setting on the Network adapter used as Internet Connectivity helped me further coping with that problem.
<https://www.speedguide.net/downloads.php>
Btw: Its Test recommended reducing MTU to 1490 so avoiding Network fragments.
[Before](https://github.com/arjunae/myScite/blob/devel/contrib/SciTE_screenshots/picture_space/projects/twitch_desktop_client.PNG)
[After](https://github.com/arjunae/myScite/blob/devel/contrib/SciTE_screenshots/picture_space/projects/twitch_tcp_optimizer.PNG)
Update; Defined a port prio for HTTP/80 and HTTPS/443 as Twitch seems to use HLS <https://en.wikipedia.org/wiki/HTTP_Live_Streaming>
Other Services showed to use (RTMP/1935) (RTMPS-HTTPS/443) <https://en.wikipedia.org/wiki/Real-Time_Messaging_Protocol>
HAHA.. Tested while viewing 3 German OldSchool boys in mid-age dresses singing funny Songs from that Time :)
https://www.twitch.tv/kawautv
~~~~~~~~~~~~~~~~~~~~~~~~
Further Detailed System Tuning
~~~~~~~~~~~~~~~~~~~~~~~~
Just for Reference, the following Site has some detailed Instruction on how to reduce a Systems Latency.
<https://support.native-instruments.com/hc/en-us/articles/209571729-Windows-Tuning-Tips-for-Audio-Processing>
Besides other Tasks to try - it recommends and describes the use of an Application called "LatencyMon" to measure and such unveil
Services and Drivers with high Latencies.
Have Fun, Thorsten
----------------------------------------------
@echo off
::REM https://www.codeproject.com/Tips/123810/Get-user-input-from-DOS-prompt
::REM https://github.com/streamlink/streamlink
:: Lag-Free Open Live Stream with VLC (YouNow, Twitch etc)
SET /P Link=Stream Quelle ? :
IF ["%Link%"] neq [""] streamlink --stream-url %Link% best
IF ["%Link%"] neq [""] streamlink %Link% best
:: To Include another RTMP Source within OBS "Video Source" do:
:: IF ["%Link%"] neq [""] streamlink --player-external-http --player-external-http-port 8080 %Link% best
Pause
REM : (re)Stream any DirectShow Video Source (eg a AV or a Url) to a Streaming Plat (eg YouNow)
REM : Tuned for use in a 2012 Thinkpad (4MB RAM , Intel Graphics)
REM : https://github.com/rdp/virtual-audio-capture-grabber-device
REM : https://obsproject.com/forum/resources/obs-virtualcam.539/
REM
start /HIGH ffmpeg -threads 4 -hwaccel dxva2 -r 30 -f dshow -s 640x360 -i video="OBS-Camera":audio="virtual-audio-capturer" -vf scale=568:320 -ar 44100 -ab 96k -ac 1 -vcodec libx264 -preset ultrafast -tune fastdecode -pix_fmt yuv420p -profile:v baseline -level 1 -b:v 150k -f flv "rtmp://stream.younow.com/liveapp/YouNowStreamKey"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment