Skip to content

Commit

Permalink
Use H.264 codec first
Browse files Browse the repository at this point in the history
  • Loading branch information
tatzyr committed Sep 20, 2020
1 parent 33dfac1 commit 01d74f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pkg/ytdl/ytdl.go
Expand Up @@ -195,12 +195,12 @@ func buildArgs(feedConfig *config.Feed, episode *model.Episode, outputFilePath s
if feedConfig.Format == model.FormatVideo {
// Video, mp4, high by default

format := "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
format := "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4][vcodec^=avc1]/best[ext=mp4]/best"

if feedConfig.Quality == model.QualityLow {
format = "worstvideo[ext=mp4]+worstaudio[ext=m4a]/worst[ext=mp4]/worst"
format = "worstvideo[ext=mp4][vcodec^=avc1]+worstaudio[ext=m4a]/worst[ext=mp4][vcodec^=avc1]/worst[ext=mp4]/worst"
} else if feedConfig.Quality == model.QualityHigh && feedConfig.MaxHeight > 0 {
format = fmt.Sprintf("bestvideo[height<=%d][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", feedConfig.MaxHeight)
format = fmt.Sprintf("bestvideo[height<=%d][ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[height<=%d][ext=mp4][vcodec^=avc1]/best[ext=mp4]/best", feedConfig.MaxHeight, feedConfig.MaxHeight)
}

args = append(args, "--format", format)
Expand Down
14 changes: 7 additions & 7 deletions pkg/ytdl/ytdl_test.go
Expand Up @@ -48,23 +48,23 @@ func TestBuildArgs(t *testing.T) {
format: model.FormatVideo,
output: "/tmp/1",
videoURL: "http://url",
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/1", "http://url"},
expect: []string{"--format", "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4][vcodec^=avc1]/best[ext=mp4]/best", "--output", "/tmp/1", "http://url"},
},
{
name: "Video unknown quality with maxheight",
format: model.FormatVideo,
maxHeight: 720,
output: "/tmp/1",
videoURL: "http://url",
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/1", "http://url"},
expect: []string{"--format", "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4][vcodec^=avc1]/best[ext=mp4]/best", "--output", "/tmp/1", "http://url"},
},
{
name: "Video low quality",
format: model.FormatVideo,
quality: model.QualityLow,
output: "/tmp/2",
videoURL: "http://url",
expect: []string{"--format", "worstvideo[ext=mp4]+worstaudio[ext=m4a]/worst[ext=mp4]/worst", "--output", "/tmp/2", "http://url"},
expect: []string{"--format", "worstvideo[ext=mp4][vcodec^=avc1]+worstaudio[ext=m4a]/worst[ext=mp4][vcodec^=avc1]/worst[ext=mp4]/worst", "--output", "/tmp/2", "http://url"},
},
{
name: "Video low quality with maxheight",
Expand All @@ -73,15 +73,15 @@ func TestBuildArgs(t *testing.T) {
maxHeight: 720,
output: "/tmp/2",
videoURL: "http://url",
expect: []string{"--format", "worstvideo[ext=mp4]+worstaudio[ext=m4a]/worst[ext=mp4]/worst", "--output", "/tmp/2", "http://url"},
expect: []string{"--format", "worstvideo[ext=mp4][vcodec^=avc1]+worstaudio[ext=m4a]/worst[ext=mp4][vcodec^=avc1]/worst[ext=mp4]/worst", "--output", "/tmp/2", "http://url"},
},
{
name: "Video high quality",
format: model.FormatVideo,
quality: model.QualityHigh,
output: "/tmp/2",
videoURL: "http://url1",
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
expect: []string{"--format", "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4][vcodec^=avc1]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
},
{
name: "Video high quality with maxheight",
Expand All @@ -90,7 +90,7 @@ func TestBuildArgs(t *testing.T) {
maxHeight: 1024,
output: "/tmp/2",
videoURL: "http://url1",
expect: []string{"--format", "bestvideo[height<=1024][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
expect: []string{"--format", "bestvideo[height<=1024][ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[height<=1024][ext=mp4][vcodec^=avc1]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
},
{
name: "Video high quality with custom youtube-dl arguments",
Expand All @@ -99,7 +99,7 @@ func TestBuildArgs(t *testing.T) {
output: "/tmp/2",
videoURL: "http://url1",
ytdlArgs: []string{"--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB"},
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB", "--output", "/tmp/2", "http://url1"},
expect: []string{"--format", "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4][vcodec^=avc1]/best[ext=mp4]/best", "--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB", "--output", "/tmp/2", "http://url1"},
},
}

Expand Down

0 comments on commit 01d74f8

Please sign in to comment.