Windows下使用批处理随机播放文件
先开好接收端
socat -u TCP-LISTEN:12345,fork,reuseaddr SYSTEM:"ffplay -autoexit -f wav -"
可以设置低延迟
socat -u TCP-LISTEN:12345,fork,reuseaddr SYSTEM:"stdbuf -o0 ffplay -nodisp -autoexit -fflags nobuffer -flags low_delay -infbuf -af anull -probesize 32 -analyzeduration 0 -f wav -"
@echo off
setlocal enabledelayedexpansion
set SERVER_IP=10.85.11.2
set PORT=12345
:: 初始化变量
set i=0
:parse_args
if "%~1"=="" goto build_done
:: 判断是否是目录
if exist "%~1\" (
pushd "%~1" >nul 2>nul
for /r %%f in (*) do (
set /a i+=1
set "arg[!i!]=%%~ff"
)
popd
) else if exist "%~1" (
set /a i+=1
set "arg[!i!]=%~1"
)
shift
goto parse_args
:build_done
if %i%==0 (
echo No valid files found.
pause
exit /b
)
set count=%i%
:: 无限随机播放
:loop
set /a randIndex=%random% %% count + 1
call set "filepath=%%arg[!randIndex!]%%"
title !filepath!
ffmpeg.exe -re -i "!filepath!" -f wav tcp://%SERVER_IP%:%PORT%
goto loop
本文来自博客园,作者:项希盛,转载请注明原文链接:https://www.cnblogs.com/xiangxisheng/p/19006884
浙公网安备 33010602011771号