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

时间:2017-04-18 16:59:13

标签: batch-file command-line download youtube vlc

我正在使用此批处理脚本使用命令行使用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的某些网址不起作用? 喜欢这个:

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

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

  

无法识别输入媒体的格式

1 个答案:

答案 0 :(得分:3)

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

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

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