Closed m1k1o closed 2 years ago
It is already functional, just very basic proof of concept, can be called like this:
/tmp/test.mp4
is the source media./tmp/out
transcoding directory, must exist.import "github.com/m1k1o/go-transcode/hlsvod"
hlsVodManager := hlsvod.New(hlsvod.Config{
MediaPath: "/tmp/test.mp4",
TranscodeDir: "/tmp/out",
SegmentPrefix: "foo",
VideoProfile: &hlsvod.VideoProfile{
Width: 1280,
Height: 720,
Bitrate: 4200,
},
AudioProfile: &hlsvod.AudioProfile{
Bitrate: 128,
},
Cache: true,
FFmpegBinary: "ffmpeg",
FFprobeBinary: "ffprobe",
})
err := hlsVodManager.Start()
if err != nil {
log.Err(err)
return
}
http.HandleFunc("/playlist.m3u8", hlsVodManager.ServePlaylist)
http.HandleFunc("/", hlsVodManager.ServeMedia)
log.Info().Msg("listening on :8080")
err = http.ListenAndServe(":8080", nil)
log.Err(err)
edit: added profiles after changes.
It has been added to API. You can call it using:
go run main.go serve --voddir /tmp/media/
Assuming file /tmp/media/test.mp4
exists, you can play it with http://127.0.0.1:8080/vod/test.mp4/default.m3u8
.
TODO:
Transcode static files on demand.
fixes #12