When I use this code, I can only download the stream.
When I use this code, yt-dlp pipe the stream to mpv but does not download any files.Code:%ytdlp% "%URL%" ^ --hls-prefer-native ^ --hls-use-mpegts ^ --continue ^ --no-part ^ --no-cache-dir ^ -v ^ -o "%OUTPUT%"
But if I try to put the output with mpv (-o "%OUTPUT%" - | "%MPV%" -), I get this errorCode:%ytdlp% "%URL%" ^ --hls-prefer-native ^ --hls-use-mpegts ^ --continue ^ --no-part ^ --no-cache-dir ^ -v ^ -o - | "%MPV%" -
What did I do wrong? Also, How can I add mpv syntax like -geometry=854x480?Code:ERROR: Fixed output name but more than one file to download:
+ Reply to Thread
Results 1 to 22 of 22
-
-
Thread moved to the video streaming downloading forum where you can get more help.
I think,therefore i am a hamster. -
1. ask to AI. it's full all web. choose Gemini, duckgo, OpenAI, and many others
2. join to yt-dlp discord server and ask here https://discord.gg/H5MNcFW63r
3. search mpv forum and ask there (https://www.mazdaforum.com/forum/mazda-mpv-17/) -
-
-o "%OUTPUT%" - | "%MPV%" -
a tool like streamlink can do this natively.
Code:streamlink -r file.ts --player mpv "URL" best
-
I would use Streamlink if it didn't depend on plugins to support some streams and the stream I want to download is only supported by yt-dlp.
-
streamlink supports direct m3u8 links too if that helps you.
in some situations, you can play the file as it downloads when using yt-dlp, but is a two-step process and you have to let it write a bit of the file first. -
But the link I want to download does not end with a ".m3u8".
I want to avoid that, I don't want to open files manually anymore. If in the same batch script I do yt-dlp download and pipe output to mpv I will have more control of what happens. If playback stops due to a source interruption before I stop the download, I'll know to take immediate action. -
Then try something like this:
Code:@echo off set "URL=https://live03-col.msf.cdn.mediaset.net/live/ch-fu/fu-clr.isml/manifest_hd.mpd" for /f %%a in ('powershell -Command "Get-Date -format yyyy.MM.dd#HH.mm.ss"') do set datetime=%%a start "" yt-dlp --hls-prefer-native --hls-use-mpegts --continue --no-part --no-cache-dir %URL% -o "%datetime%.mp4" timeout /t 9 /nobreak> nul vlc "%datetime%.mp4" exit
-
In fact, I use Windows, but if I have to use PowerShell to achieve what I need, then I'm not going to do it. I already tried something similar but PowerShell wouldn't let me use the variables I set.
Code:set URL=URL set CSN=ChannelName set CSR=VideoSize set CSS=StreamType set CDC=VideoCodec %CSR% AudioCodec kHz BitRate set CSTCMD=%CSN% %CSS% (%CSR% 16:9) set CSTMPV=%CSTCMD% TITLE %CSTCMD% - ytdlp COLOR 5F set YY=%date:~-4% set MM=%date:~-7,2% set DD=%date:~-10,2% set HH=%time:~0,2% set MN=%time:~3,2% set SC=%time:~6,2% set FDT=[%YY%-%MM%-%DD% %HH%h-%MN%m-%SC%s] set OUTPUT=%~d0\StreamRipping\youtube-dl\WEBdls/%CSN% (%CDC%) %FDT% (%CSR%).ts set MPV=%~d0\StreamRipping\Players\MPV_x64\mpv.exe set ytdlp=%~d0\StreamRipping\youtube-dl\bin\yt-dlp.exe
-
This seems to work, tested on windows 7 and windows 10: " 1080p.España, Flooxer.cmd ".
Code:@echo off& cd /D "%~dp0"& chcp 1252& cls set "URL=https://fast-channels.atresmedia.com/5c1285e47ed1a861f8125285/5c1285e47ed1a861f8125285.m3u8" set "CSN=España, Flooxer" set CSR=1920x1080 set CSS=HLS set CDC=h264 aac 48kHz 134kbs set CSTCMD=%CSN% %CSS% (%CSR% 16:9) set CSTMPV=%CSTCMD% TITLE %CSTCMD% - ytdlp COLOR 5F set YY=%date:~-4% set MM=%date:~-7,2% set DD=%date:~-10,2% set HH=%time:~0,2% set MN=%time:~3,2% set SC=%time:~6,2% set FDT=[%YY%-%MM%-%DD% %HH%h-%MN%m-%SC%s] set OUTPUT=%~d0\StreamRipping\youtube-dl\WEBdls/%CSN% (%CDC%) %FDT% (%CSR%).ts set MPV=%~d0\StreamRipping\Players\MPV_x64\mpv.exe set ytdlp=%~d0\StreamRipping\youtube-dl\bin\yt-dlp.exe start "%CSTCMD% - ytdlp" %ytdlp% --hls-prefer-native --hls-use-mpegts --continue --no-part --no-cache-dir %URL% -o "%OUTPUT%" if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if NOT exist "%OUTPUT%" timeout /t 1 /nobreak> nul if exist "%OUTPUT%" start "" %MPV% "%OUTPUT%"
Last edited by G.T.X.R; 15th Apr 2025 at 13:12.
-
@naoto89
Verified that this works
Pipe yt-dlp output to vlc video player
Code:yt-dlp "https://fast-channels.atresmedia.com/5c1285e47ed1a861f8125285/5c1285e47ed1a861f8125285.m3u8" -o - | vlc -
Code:yt-dlp "https://fast-channels.atresmedia.com/5c1285e47ed1a861f8125285/5c1285e47ed1a861f8125285.m3u8" -o - | mpv -
@G.T.X.R
Ever consider using a for or while loop instead of that list of wait statements?
@naoto89
Code:for /f %%a in ('powershell -Command "Get-Date -format yyyy.MM.dd#HH.mm.ss"') do set datetime=%%a
It is a called a powershell cmdlet and is a great technique to save the date/time into a variable. You should study it (incorporating cmdlets into your windows batch scripts) and thank @G.T.X.R for pointing it out to you
This below is an excellent way to initialize variables in win batch scripts
for /f %%a in (' place_your_code_here ') do set "variable_name=%%a"
place_your_code_here <== this can include piping of sed, grep, awk or whatever
This is very powerful.
Also, when you use set, always try to add "" to the statement ... look at what G.T.X.R did
set "URL=https://live03-col.msf.cdn.mediaset.net/live/ch-fu/fu-clr.isml/manifest_hd.mpd"
It removes any spaces that windows batch adds to the end of the declarationLast edited by Gromyko; 15th Apr 2025 at 14:30.
-
This is universal rec+play script, there are options inside - you can choose from >10 combinations:
set RX= ffmpeg¦streamlink¦N_m3u8DL-RE¦yt-dlp¦youtube-dl
set TX= MPV¦VLC
So you can use yt-dlp with VLC or yt-dlp with MPV or ffmpeg with VLC or streamlink (native too) with MPV etc. But first check or change path to executables on your system. * Not for contents with separate audio and video.
"_Universal.Rec-Play.Script_.cmd"
Code:@echo off& cd /D "%~dp0"& chcp 1252& cls ::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:: ::@@@ _ U n i v e r s a l . R e c - P l a y . S c r i p t _ @@@:: ::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:: set "URL=https://fast-channels.atresmedia.com/5c1285e47ed1a861f8125285/5c1285e47ed1a861f8125285.m3u8" set "CSN=España, Flooxer" set "CSR=1920x1080" set "CSS=HLS" set "CDC=h264 aac 48kHz 134kbs" set "CSTCMD=%CSN% %CSS% (%CSR% 16:9)" set "CSTMPV=%CSTCMD%" for /f %%a in ('powershell -Command "Get-Date -format [yyyy-MM-dd#HH\h.mm\m.ss\s]"') do set "FDT=%%a" set "MPV=%~d0\StreamRipping\Players\MPV_x64\mpv.exe" set "VLC=%ProgramFiles%\VideoLAN\VLC\vlc.exe" set "ffmpeg=%ProgramFiles%\Streamlink\ffmpeg\ffmpeg.exe" set "streamlink=%ProgramFiles%\Streamlink\bin\streamlink.exe" set "N_m3u8DL-RE=%SystemDrive%\Tvtools\N_m3u8DL-RE.exe" set "yt-dlp=%~d0\StreamRipping\youtube-dl\bin\yt-dlp.exe" set "youtube-dl=%SystemDrive%\Tvtools\youtube-dl.exe" rem s t a r t o p t i o n s : rem ===ffmpeg¦streamlink¦N_m3u8DL-RE¦yt-dlp¦youtube-dl=== set "RX=%yt-dlp%" rem ===================================================== rem ===streamlink native: true¦false===================== set "NAT=false" rem ===================================================== rem ===MPV¦VLC=========================================== set "TX=%VLC%" rem ===================================================== rem e n d o p t i o n s TITLE %CSTCMD% - %RX% COLOR 5F set "DIR=%~d0\StreamRipping\youtube-dl\WEBdls" set "OUTPUT=%CSN% (%CDC%) %FDT% (%CSR%)" set "EXT=ts" if "%RX%"=="%ffmpeg%" (start "%CSTCMD% - %RX%" "%RX%" -i %URL% "%DIR%\%OUTPUT%.%EXT%") if "%RX%"=="%streamlink%" ( if "%NAT%"=="true" ( start "%CSTCMD% - %RX%" "%RX%" -r "%DIR%\%OUTPUT%.%EXT%" --player "%TX%" %URL% best ) else if "%NAT%"=="false" ( start "%CSTCMD% - %RX%" "%RX%" %URL% best -o "%DIR%\%OUTPUT%.%EXT%" ) ) if "%RX%"=="%N_m3u8DL-RE%" (start "%CSTCMD% - %RX%" "%RX%" --live-real-time-merge --live-pipe-mux %URL% -sv best -sa best --save-dir "%DIR%" --save-name "%OUTPUT%" --tmp-dir "%temp%") if "%RX%"=="%yt-dlp%" (start "%CSTCMD% - %RX%" "%RX%" %URL% --hls-prefer-native --hls-use-mpegts --continue --no-part --no-cache-dir -o "%DIR%\%OUTPUT%.%EXT%") if "%RX%"=="%youtube-dl%" (start "%CSTCMD% - %RX%" "%RX%" %URL% --hls-prefer-native --hls-use-mpegts --continue --no-part --no-cache-dir -o "%DIR%\%OUTPUT%.%EXT%") if "%RX%" == "%streamlink%" ( if "%NAT%" == "true" ( goto EOF ) ) if exist "%DIR%\%OUTPUT%.%EXT%" goto play :wait timeout /t 1 /nobreak> nul if NOT exist "%DIR%\%OUTPUT%.%EXT%" goto wait :play start "" "%TX%" "%DIR%\%OUTPUT%.%EXT%"
-
It's a good code but there's some stuff I don't understand.
I always run my batch scripts inside subfolders on drives outside C:\, so in the .exe paths and output set in variables I use %~d0 instead the current drive letter to avoid change letters.
I noticed that this runs yt-dlp in a new CMD window where the yt-dlp activity is displayed instead the first CMD window, which shouldn't happen and would just open extra CMD windows. Also, if the download is interrupted by a source interruption, the yt-dlp window will close while the first CMD window will remain open because it has a PAUSE>NUL to prevent that window closing automatically. I also noticed that if you don't put start "" before %ytdlp%, %MPV% won't run even if yt-dl is still downloading.
I guess it's to kill time before the mpv opens and loads the output.
It only pipes stdout, there is no path to the downloaded file which is what should be piped.
This is even more amazing than the previous code, but I have a question about VLC. Is there a way to make VLC portable load its own custom settings instead of loading the settings saved in %AppData% of the local Windows user?Last edited by naoto89; 16th Apr 2025 at 09:06.
-
What does "tee" do? That doesn't work for me either.
Something I didn't realize before is that if I put ' -o - "%OUTPUT%" | "%MPV%" - ' instead of ' -o "%OUTPUT%" - | "%MPV%" - ', yt-dlp opens and pipes stdout to mpv, but yt-dlp still doesn't download the stream even though it's set to output after stdout. For yt-dlp to not be able to do something that FFmpeg+FFplay can, it means there's a bug. This is some code I use in FFmpeg, and notice how the output comes before stdout, both outputs work together and there is not problem.
Code:"%ffmpeg%" ^ -thread_queue_size 4096 ^ -i "%URL%" ^ -c copy ^ -reconnect true ^ -reconnect_at_eof true ^ -reconnect_on_network_error true ^ -reconnect_on_http_error "4xx, 5xx" ^ -reconnect_streamed true ^ -reconnect_delay_max 4294 ^ -multiple_requests true "%OUTPUT%" ^ -f mpegts ^ - | "%ffplay%" - ^ -x 854 ^ -y 480 ^ -window_title "%CSTFFP%"
-
-
° cd /D "%~dp0" at the start is useful in some circumstances, it is for confirm script position only, the rest (.exe paths and output) can use %~d0, that is not touched. Anyway you can skip this.
° %VLC% --config="%SystemDrive%\vlc2\vlcrc" for example allows to open vlc with an alternative config file which is located in the specified position. Also i try copy vlc.exe to another place, it works too with original config file. Add --config= for alternative config.
° My previous script, runs yt-dlp in a new CMD window because I couldn't find a way to do this all in one window. Only streamlink allows this by having native functionality.
But in this new script I used some tricks to reach all tasks in one window, unfortunately MPV is not compatible in most cases (maybe bug), only VLC can be used. Also, N_m3u8DL-RE not support redirecting, the script must open separate window for it.
_Universal.Rec-Play.Script.(Vers.0.2)_.cmd
Code:@echo off& cd /D "%~dp0"& chcp 1252& cls ::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:: ::@@@ _ U n i v e r s a l . R e c - P l a y . S c r i p t _ @@@:: ::@@@@@@@@@@@@@@@@@@@@@@vers 0.2@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:: set "URL=https://fast-channels.atresmedia.com/5c1285e47ed1a861f8125285/5c1285e47ed1a861f8125285.m3u8" set "CSN=España, Flooxer" set "CSR=1920x1080" set "CSS=HLS" set "CDC=h264 aac 48kHz 134kbs" set "CSTCMD=%CSN% %CSS% (%CSR% 16:9)" set "CSTMPV=%CSTCMD%" for /f %%a in ('powershell -Command "Get-Date -format [yyyy-MM-dd#HH\h.mm\m.ss\s]"') do set "FDT=%%a" set "VLC=%ProgramFiles%\VideoLAN\VLC\vlc.exe" set "ffmpeg=%SystemDrive%\Tvtools\ffmpeg.exe" set "streamlink=%ProgramFiles%\Streamlink\bin\streamlink.exe" set "N_m3u8DL-RE=%SystemDrive%\Tvtools\N_m3u8DL-RE.exe" set "yt-dlp=%SystemDrive%\Tvtools\yt-dlp.exe" set "youtube-dl=%SystemDrive%\Tvtools\youtube-dl.exe" rem s t a r t o p t i o n s : rem ==%ffmpeg%¦%streamlink%¦%N_m3u8DL-RE%¦%yt-dlp%¦%youtube-dl%== set "RX=%yt-dlp%" rem ============================================================= rem e n d o p t i o n s TITLE %CSTCMD% - %RX% COLOR 5F set "DIR=%SystemDrive%\TV" set "OUTPUT=%CSN% (%CDC%) %FDT% (%CSR%)" set "EXT=ts" echo.%DIR%\%OUTPUT%.%EXT%> "%DIR%\%OUTPUT%.%EXT%" timeout /t 2 /nobreak> nul if "%RX%"=="%ffmpeg%" ("%RX%" -y -i %URL% "%DIR%\%OUTPUT%.%EXT%"| "%VLC%" --quiet --meta-title="%CSTCMD% - %RX%" -f --directx-volume=1.0 "%DIR%\%OUTPUT%.%EXT%") if "%RX%"=="%streamlink%" ("%RX%" %URL% best --force -o "%DIR%\%OUTPUT%.%EXT%"| "%VLC%" --quiet --meta-title="%CSTCMD% - %RX%" -f --directx-volume=1.0 "%DIR%\%OUTPUT%.%EXT%") if "%RX%"=="%N_m3u8DL-RE%" ( del /f /q "%DIR%\%OUTPUT%.%EXT%" start "%CSTCMD% - %RX%" "%RX%" --live-real-time-merge --live-pipe-mux %URL% -sv best -sa best --save-dir "%DIR%" --save-name "%OUTPUT%" --tmp-dir "%temp%\RE" if exist "%DIR%\%OUTPUT%.%EXT%" goto play :wait timeout /t 1 /nobreak> nul if NOT exist "%DIR%\%OUTPUT%.%EXT%" goto wait :play start "" "%VLC%" --quiet --meta-title="%CSTCMD% - %RX%" -f --directx-volume=1.0 "%DIR%\%OUTPUT%.%EXT%" ) if "%RX%"=="%yt-dlp%" ("%RX%" %URL% --hls-prefer-native --hls-use-mpegts --continue --no-part --no-cache-dir --force-overwrite -o "%DIR%\%OUTPUT%.%EXT%"| "%VLC%" --quiet --meta-title="%CSTCMD% - %RX%" -f --directx-volume=1.0 "%DIR%\%OUTPUT%.%EXT%") if "%RX%"=="%youtube-dl%" ("%RX%" %URL% --hls-prefer-native --hls-use-mpegts --continue --no-part --no-cache-dir -o "%DIR%\%OUTPUT%.%EXT%"| "%VLC%" --quiet --meta-title="%CSTCMD% - %RX%" -f --directx-volume=1.0 "%DIR%\%OUTPUT%.%EXT%")
-
Instead of using tee, ffmpeg can be used. Works just as expected, but one thing I noticed is that if I use ffmpeg and aria2c (as downloader) in the same yt-dlp script, aria2c is avoided and doesn't appear in the Windows Task Manager.
I don't have VLC installed on Windows, but I use a portable version that is on another drive and I copy the folder of that version to the paths I want. No matter how many copies I make of VLC and the paths, it will always load the info that is in "%APPDATA%\vlc\vlc-qt-interface.ini". Is it possible to change this within VLC GUI and instead use the same directory where vlc.exe is located so that it can load its own config from there? If I do that, I could avoid add --config= to the batch script. Or am I wrong? -
Similar Threads
-
yt-dlp error
By cholla in forum Video Streaming DownloadingReplies: 2Last Post: 19th Mar 2025, 12:14 -
certification error with yt-dlp
By blanc in forum Video Streaming DownloadingReplies: 13Last Post: 29th Mar 2022, 07:53 -
Yt-dlp ERROR <urlopen error time out>
By Josh in forum Video Streaming DownloadingReplies: 9Last Post: 7th Jan 2022, 08:53 -
yt-dlp error "HTTP Error 403: Forbidden". MPD downloading [ABC.com site]
By nikshell29 in forum Video Streaming DownloadingReplies: 5Last Post: 26th Aug 2021, 15:18 -
Time of video and local mouse coordinates with MPV
By Gabrivolea in forum ProgrammingReplies: 6Last Post: 24th May 2021, 12:16