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
205 stars 36 forks source link

VOD profile for original source file? #54

Open metal450 opened 1 month ago

metal450 commented 1 month ago

In config.yaml, we can define video-profiles like i.e.

video-profiles:
    360p:
      width: 640
      height: 360
      bitrate: 800
    540p:
      width: 960
      height: 540
      bitrate: 1800

Is there a way to have an "original file" profile? i.e. to optionally just serve up the source .mp4, without any transcoding?

If not, would love it as a feature request :)

m1k1o commented 1 month ago

without any transcoding

That would be only possible if the original file is already transcoded in the correct format (correct video/audio codec, acceptable GOP length, etc.). So we would need to verify first if the source is compatible and then allow direct passthrough with only segmenting. Otherwise we would need to either fallback to transcoding anyway or throw an error.

metal450 commented 1 month ago

That would be only possible if the original file is already transcoded in the correct format

You mean if the original file is in some format that supports streaming (i.e. h264, not h265)?

Basically, I have a video library on a Synology NAS. Through their UI, I'm actually able to browse the files, and play them directly (not with transcoding). So when I'm "close to the NAS" (i.e. on the same LAN or with fast internet), I can watch directly; when I'm on slow Internet, I can watch transcoded via go-transcode. It'd be great if go-transcode could provide the original file as an option, that way I could use it as the sole access point for the videos - use the "direct stream" when internet is fast enough, switch to transcoding otherwise. Does that make sense?

m1k1o commented 1 month ago

It would only be needed if you want to play it on the web. If only using VLC, you can basically just serve the file using a webserver. Depends on the codec, VLC should be able to just request the byte ranges of the file that are actually needed.

An idea, to basically just serve the files as they are, you can try out: https://github.com/m1k1o/go-transcode/compare/master...vod-serve-files

So if you would play http://127.0.0.1:8080/vod/MyFile.mp4 in VLC, it should work. And if you need transcoding, you can still request using the old format.

metal450 commented 1 month ago

An idea, to basically just serve the files as they are, you can try out: https://github.com/m1k1o/go-transcode/compare/master...vod-serve-files

Yup, that works great :)

The only thing I'd possibly add is, it would be awesome to actually have it as an option in the index - that way it could also be selected from the quality selector (i.e. in the web player or some desktop players). Granted that, as you said, if the file is the wrong format it might not be able play, but that's fine. i.e. maybe some special-case profile, like:

video-profiles:
    360p:
      width: 640
      height: 360
      bitrate: 800
    540p:
      width: 960
      height: 540
      bitrate: 1800
    original:
      original: true // or however to best denote it

Just an idea. What you did so far is already great tho :)