Skip to content

Add Youtube and HTTP/1.1+ stream functionality#37

Open
izekblz wants to merge 11 commits intojustarandomguyintheinternet:mainfrom
izekblz:main
Open

Add Youtube and HTTP/1.1+ stream functionality#37
izekblz wants to merge 11 commits intojustarandomguyintheinternet:mainfrom
izekblz:main

Conversation

@izekblz
Copy link
Copy Markdown

@izekblz izekblz commented Apr 27, 2025

Full disclosure, I am not a CPP developer nor do I claim to really know what I'm doing. I've done all the testing I could think of, but a real developer should review this.

This is a quick and dirty solution for that arose from half of the online radios being unavailable. The main culprit was FMOD, as it can't properly parse audio streams that are transmitted in HTTP/1.1+.

To solve this, I introduced ffmpeg relays, that would just post to any open port on localhost. Unfortunately, those relays were unstable and usually fell apart after 1-2 reconnects. This is where Icecast comes in, as it's lightweight enough to be virtually unnoticeable and could also accommodate streams from ffmpeg relays.

While we're at it and have already introduced relays, adding youtube functionality seemed like a logical next step. Unfortunately, I couldn't get it done without introducing yt-dlp.

The general workflow looks like this:

  1. On game launch, we instantly start Icecast server
  2. Still during launch, we check all the metadata.json files if they are a stream
  3. If they are a stream, we use curl to check the HTTP version in headers, and for every one that has HTTP != 1.0 we start a relay
  4. In the relay start logic, we check if the URL is Youtube (requires yt-dlp) or not, and create a process for relay with respective parameters

So all in all, the updated functionality requires 3 third party binaries (Icecast, FFmpeg and yt-dlp) and uses one more third party package (curl). There is an option to build and provide third party binaries by yourself, instead of relying on pre-provided ones in the release. Details are described in the updated README.

You can test my latest release or build your own, the only thing that might change in the project is including curl.

This also includes changes from @tiehu, as they might save someone from killing world radios in their save.

tiehu and others added 11 commits February 14, 2025 17:27
Relay creation introduced microfreezes during gameplay, moved to game initialization
Utilizes yt-dlp to get the m3u8 audio only stream and pipes to ffmpeg which posts to icecast
FFMPEG and yt-dlp can now be called from users PATH, if the user doesn't have executables in the `Cyberpunk 2077\red4ext\plugins\RadioExt` folder
@izekblz
Copy link
Copy Markdown
Author

izekblz commented Apr 27, 2025

This also inadvertently added the .aac support for streams. I will probably update the ffmpeg command to work with .m3u and .ogg at some point in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants