Skip to content

Commit a4f8545

Browse files
authored
Merge pull request #173 from tatzyr/h264
Use H.264 codec first
2 parents 33dfac1 + 01d74f8 commit a4f8545

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/ytdl/ytdl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ func buildArgs(feedConfig *config.Feed, episode *model.Episode, outputFilePath s
195195
if feedConfig.Format == model.FormatVideo {
196196
// Video, mp4, high by default
197197

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

200200
if feedConfig.Quality == model.QualityLow {
201-
format = "worstvideo[ext=mp4]+worstaudio[ext=m4a]/worst[ext=mp4]/worst"
201+
format = "worstvideo[ext=mp4][vcodec^=avc1]+worstaudio[ext=m4a]/worst[ext=mp4][vcodec^=avc1]/worst[ext=mp4]/worst"
202202
} else if feedConfig.Quality == model.QualityHigh && feedConfig.MaxHeight > 0 {
203-
format = fmt.Sprintf("bestvideo[height<=%d][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", feedConfig.MaxHeight)
203+
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)
204204
}
205205

206206
args = append(args, "--format", format)

pkg/ytdl/ytdl_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@ func TestBuildArgs(t *testing.T) {
4848
format: model.FormatVideo,
4949
output: "/tmp/1",
5050
videoURL: "http://url",
51-
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/1", "http://url"},
51+
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"},
5252
},
5353
{
5454
name: "Video unknown quality with maxheight",
5555
format: model.FormatVideo,
5656
maxHeight: 720,
5757
output: "/tmp/1",
5858
videoURL: "http://url",
59-
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/1", "http://url"},
59+
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"},
6060
},
6161
{
6262
name: "Video low quality",
6363
format: model.FormatVideo,
6464
quality: model.QualityLow,
6565
output: "/tmp/2",
6666
videoURL: "http://url",
67-
expect: []string{"--format", "worstvideo[ext=mp4]+worstaudio[ext=m4a]/worst[ext=mp4]/worst", "--output", "/tmp/2", "http://url"},
67+
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"},
6868
},
6969
{
7070
name: "Video low quality with maxheight",
@@ -73,15 +73,15 @@ func TestBuildArgs(t *testing.T) {
7373
maxHeight: 720,
7474
output: "/tmp/2",
7575
videoURL: "http://url",
76-
expect: []string{"--format", "worstvideo[ext=mp4]+worstaudio[ext=m4a]/worst[ext=mp4]/worst", "--output", "/tmp/2", "http://url"},
76+
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"},
7777
},
7878
{
7979
name: "Video high quality",
8080
format: model.FormatVideo,
8181
quality: model.QualityHigh,
8282
output: "/tmp/2",
8383
videoURL: "http://url1",
84-
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
84+
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"},
8585
},
8686
{
8787
name: "Video high quality with maxheight",
@@ -90,7 +90,7 @@ func TestBuildArgs(t *testing.T) {
9090
maxHeight: 1024,
9191
output: "/tmp/2",
9292
videoURL: "http://url1",
93-
expect: []string{"--format", "bestvideo[height<=1024][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
93+
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"},
9494
},
9595
{
9696
name: "Video high quality with custom youtube-dl arguments",
@@ -99,7 +99,7 @@ func TestBuildArgs(t *testing.T) {
9999
output: "/tmp/2",
100100
videoURL: "http://url1",
101101
ytdlArgs: []string{"--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB"},
102-
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"},
102+
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"},
103103
},
104104
}
105105

0 commit comments

Comments
 (0)