mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-11-03 23:38:14 +02:00
fix: support separate yt-dlp video and audio streams
This commit is contained in:
1 parent
389bd1b348
commit
9a5deeefed
2 files changed
+7
-7
No files matched your search
@@ -42,9 +42,9 @@ class Downloader:
|
|||||||
|
|
||||||
cap = parse_height_cap(max_download_quality)
|
cap = parse_height_cap(max_download_quality)
|
||||||
if cap is not None:
|
if cap is not None:
|
||||||
#if the requested cap isn't available, we still download the best mp4.
|
# Prefer separate MP4 video and audio streams; yt-dlp merges them with ffmpeg.
|
||||||
return f"best[ext=mp4][acodec!=none][vcodec!=none][height<={cap}]/best[ext=mp4][height<={cap}]/best[ext=mp4]"
|
return f"bestvideo[ext=mp4][height<={cap}]+bestaudio[ext=m4a]/bestvideo[ext=mp4][height<={cap}]+bestaudio/bestvideo[ext=mp4][height<={cap}]/best[ext=mp4]"
|
||||||
return "best[ext=mp4][acodec!=none][vcodec!=none]/best[ext=mp4]"
|
return "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio/bestvideo[ext=mp4]/best[ext=mp4]"
|
||||||
|
|
||||||
async def handle_job(self, job: DownloadJob):
|
async def handle_job(self, job: DownloadJob):
|
||||||
try:
|
try:
|
||||||
@@ -97,10 +97,8 @@ class Downloader:
|
|||||||
|
|
||||||
fmt = self.build_format(getattr(job, "max_download_quality", None))
|
fmt = self.build_format(getattr(job, "max_download_quality", None))
|
||||||
|
|
||||||
# All modes download a single muxed mp4 when possible.
|
# Prefer MP4 video with a separate audio stream; yt-dlp merges them when needed.
|
||||||
# This avoids any ffmpeg-driven merging during the download step, satisfying:
|
# Audio extraction for audio/both modes happens separately after download.
|
||||||
# - video: "original file, no processing"
|
|
||||||
# - audio/both: extraction is done separately after download
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
"format": fmt,
|
"format": fmt,
|
||||||
"outtmpl": outtmpl,
|
"outtmpl": outtmpl,
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ from app.core.download.downloader import Downloader
|
|||||||
def test_build_format_defaults_to_best_mp4():
|
def test_build_format_defaults_to_best_mp4():
|
||||||
fmt = Downloader.build_format(None)
|
fmt = Downloader.build_format(None)
|
||||||
assert "height<=1080" in fmt
|
assert "height<=1080" in fmt
|
||||||
|
assert "bestvideo[ext=mp4][height<=1080]+bestaudio" in fmt
|
||||||
assert fmt.endswith("/best[ext=mp4]")
|
assert fmt.endswith("/best[ext=mp4]")
|
||||||
|
|
||||||
|
|
||||||
def test_build_format_applies_height_cap():
|
def test_build_format_applies_height_cap():
|
||||||
fmt = Downloader.build_format("720p")
|
fmt = Downloader.build_format("720p")
|
||||||
|
assert "bestvideo[ext=mp4]" in fmt
|
||||||
assert "height<=720" in fmt
|
assert "height<=720" in fmt
|
||||||
|
|
||||||
Reference in new issue
Block a user