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:
|
else:
|
||||||
outtmpl = str(Path(output_dir) / '%(title)s.%(ext)s')
|
outtmpl = str(Path(output_dir) / '%(title)s.%(ext)s')
|
||||||
|
|
||||||
# Configure format selector for maximum quality with correct aspect ratio
|
# Configure format selector for maximum quality with Telegram/mobile compatibility
|
||||||
# Priority: best video + best audio, or best combined format
|
# Priority: Prefer already merged formats in mp4 container
|
||||||
# This ensures we get the highest quality available while maintaining original proportions
|
# This ensures compatibility with Telegram and mobile devices
|
||||||
if quality == "best":
|
if quality == "best":
|
||||||
# Format selector for maximum quality:
|
# Format selector for maximum quality with compatibility:
|
||||||
# 1. bestvideo (highest quality video) + bestaudio (highest quality audio) - best quality
|
# 1. Prefer already merged mp4 files (best compatibility, no re-encoding needed)
|
||||||
# 2. best (best combined format if separate streams not available) - fallback
|
# 2. bestvideo[ext=mp4]+bestaudio[ext=m4a] (mp4 container, compatible codecs)
|
||||||
# This selector maintains original aspect ratio and resolution
|
# 3. bestvideo+bestaudio (fallback, will be merged to mp4)
|
||||||
format_selector = 'bestvideo+bestaudio/best'
|
# 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:
|
else:
|
||||||
# Use custom quality if specified
|
# Use custom quality if specified
|
||||||
format_selector = quality
|
format_selector = quality
|
||||||
@@ -155,7 +161,13 @@ async def download_media(
|
|||||||
'no_warnings': False,
|
'no_warnings': False,
|
||||||
'progress_hooks': [progress_hook_func],
|
'progress_hooks': [progress_hook_func],
|
||||||
# Merge video and audio into single file (if separate streams)
|
# Merge video and audio into single file (if separate streams)
|
||||||
|
# Use mp4 container for maximum compatibility
|
||||||
'merge_output_format': 'mp4',
|
'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)
|
# Don't prefer free formats (they may be lower quality)
|
||||||
'prefer_free_formats': False,
|
'prefer_free_formats': False,
|
||||||
# Additional options for better quality
|
# Additional options for better quality
|
||||||
|
|||||||
Reference in New Issue
Block a user