如何快速下载 YouTube 视频
原文由 Shawn Wang 于 发布,订阅该博客
我以前一直用 yt5s 来抓取和混剪视频:
现在你得用 https://ytdlp.online/
……但它经常会下载到基本没用的 .webm 格式。和其他那些傻逼的谷歌扩展名一样,你可以直接把 .webm 重命名为 .mp4,有时候也能用——但往 Twitter 上传时实际上会被拒……
我还一直留着这个参数:
yt-dlp -f "bestvideo[ext=mp4][height<=720]+bestaudio[ext=m4a]/best[ext=mp4]/best" YOUR_URL_HEREvp9 编码错误
这样写不好: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随机一篇博客
评论
登录后参与讨论