Update yt-dlp option config for download best quality video with pc/phone support
This commit is contained in:
@@ -135,15 +135,21 @@ async def download_media(
|
||||
else:
|
||||
outtmpl = str(Path(output_dir) / '%(title)s.%(ext)s')
|
||||
|
||||
# Configure format selector for maximum quality with correct aspect ratio
|
||||
# Priority: best video + best audio, or best combined format
|
||||
# This ensures we get the highest quality available while maintaining original proportions
|
||||
# Configure format selector for maximum quality with Telegram/mobile compatibility
|
||||
# Priority: Prefer already merged formats in mp4 container
|
||||
# This ensures compatibility with Telegram and mobile devices
|
||||
if quality == "best":
|
||||
# Format selector for maximum quality:
|
||||
# 1. bestvideo (highest quality video) + bestaudio (highest quality audio) - best quality
|
||||
# 2. best (best combined format if separate streams not available) - fallback
|
||||
# This selector maintains original aspect ratio and resolution
|
||||
format_selector = 'bestvideo+bestaudio/best'
|
||||
# Format selector for maximum quality with compatibility:
|
||||
# 1. Prefer already merged mp4 files (best compatibility, no re-encoding needed)
|
||||
# 2. bestvideo[ext=mp4]+bestaudio[ext=m4a] (mp4 container, compatible codecs)
|
||||
# 3. bestvideo+bestaudio (fallback, will be merged to mp4)
|
||||
# 4. best (best combined format if separate streams not available)
|
||||
format_selector = (
|
||||
'best[ext=mp4]/'
|
||||
'bestvideo[ext=mp4]+bestaudio[ext=m4a]/'
|
||||
'bestvideo[ext=mp4]+bestaudio/'
|
||||
'bestvideo+bestaudio/best'
|
||||
)
|
||||
else:
|
||||
# Use custom quality if specified
|
||||
format_selector = quality
|
||||
@@ -155,7 +161,13 @@ async def download_media(
|
||||
'no_warnings': False,
|
||||
'progress_hooks': [progress_hook_func],
|
||||
# Merge video and audio into single file (if separate streams)
|
||||
# Use mp4 container for maximum compatibility
|
||||
'merge_output_format': 'mp4',
|
||||
# FFmpeg options for merging to ensure compatibility
|
||||
# Copy streams when possible (no re-encoding), only encode if necessary
|
||||
'postprocessor_args': {
|
||||
'ffmpeg': ['-c:v', 'copy', '-c:a', 'aac', '-movflags', '+faststart']
|
||||
},
|
||||
# Don't prefer free formats (they may be lower quality)
|
||||
'prefer_free_formats': False,
|
||||
# Additional options for better quality
|
||||
|
||||
Reference in New Issue
Block a user