Live streaming from within your game

Yes there are, and I mentioned some of them to the Unity team.
Their response was: thanks for noticing.
And now these assets are offline…

Interesting, that’s a C# library instead of a native (C/C++/etc) library.
That might still work though, I’ll dive into that.
I’d rather not user openh264 as that means we’re doing the encoding in software instead of on the GPU.

Hahah. Did they really?

People have pretty broad CPUs these days, I wouldn’t worry too much about openh264. Ship it then update to add support for hardware APIs. You’ll quickly find out how important it is to users.

I’ve removed the FFmpeg dll’s and made them available on a website.
The idea is that you download the asset and manually install the FFmpeg dll’s.
If the asset finds the dll’s it will use them, otherwise its just a capture asset without streaming capability.
I could not find any statements that suggest this is against the rules, so lets hope this works.

Wohoo, the plugin is accepted in the store.

1 Like

Great news! Please keep going with the Android version :slight_smile:

Since the plugin is released I have time to work on new features.

I’ve started on Android support.
The current state is that the video capture works, the video is encoded via the hardware encoder on the device and it can be written to an mp4 file.
I’m now trying to make the RTMP part working on Android, without the use of FFmpeg.
I figured this saves customers the hassle of including a notice about using FFmpeg, plus its easier to use the plugin that way.
The problem I’m now working on is that the libraries I could find that have a decent licensing only do RTMP itself and are very poorly documented.
Also these RTMP libraries do not provide a streaming solution like FFmpeg does, they only provide an interface on top of the communication protocol.
Which means you have to know how the protocol works in order to do something with it.
I landed on rtmpsharp, which was suggested by @bengarney .
Unfortunately I had to write a test program around it to be able to develop with it, because when doing some invalid RTMP commands, it completely crashes Unity.
Next to RTMP we also need FLV which is kind of the MP4 of RTMP streaming.
Luckily FLV is a small and easy format so I should be able to work that out without spending months of time on it.

So long story short, for Android I need to complete RTMP and FLV, the other parts are covered.

1 Like

Excited for it! Sounds like you are making great progress

v0.9.2 is released today.
It contains a couple of audio fixes and adds support for setting the audio bitrate.

I also want to give an update on the support of the mobile platforms.
I could not get rtmpsharp to work correctly, it kept crashing the app after the publish RTMP command was sent.
After struggling for some time I found another project which contains a large part of an RTMP library and it has a compatible license.
I’ve extracted the RTMP code out of it so I can use that in the plugin and I’ve added the missing pieces like sending the actual RTMP commands to this code.
I am now able to start an RTMP connection and send FLV data to the RTMP server.
The next thing I am going to do is write an FLV muxer so that I can actually send the captured video over RTMP, instead of my test video.

1 Like

this could be used to stream to a program in the local network? I need to save the streamed video and audio file locally to a file. I can program by myself the program to receive, but i need to know if this is able to stream directly on the local network and what protocol it uses.
thanks.

The plugin streams via RTMP (and later I plan to add SRT).
So yes, you should be able to receive the video over a local network.
You could use for example this FFmpeg command which waits for an RTMP stream and writes it to a file:

    ffmpeg \
        -y \
        -f flv \
        -listen 1 \
        -i rtmp://0.0.0.0:1935/live/app \
        -c copy \
        test.mp4

thanks joepadmiraal,
I have another question, it is possible to stream multiple video/audio stream at the same time using different cameras that renders to render textures?

At the moment this is not possible.
I can add it to the roadmap, but I think it will take quite some time before it will be added.
Unless more people are requesting this of course.

@joepadmiraal
Thank you for creating such great assets.
I was looking for “unity → youtube” that runs in a PC environment.
This is the perfect solution!
When will the version that works on MacOS be updated?
Have a happy year-end 2023.

1 Like

Hi @leebs1986 , thanks for your interest.

I’m currently still working on Android support.
That is taking way longer than I wanted, mainly because I have to develop a lot of stuff myself.
I am able to stream to a local RTMP server now on Android, but commercial services like Youtube don’t work yet.
I have a suspicion on why that is, but it is a lot of work to fix that.

Anyways for MacOS, it will take at least a couple of months before I can start on that.
So a safe bet would be to expect it to be available in half a year.
But who knows, maybe I get lucky and will be able to start sooner.

And happy holidays to you too!

3 Likes

Hi @joepadmiraal
I hav a issue about sync video and audio
It seems to sync well at first. But, when 30 ~ 40 minutes after, the video suddenly stops intermittently, causing the video to lose sync with audio. and the video to lag behind audio.

Do you know anything about this issue?

1 Like

Hi @dhtpdud528
I have not experienced this myself yet.
Could you maybe send the admvideostreamer.log file?
Maybe I can see some issues in there.

@joepadmiraal
Sure. I sent the admvideostreamer.log to admvideostreamer@admiraalit.com.
Please understand that cannot be sent the video of this log due to my company’s security issues.

@joepadmiraal
I received your reply. Thank you for your effort.

I am attaching some files below, hoping that it will be of any help to you.

These are the video & the log file of my 17 hour streaming

===


and this YouTube Studio livestreaming page
I’m not sure if this is the cause but as you can see, Sometimes the audio stream’s bitrate sent to 0

===

I made some modifications to your code “Streamer.cs” to split the camera.
And I will send the code file by e-mail.

version 0.9.2 from October 2023.
Are there any updates planned in the near future?
Thank you.

Hi @Barritico .
I was working on my own RTMP implementation which I wanted to use for the Android version.
But I’m going to give up on that as I’m struggling on getting that to work.
The main problem I have are that the H264 headers that I generate do not seem to be accepted by Youtube.
So, I think I have to pivot to compile FFmpeg for Android and keep using FFmpeg, at least for the RTMP part.

As for an upcoming release, I’m now working on 2 bugs:

  1. The AVsync issue mentioned by dhtpdud528, it seems to happen when the pc is a bit overloaded. I’ve created a test build for them with some detection and compensation logic. But we’re not there yet.
  2. A crash could happen, caused by connection issues.

My plan is to fix point 2 first as I have a clear path to a solution for that one.
So once that is fixed I’ll make a new release.

Also if anyone is interested in how the plugin works before buying it, I’ve uploaded the manual here.

2 Likes