Search code examples
c#.netffmpegwin-universal-appyoutube-livestreaming-api

How to live stream from Windows 10 app to Youtube?


I'm playing around with the YouTube Live Stream API. That's working fine so far, but the next step is to stream the web cam data to YouTube via RTMP.

In the (excellent) documentation at Google Dev, it outlines the Life of a Broadcast. However, all steps are documented in detail, except the step I'm interested in:

Step 3.2: Start your video

Start transmitting video on your video stream.

I was able to use Open Broadcasting Software to stream to a manually created YouTube Live Event, but I have no idea how to do it from my Windows 10 App. I've looked at the MediaElement class, and was able to capture the web cam preview in my app. But I can only find methods to save as a file.

Also found information about FFMPEG, which should probably be able to do the job, but I cannot find a library / DLL to use FFMPEG in my App.

I just need some guidance where to look next, because now I'm just clueless what to do.

/edit: I came across MPlatform SDK, which sounds exactly what I want, but it costs $5000.... Not for a hobby :(


Solution

  • So, as you mentioned, FFmpeg does indeed support streaming (output) over RTMP. I'm not sure what you're trying to stream, since depending on that, the solution will be slightly more or less complex. Two basic cases:

    1. if you're trying to stream an existing file or something from your screen, you can simply use ffmpeg as a command-line executable in your c# application.
    2. if you're streaming custom bitmap data, it's a little bit more complex and you'll have to manually invoke libavformat/libavcodec.

    So, first, get some Windows builds of FFmpeg, e.g. from zeranoe. If you're going to go route 1, just call ffmpeg.exe in your application and you're done. If you want to go route 2, load the relevant libraries into your project and follow tutorials about writing files using libavcodec/libavformat. I can give more details if you tell me what data you want to write. Then, just use either approach to open a rtmp:// output stream, and you should be good to go. (Use h264 as video codec and aac as audio codec, and make sure your build has x264 support, which zeranoe does.)