通过命令行使用 VLC 从 youtube 下载视频

Downloading video from youtube using VLC with the command line

我正在制作此批处理脚本,以通过命令行使用 VLC 从 youtube 下载 MP4 格式的视频。对我来说效果很好!

@echo off
REM Downloading a video from youtube using VLC with the command line by (c) Hackoo 2017
Title Si Lemhaf - Kharrej Legrinta Elli Fik by (c) Hackoo 2017
mode con:cols=65 lines=3 & COLOR 0E
Taskkill /IM "vlc.exe" /F >nul 2>&1
echo.
echo     Please wait a while ... The download is in progress ...
set Title=Si Lemhaf - Kharrej Legrinta Elli Fik by (c) Hackoo 2017
set "VLC_URL=http://www.videolan.org/vlc/download-windows.html"
set "URL=https://www.youtube.com/watch?v=KDI1C27zEC0"
set "File=SiLmehaf.mp4"

IF /I "%PROCESSOR_ARCHITECTURE%"=="x86" (
        Set "vlc=%ProgramFiles%\VideoLAN\VLC\vlc.exe"
    ) else (
        Set "vlc=%ProgramFiles(x86)%\VideoLAN\VLC\vlc.exe"
)

If Not Exist "%vlc%" (
    Cls & COLOR 0C
    echo.
    Echo       "The VLC program is not installed on your system" 
    TimeOut /T 5 /NoBreak>nul
    Start "" %VLC_URL%
    Exit
)

"%vlc%" -vvv "%URL%" --qt-start-minimized --qt-notification=0 --sout=#transcode{vcodec="h264",vb="512",fps="23.97",scale="1",acodec="mpga",ab="128","channels=2",samplerate="44100"}:standard{access="file",mux=mp4,dst=%File%} vlc://quit"
REM Starting the video in fullscreen with VLC
Start "" "%vlc%" -f --meta-title="%Title%" %File% 

但是,我的问题是为什么 Youtube 中的某些 URL 不起作用? 像这样:

https://www.youtube.com/watch?v=TGtWWb9emYI

我从 VLC 程序中得到这个错误

Can not recognize the format of the input media

因为此视频的所有者:https://www.youtube.com/watch?v=TGtWWb9emYI 拥有 turn off the embedding,您无法使用 vlc 下载它。您的代码工作正常,如果您从 vlc programm >> Media >> 打开捕获设备并通过您的 Url 流式传输 youtube 视频,您将收到错误消息。

此外,yturls 脚本在尝试下载 Youtube 视频时会显示以下错误:

YouTubeAPIError: This video contains content from VEVO. It is restricted 
from playback on certain sites or applications.