From c1dcced79138554c74d0cb9336feb02906d64d8e Mon Sep 17 00:00:00 2001 From: Nonoo Date: Mon, 14 Aug 2023 13:48:26 +0200 Subject: [PATCH] Add options to set merge output format and sorting format yt-dlp uses mp4 format by default to merge sources with separate video and audio streams. mp4 format does not handle VP9 codec, so adding the ability to set the merge output format, we can set it to use for ex. mkv, which handles VP9 well. With the possibility of setting the sorting format we can tell yt-dlp which criteria to consider as the best format. --- goutubedl.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/goutubedl.go b/goutubedl.go index 1da583e..4e2110c 100644 --- a/goutubedl.go +++ b/goutubedl.go @@ -211,6 +211,8 @@ type Options struct { DebugLog Printer StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr HTTPClient *http.Client // Client for download thumbnail and subtitles (nil use http.DefaultClient) + MergeOutputFormat string // --merge-output-format + SortingFormat string // --format-sort } // Version of youtube-dl. @@ -474,6 +476,18 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu cmd.Args = append(cmd.Args, "--downloader", result.Options.Downloader) } + if result.Options.MergeOutputFormat != "" { + cmd.Args = append(cmd.Args, + "--merge-output-format", result.Options.MergeOutputFormat, + ) + } + + if result.Options.SortingFormat != "" { + cmd.Args = append(cmd.Args, + "--format-sort", result.Options.SortingFormat, + ) + } + cmd.Dir = tempPath var w io.WriteCloser dr.reader, w = io.Pipe()