OBS vs YouTube

getveva

New Member
Hi everyone,

I'm currently doing a streaming research using different levels of resolution, from 1080p FHD to 240p, and trying to compare the output to YouTube's output. I'm streaming to my own server hosted with DigitalOcean.
I noticed that HD stream works perfectly well and the output is the same as HD video output on YouTube, but I started seeing changes when I stream in SD (480p, 360p, 240p). SD video output on YouTube is brighter and crispier than what I'm seeing on my server. I'v tried different tweaks on OBS by lowering CPU usage preset to FAST, downscale to Lanczos, increase FPS to 60 but nothing works. Is there a way I can achieve same SD output I'm seeing on YouTube on my server using OBS?

Thanks everyone.
 

koala

Active Member
If something is uploaded to Youtube, it gets recoded by Youtube to each of the intermediate resolutions. To reproduce this behavior, you need to recode your original video the same way.

It's not that easy, because the exact encoding parameters are unknown. We know the resolution and the bitrate, fps, color space, encoding format, profile and that Youtube hasn't infinite CPU resources. But we don't know preset and any custom encoding parameters. It's probably ffmpeg x264 what they use, but we don't know for sure.

You can enumerate all the available video (and audio) parts of a Youtube video with youtube-dl -F <video>, for example like this:

Code:
>youtube-dl -F "https://www.youtube.com/watch?v=DTNUA0U1NZY"
[debug] System config: []
[debug] User config: ['--verbose']
[debug] Custom config: []
[debug] Command-line args: ['-F', 'https://www.youtube.com/watch?v=DTNUA0U1NZY']
[debug] Encodings: locale cp1252, fs mbcs, out cp65001, pref cp1252
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.19041
[debug] exe versions: ffmpeg 2021-12-09-git-b9f4c1231f-full_build-www.gyan.dev, ffprobe 2021-12-09-git-b9f4c1231f-full_build-www.gyan.dev
[debug] Proxy map: {}
[youtube] DTNUA0U1NZY: Downloading webpage
[info] Available formats for DTNUA0U1NZY:
format code  extension  resolution note
249          webm       audio only tiny   50k , webm_dash container, opus @ 50k (48000Hz), 1.01MiB
250          webm       audio only tiny   64k , webm_dash container, opus @ 64k (48000Hz), 1.31MiB
251          webm       audio only tiny  123k , webm_dash container, opus @123k (48000Hz), 2.50MiB
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 2.61MiB
160          mp4        256x144    144p   82k , mp4_dash container, avc1.4d400c@  82k, 30fps, video only, 1.67MiB
278          webm       256x144    144p   89k , webm_dash container, vp9@  89k, 30fps, video only, 1.81MiB
242          webm       426x240    240p  179k , webm_dash container, vp9@ 179k, 30fps, video only, 3.62MiB
133          mp4        426x240    240p  203k , mp4_dash container, avc1.4d4015@ 203k, 30fps, video only, 4.11MiB
243          webm       640x360    360p  361k , webm_dash container, vp9@ 361k, 30fps, video only, 7.29MiB
134          mp4        640x360    360p  457k , mp4_dash container, avc1.4d401e@ 457k, 30fps, video only, 9.23MiB
244          webm       854x480    480p  691k , webm_dash container, vp9@ 691k, 30fps, video only, 13.96MiB
135          mp4        854x480    480p  914k , mp4_dash container, avc1.4d401f@ 914k, 30fps, video only, 18.46MiB
247          webm       1280x720   720p 1555k , webm_dash container, vp9@1555k, 30fps, video only, 31.39MiB
136          mp4        1280x720   720p 1899k , mp4_dash container, avc1.64001f@1899k, 30fps, video only, 38.32MiB
302          webm       1280x720   720p60 2457k , webm_dash container, vp9@2457k, 60fps, video only, 49.60MiB
298          mp4        1280x720   720p60 2873k , mp4_dash container, avc1.640020@2873k, 60fps, video only, 57.99MiB
303          webm       1920x1080  1080p60 4105k , webm_dash container, vp9@4105k, 60fps, video only, 82.85MiB
299          mp4        1920x1080  1080p60 5472k , mp4_dash container, avc1.64002a@5472k, 60fps, video only, 110.44MiB
18           mp4        640x360    360p  558k , avc1.42001E, 30fps, mp4a.40.2 (44100Hz), 11.26MiB
22           mp4        1280x720   720p 2027k , avc1.64001F, 30fps, mp4a.40.2 (44100Hz) (best)
You see all the different resolutions and their container and encoding format, as well as fps and bitrate. Try to rebuild a ffmpeg command line that will exactly encode to this format. Keep in mind, Youtube keeps video and audio streams separately. The player downloads both at on the fly and merges them accordingly for playback. So if you see bitrate 203k for stream #133, this is for video part only, not for both audio and video.
You can also download all the different resolution videos with youtube-dl -f <number> <video file>, for example youtube-dl -f 133 "https://www.youtube.com/watch?v=DTNUA0U1NZY" for variant 133. Then look with MediaInfo or ffprobe at the properties to get a deeper insight about their properties.
ffprobe:
Code:
D:\temp>ffprobe "If Tom Scott was a Factorio youtuber-DTNUA0U1NZY.mp4"
...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'If Tom Scott was a Factorio youtuber-DTNUA0U1NZY.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    creation_time   : 2022-02-23T00:11:34.000000Z
  Duration: 00:02:49.27, start: 0.000000, bitrate: 203 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 426x240 [SAR 1:1 DAR 71:40], 7 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      creation_time   : 2022-02-23T00:11:34.000000Z
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
MediaInfo:
1645719107007.png


After you got all the info, finally try to construct ffmpeg command lines that will rescale your original video to all the resolutions with the reproduced encoding parameters.
 
Last edited:
Top