diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-05 15:05:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-09 09:18:07 +0200 |
commit | 5e2afe4290103bf0d54ae7b3e62781f2a00487c9 (patch) | |
tree | 84e084135c60d208fc9afcee63180d3200f763e6 /server/helpers/youtube-dl/youtube-dl-cli.ts | |
parent | 64fd6158fd276f258bcfc4bb0c8fc2f64a220a11 (diff) | |
download | PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.gz PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.zst PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.zip |
Limit import depending on transcoding resolutions
Diffstat (limited to 'server/helpers/youtube-dl/youtube-dl-cli.ts')
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-cli.ts | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/helpers/youtube-dl/youtube-dl-cli.ts index 728f096b5..13c990a1e 100644 --- a/server/helpers/youtube-dl/youtube-dl-cli.ts +++ b/server/helpers/youtube-dl/youtube-dl-cli.ts | |||
@@ -57,7 +57,7 @@ export class YoutubeDLCLI { | |||
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | static getYoutubeDLVideoFormat (enabledResolutions: VideoResolution[]) { | 60 | static getYoutubeDLVideoFormat (enabledResolutions: VideoResolution[], useBestFormat: boolean) { |
61 | /** | 61 | /** |
62 | * list of format selectors in order or preference | 62 | * list of format selectors in order or preference |
63 | * see https://github.com/ytdl-org/youtube-dl#format-selection | 63 | * see https://github.com/ytdl-org/youtube-dl#format-selection |
@@ -69,18 +69,26 @@ export class YoutubeDLCLI { | |||
69 | * | 69 | * |
70 | * in any case we avoid AV1, see https://github.com/Chocobozzz/PeerTube/issues/3499 | 70 | * in any case we avoid AV1, see https://github.com/Chocobozzz/PeerTube/issues/3499 |
71 | **/ | 71 | **/ |
72 | const resolution = enabledResolutions.length === 0 | 72 | |
73 | ? VideoResolution.H_720P | 73 | let result: string[] = [] |
74 | : Math.max(...enabledResolutions) | 74 | |
75 | 75 | if (!useBestFormat) { | |
76 | return [ | 76 | const resolution = enabledResolutions.length === 0 |
77 | `bestvideo[vcodec^=avc1][height=${resolution}]+bestaudio[ext=m4a]`, // case #1 | 77 | ? VideoResolution.H_720P |
78 | `bestvideo[vcodec!*=av01][vcodec!*=vp9.2][height=${resolution}]+bestaudio`, // case #2 | 78 | : Math.max(...enabledResolutions) |
79 | `bestvideo[vcodec^=avc1][height<=${resolution}]+bestaudio[ext=m4a]`, // case #3 | 79 | |
80 | `bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio`, | 80 | result = [ |
81 | `bestvideo[vcodec^=avc1][height=${resolution}]+bestaudio[ext=m4a]`, // case #1 | ||
82 | `bestvideo[vcodec!*=av01][vcodec!*=vp9.2][height=${resolution}]+bestaudio`, // case #2 | ||
83 | `bestvideo[vcodec^=avc1][height<=${resolution}]+bestaudio[ext=m4a]` // case # | ||
84 | ] | ||
85 | } | ||
86 | |||
87 | return result.concat([ | ||
88 | 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio', | ||
81 | 'best[vcodec!*=av01][vcodec!*=vp9.2]', // case fallback for known formats | 89 | 'best[vcodec!*=av01][vcodec!*=vp9.2]', // case fallback for known formats |
82 | 'best' // Ultimate fallback | 90 | 'best' // Ultimate fallback |
83 | ].join('/') | 91 | ]).join('/') |
84 | } | 92 | } |
85 | 93 | ||
86 | private constructor () { | 94 | private constructor () { |