如何从 youtube-dl 转换脚本

How to convert a script from youtube-dl

有一个bash/batch文件脚本:

ffmpeg -i `youtube-dl https://www.twitch.tv/zero` -vf fps=fps=60, scale=1920x1080 -c:v libx264 -b:v 500k -preset superfast -c:a copy -f segment -segment_time 60 test.mp4

该脚本不是我的,但它可以让您以恒定帧率的部分录制视频。不幸的是,在 cmd 中它对我不起作用。都试过了,不知道是什么错误

我得到 No such file or directory

试过'youtube-dl https://www.twitch.tv/zero',同样的错误

我试过"youtube-dl https://www.twitch.tv/zero",错误:youtube-dl https://www.twitch.tv/zero: Invalid argument

我做错了什么?作者保证他在 linux

上工作

更新

我试了ffmpeg -i $ (youtube-dl -f best -g https://www.twitch.tv/zero) ....同样的错误

更新 2

为什么视频大小超过 500 Mb?我做错了什么?

代码

cls && @echo off & setlocal enableextensions enabledelayedexpansion 
set "_tag_00=https://www.twitch.tv/avagg"
set "_tag_01=--ignore-errors --abort-on-error --ignore-config --flat-playlist --geo-bypass "
set "_tag_02=--restrict-filenames --no-part --no-cache-dir --write-thumbnail --prefer-ffmpeg "
set "_tag_03=--ffmpeg-location .\ --postprocessor-args  -i "%%(title)s.%%(ext)s" -vf fps^=fps^=60^,"
set "_tag_04=scale^=1920x1080 -c:v libx264 -b:v 500k -preset superfast -c:a copy -f segment -segment_time "
set "_tag_05=60 %%^(title^)s.mp4"

youtube-dl "!_tag_00!" -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "%%^(title^)s.%%^(ext^)s" !_tag_1!!_tag_2!!_tag_3!!_tag_4!!_tag_5!
Pause

更新 3

注意以下一些要点

  • 所以,如果我真的理解你的问题,而且它是关于 Windows 中的批处理 file/cmd,你 需要将 的路径放在 ffmpeg.exe在一个变量中,所以可以访问到youtube-dl找到它。
  • 或者,在我上面的示例中,在相同的路径和可变参数工具中,因此,youtube-dl amd ffmepg.exe 在相同的 folder/path = .\ 中。
  • question, is offline, so I changed this link to an another online中的link:

我将按名称保存此代码yt-DL.cmd

仅复制特定时间按:仅编辑_tag_1值:-t 00:60:00

   cls && @echo off & setlocal enableextensions enabledelayedexpansion 

    :: do some with the bat file, after then,  for all links need `call :_yd_dl` %1

    call :_yd_dl %1
    echo/ is done^^!!

    goto :eof

    :_yd_dl

    set "_tag_00=%1"
    set "_tag_01= -t 00:60:00 -v error -stats -vf fps=fps=60,scale=1920x1080 -c:v libx264 -preset superfast -c:a copy "
    for /f %%i in ('.\youtube-dl.exe -g !_tag_00! ^<nul ') do .\ffmpeg.exe  -i "%%i" !_tag_01! .\output.mp4

    exit /b 

复制完整视频:

  cls && @echo off & setlocal enableextensions enabledelayedexpansion 

    :: do some with the bat file, after then,  for all links need `call :_yd_dl` %1

    call :_yd_dl %1
    echo/ is done^^!!

    goto :eof

    :_yd_dl

    set "_tag_0=%1"
    set "_tag_1=--ignore-errors --abort-on-error --ignore-config --flat-playlist --geo-bypass "
    set "_tag_2=--restrict-filenames --no-part --no-cache-dir --write-thumbnail --prefer-ffmpeg "
    set "_tag_3=--ffmpeg-location .\ --postprocessor-args  -i "%%(title)s.%%(ext)s" -vf fps^=fps^=60^,"
    set "_tag_4=scale^=1920x1080 -c:v libx264 -b:v 500k -preset superfast -c:a copy -f segment -segment_time "
    set "_tag_5=60 %%^(title^)s.mp4"

    youtube-dl "!_tag_0!" -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "%%^(title^)s.%%^(ext^)s" !_tag_1!!_tag_2!!_tag_3!!_tag_4!!_tag_5!

    exit /b