Search code examples
cmdffmpegyoutube-dl

How to convert a script from youtube-dl


There is a bash/batch file script:

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

The script is not mine, but it allows you to record video with a constant frame rate of parts. Unfortunately in cmd it does not work for me. Already tried everything, I do not know what the error is.

I am getting No such file or directory.

Tried 'youtube-dl https://www.twitch.tv/zero', the same error

I tried "youtube-dl https://www.twitch.tv/zero", error: youtube-dl https://www.twitch.tv/zero: Invalid argument

What am I doing wrong? The author assures that he works on linux

Update

I tried ffmpeg -i $ (youtube-dl -f best -g https://www.twitch.tv/zero) .... The same error

Update 2

Why the video size exceeds 500 Mb? What am I doing wrong?

enter image description here enter image description here

Code

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

Update 3

enter image description here


Solution

  • Please, pay attention to some points below:

    • So, if I really understand your question, and it is about batch file/cmd in Windows, you would need to put the path to ffmpeg.exe in a variable, so it can be accessible to youtube-dl found it.
    • Or, in my sample above, in same path and in variable argument tool, so, youtube-dl amd ffmepg.exe are in same folder/path = .\\.
    • The link in this question, is offline, so I changed this link to an another online: cmd output

    I’ll save this code by name yt-DL.cmd

    Copy only a specific time by: Only edit _tag_1 value: -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 
    

    copy full video by:

      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