m1k1o / go-transcode

On-demand transcoding origin server for live inputs and static files in Go using ffmpeg. Also with NVIDIA GPU hardware acceleration.
Apache License 2.0
208 stars 38 forks source link

Add support for running go-transcode on Windows #41

Open hheimbuerger opened 1 year ago

hheimbuerger commented 1 year ago

I know this probably isn't very high on your list, but I have a use case for on-demand transcoding on Windows, couldn't find any other existing project doing this as easily as this one, and it works with some minor changes, so… here we go!

Let me know what you think and how you want to proceed with this. I see this primarily as a test balloon, to figure out whether changes like this are something you're interested in merging upstream? I could understand if this isn't something you want to deal with (and I'm probably not interested in maintaining this long-term either). I guess I'd just use my fork for my upcoming project and not open further pull requests related to Windows-support.


Some technical notes:

Really the only platform-dependent bits of code were the process group management. I've replaced those with Windows-specific versions, although I haven't fully tested them, because I'm not entirely sure how they're used. (I've pressed Ctrl-C on a running instance once and it seemed to terminate the running ffmpeg instances. But then again, I think they were normal individual processes, so I don't see the need for project groups yet.) Also, the build configuration for Linux and other non-Windows platforms is completely untested.

I believe I also got stream support working, by mashing together some of the bash scripts into a Windows Batch file and replacing that one bit where it concats .sh to the profile name with .cmd. However, I'm only doing VOD and I just found out, that I apparently don't even need those bash scripts, so it isn't included here.

Note that this is the first time I've written or built any Go, so my code is probably not very idiomatic. Suggestions (including required reading) welcome.

m1k1o commented 1 year ago

Although Windows-support was never considered in this project, it seems like a valid usecase and should be included in this project. However, I would prefer to see this OS-specific code outside of the streaming logic. For example, creating a simple helper structure that handles lifecycle of a command.

This OS-specific code that handles linux's process groups was supposed to solve https://github.com/m1k1o/go-transcode/issues/2 but it actually never did (still leaving defunct processes when trying to run multiple processes). Maybe refactroing the code to allow running chain of programs piped togehter (like | in bash) and then killing them one by one would solve this issue.