How to download YouTube Videos quickly

Shawn Wang

如何快速下載 YouTube 影片

原文由 Shawn Wang 發布,訂閱此部落格

我以前一直都用 yt5s 來抓影片、做混剪:

圖片

現在得改用 https://ytdlp.online/

……但它常常會下載到根本沒屁用的 .webm 副檔名。跟 Google 其他那堆爛副檔名一樣,你可以直接把 .webm 改成 .mp4,有時候會動——但你要上傳到 Twitter 時真的會被擋下來。

我手邊也都會留著這個參數

yt-dlp -f "bestvideo[ext=mp4][height<=720]+bestaudio[ext=m4a]/best[ext=mp4]/best" YOUR_URL_HERE

vp9 編碼錯誤

這樣寫很糟: youtube-dl -f bestvideo+bestaudio --merge-output-format mp4 https://www.youtube.com/watch\?v\=VcUl0vPJwxo 因為它會抓到錯誤的影片(https://chatgpt.com/c/68856117-61c8-8331-b493-9027ad956de5)然後你就得重新轉檔 ffmpeg -i yourvideo.mp4 -c:v libx265 -c:a aac fixed.mp4

如果 Youtube 允許的話就這樣做

yt-dlp -f "bv*[vcodec^=avc1][ext=mp4]+ba[acodec^=mp4a]/b[vcodec^=avc1][ext=mp4]" \
  --merge-output-format mp4 -o "%(title)s.%(ext)s" https://www.youtube.com/watch?v=VcUl0vPJwxo

# or re encode:

yt-dlp -f "bv*+ba/b" --recode-video mp4 \
  --postprocessor-args "ffmpeg:-c:v hevc_videotoolbox -b:v 8M -pix_fmt yuv420p -tag:v hvc1 -c:a aac -movflags +faststart" \
  -o "%(title)s.%(ext)s" https://www.youtube.com/watch?v=VcUl0vPJwxo

直播用

yt-dlp --live-from-start -f "bestvideo[ext=mp4][height<=720]+bestaudio[ext=m4a]/best[ext=mp4]/best" YOUR_URL_HERE

加上時間長度限制

yt-dlp --hls-prefer-ffmpeg --live-from-start \
  --downloader ffmpeg \
  --downloader-args "ffmpeg:-t 02:00:00" \
  -o "%(title)s_%(upload_date)s_live.%(ext)s" \
  "https://www.youtube.com/watch?v=qcO6huB0O8Y"

更新

如果你拿到 .webm 檔,可以試試這個

ffmpeg -i textgeneratorvision.webm -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -shortest -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2,fps=30" -c:v libx264 -pix_fmt yuv420p -c:a aac textgeneratorvision.mp4

照這傢伙說的

還有

yt-dlp -f "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" -o "%(title)s.%(ext)s" --merge-output-format mp4

本文章由 muse-spark-1.2-contributor 進行翻譯

留言