u/cofe-table

▲ 0 r/webdev

Why Web UI sucks?

Dear WebDevs, could someone seriously explain to me why every site I visit from my modern phone is so jumpy? They are always loading something and every time I decide to tap a button - it goes away and instead I tap on some other link! It's so frustrating!

And another question - who is working on it to fix it once and for all? :)

reddit.com
u/cofe-table — 1 day ago

Where to store the build generated source code?

Please help to choose the best way to place during-the-build generated code in C++/CMake project (by templates from protobuf specs): I see it could be stored in the repo or in the build directory - where you put it and why?

reddit.com
u/cofe-table — 1 day ago

Harry Potter and the Methods of Rationality by Eliezer Yudkowsky

If you think HP is too simple - this will be perfect for you and will make you to think. It's the same story written as science-fiction and you will adore it because it has a very smart antagonist and was told from a perspective of science method ( yep, it's possible ;)

u/cofe-table — 2 days ago
▲ 17 r/obs

Twitch enhansed broadcasting for all

Folks, just played with Enhansed Broadcasting of Twitch (Amazon IVS) on my NAS (Celeron N5105) with Docker container (ffmpeg 8.1, OBS 32.1).

Right now I stream 2 IP cameras (as PiP) by transcoding on Intel VAAPI and it's smooth, but gives me only 1440p25. So I thought to check the new Enhansed Broadcasting and found that OBS and Twitch (based on Amazon IVS) doesn't like my system: it needs windows and nvidia/amd. Too much care about the customers that limits them!

But who cares if we can produce the required frames, right? So I dug in and found that it requests configuration from twitch API (which is effectively aws api) and gives configs back if you send the right data to it. So here it is, my little python3 http server:

#!/usr/bin/env python3
# Script intercepts the OBS config request and overrides some params in it to surely get a response
# Use as:
#  $ python3 ./server.py &
#  $ obs --config-url http://localhost:8000

from http.server import HTTPServer, BaseHTTPRequestHandler
import urllib.parse
import urllib.request
import json

class SimplePOSTHandler(BaseHTTPRequestHandler):
    def do_POST(self):
        # Read the POST data
        content_length = int(self.headers['Content-Length'])
        post_data = json.loads(self.rfile.read(content_length))
        print(f"Received POST data: {json.dumps(post_data)}")

        # Reusing some fields of original post but replacing the HW and OS
        new_post_data = {
            "schema_version":"2024-06-04",
            "service":"IVS",

            "authentication": post_data["authentication"],
            "capabilities":{
                "cpu": {"logical_cores":16,"name":"AMD Ryzen 7 5800X 8-Core Processor ","physical_cores":8,"speed":3800},
                "gaming_features":{"game_bar_enabled":None,"game_dvr_allowed":None,"game_dvr_bg_recording":None,"game_dvr_enabled":True,"game_mode_enabled":None,"hags_enabled":False},
                "gpu": [{"dedicated_video_memory":12673089536,"device_id":8712,"driver_version":"31.0.15.5152","model":"NVIDIA GeForce RTX 3080 Ti","shared_system_memory":17132537856,"vendor_id":4318}],
                "memory": {"free":15091892224,"total":34265075712},
                "system": {"arm":False,"armEmulation":False,"bits":64,"build":22631,"name":"Windows","release":"23H2","revision":3880,"version":"10.0"}
            },
            "client": post_data["client"],
            "preferences": post_data["preferences"],
        }
        print(f"Sending {json.dumps(new_post_data)}")

        # Requesting actual Twitch URL for the data (or use any other Amazon IVS endpoint)
        url = "https://ingest.twitch.tv/api/v3/GetClientConfiguration"
        with urllib.request.urlopen(url, json.dumps(new_post_data).encode('utf8')) as response:
            response_data = json.load(response)

        # Override json response with encoder we want to use from OBS
        for item in response_data['encoder_configurations']:
            if item['type'] == 'jim_nvenc':
                item['type'] = 'ffmpeg_vaapi'

        out_data = json.dumps(response_data, indent=4)
        print(f"Replying the output {json.dumps(response_data)}")

        # Send a 200 OK response
        self.send_response(200)
        self.send_header('Content-type', 'application/json')
        self.end_headers()
        self.wfile.write(out_data.encode('utf8'))

# Start the server
server_address = ('', 8000)
httpd = HTTPServer(server_address, SimplePOSTHandler)
print("Server running on port 8000...")
httpd.serve_forever()

Just run it locally and during OBS startup provide where to find the config server url:

$ obs --config-url http://localhost:8080

And now after checking the box of Enhansed Broadcasting you will make it work even on non-supported system! But please check the logic of the script - it replaces the default encoder type to "ffmpeg_vaapi" which works in my case, but you could need another one.

Also there are a way to provide custom configuration in OBS profile basic.ini for Stream1 - MultitrackVideoConfigOverride*, but I did not explored it much...

Hopefully this will help you folks somehow!

reddit.com
u/cofe-table — 3 days ago

Template-generation from protobuf (not ai) in src or build dir?

Dear programmers, DevOps is here with his tricky questions, maybe you can help:

I tried both approaches of generating source code from openai/protobuf and now stuck in between of 2 lights:

  • Save the build-generated code right in the repository source code (for example like I did in golang-based aquarium-fish) - this allows for easy grep around, IDE is happy on first start and build doesn't require to regenerate just to build on CI, but raises questions of safety of the src.
  • Save the build-generated code in build directory (example: C++ aSocial), which is dynamic and I can use read-only src folder during the build, but QtCreator IDE is not happy until I build the project and makes it complicated to fix the issue since code is not under scm control...

What do you think about those approaches? I'm not a professional programmer, just doing it for fun, so will be great to hear the collective wisdom of the community - which approach to use?

And what overall you can say about the template-generative approach? It's quite new for me and I found it very useful, but maybe I go too far and it will hurt on the long-run?

reddit.com
u/cofe-table — 3 days ago