Skip to content

Commit

Permalink
Merge branch 'release/v1.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
slaveofcode committed May 8, 2020
2 parents 014910a + 6446c06 commit 39eb5f7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Voodio Change Log
All notable changes to this project will be documented in this file.

## [1.3.3]
- 44ac333 Fix incorrect playlist & default resolution
- 274c817 Merge tag 'v1.3.2' into develop

## [1.3.2]
- 25bdd1a Fix default resolution
- c8a7110 Merge tag 'v1.3.1' into develop
Expand Down
43 changes: 35 additions & 8 deletions collections/extract_hls.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,43 @@ func cmdHLS1080p(movieFilePath, destDir string) []string {
}
}

func createm3u8Playlist(path string) {
func createm3u8Playlist(path string, res []string) {
f, _ := os.Create(filepath.Join(path, "playlist.m3u8"))
defer f.Close()

f.Write([]byte(`#EXTM3U
c := `#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
`

for _, r := range res {
if r == "360p" {
c = c + `#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
360p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=842x480
`
}

if r == "480p" {
c = c + `#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=842x480
480p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
`
}

if r == "720p" {
c = c + `#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
1080p.m3u8`))
`
}

if r == "1080p" {
c = c + `#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
1080p.m3u8
`
}
}

logrus.Debugln(c)

f.Write([]byte(c))
}

// ExtractMovHLS will generate HLS files
Expand All @@ -156,14 +179,18 @@ func ExtractMovHLS(movieFilePath, destDir, ffmpegPathBin string, reso []string)
"1080p": cmdHLS1080p,
}

logrus.Debugln("reso", reso)

resolutions := make(map[string]func(string, string) []string)
for _, r := range reso {
if availableResolutions[r] != nil {
resolutions[r] = availableResolutions[r]
}
}

createm3u8Playlist(destDir)
logrus.Debugln("generated reso", resolutions)

createm3u8Playlist(destDir, reso)

output := make(chan TranscodingError, len(resolutions))
for reso, cmdStrings := range resolutions {
Expand Down
16 changes: 10 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,20 @@ func main() {
ffmpegPath := flag.String("ffmpeg-bin", "ffmpeg", "Custom full path for FFmpeg binary")
tmdbAPIKey := flag.String("tmdb-key", "", "Your TMDB Api Key, get here if you don't have one https://www.themoviedb.org/documentation/api")

screenRes := resolutionParam{
"360p",
"480p",
"720p",
"1080p",
}
screenRes := resolutionParam{}
flag.Var(&screenRes, "resolution", "Specific resolution to be processed: 360p, 480p, 720p and 1080p, this could be multiple")

flag.Parse()

if len(screenRes) == 0 {
screenRes = resolutionParam{
"360p",
"480p",
"720p",
"1080p",
}
}

if len(*parentMoviePath) == 0 {
cleanup()
panic("No movie path directory provided, exited")
Expand Down

0 comments on commit 39eb5f7

Please sign in to comment.