Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file Powershell脚本-从批处理文件转换_Batch File_Powershell - Fatal编程技术网

Batch file Powershell脚本-从批处理文件转换

Batch file Powershell脚本-从批处理文件转换,batch-file,powershell,Batch File,Powershell,我将其作为批处理文件使用,但当我尝试转换到Powershell时,我的文件不像批处理文件中那样进行代码转换。它应该问两个输入问题,视频链接和本地ip地址。一旦找到了这两个输入问题的答案,Vlc播放器就应该打开视频链接,然后将文件从.flv格式实时转换为另一种格式,并在转换代码时开始在Vlc上播放。然后,我开始通过本地网络上的chrome浏览器在vidcast上播放转换后的文件,然后也可以使用chromecast将转换后的视频播放到电视上 我认为问题出在powershell脚本的粗体部分,但我没有

我将其作为批处理文件使用,但当我尝试转换到Powershell时,我的文件不像批处理文件中那样进行代码转换。它应该问两个输入问题,视频链接和本地ip地址。一旦找到了这两个输入问题的答案,Vlc播放器就应该打开视频链接,然后将文件从.flv格式实时转换为另一种格式,并在转换代码时开始在Vlc上播放。然后,我开始通过本地网络上的chrome浏览器在vidcast上播放转换后的文件,然后也可以使用chromecast将转换后的视频播放到电视上

我认为问题出在powershell脚本的粗体部分,但我没有这方面的经验,也不知道如何解决它。有人能帮忙吗

批处理文件

@echo off
set /p input="Insert your Http link: "
set /p input1="Insert your Local IP address: "
rem VLC
cd "C:\Program Files\VideoLAN\VLC"

start vlc.exe %input% :sout=#transcode{vcodec=VP80,vb=2000,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{mux=webm,dst=:8080/stream} :sout-all :sout-keep

cd "C:\Program Files (x86)\Google\Chrome\Application"
start chrome.exe "https://dabble.me/cast/?video_link=http://%input1%/stream"
exit
电源外壳

$link = read-host "Enter an Http Link "
$ip = read-host "Enter your Local Ip Address "

& "C:\Program Files\VideoLAN\VLC\vlc.exe" "$link" ":sout=#transcode{vcodec=VP80,vb=2000,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{mux=webm,dst=:8080/stream}:sout-all :sout-keep" 

& "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "https://dabble.me/cast/?video_link=http://$ip/stream"
您是否尝试过使用
参数列表
集合

Start-Process -FilePath 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe' -ArgumentList "$link",":sout=#transcode{vcodec=VP80,vb=2000,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{mux=webm,dst=:8080/stream}:sout-all :sout-keep"
启动进程
将文件路径(
-FilePath
)作为要启动的进程。然后,它需要一个参数字符串数组(
-ArgumentList
)与正在启动的可执行文件合并

FilePath
应该是可执行文件的完整路径(或相对路径,如果您愿意)

ArgumentList
应该是所有单独的参数,逗号分隔

总而言之,它应该是这样的:

Start-Process -FilePath "C:\Where\VLC\Is\Located.exe" -ArgumentList "1stArg"[,"2ndArg"[,...]]

这里完全是初学者。如果我按原样复制那行代码,它就不会启动vlc播放器。如果我要修改那一行,你能多给我一点说明吗?@user3444610,请阅读启动过程中的文档。我已经更新了我的答案来帮助你。如果我们知道您试图访问(链接)的内容,这将非常有帮助。该链接指向.flv格式的视频,然后将其转码为Chromecast可以理解的格式。Chromecast无法理解.flv格式。所以这行代码的问题是:sout=#transcode{vcodec=VP80,vb=2000,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{mux=webm,dst=:8080/stream}:sout all:sout-keep“我不确定哪些是参数,哪些不是参数,以及如何对其进行编码。我看看能不能研究一下怎么做。ThanksIt现在正在工作,尽管我确信代码可能不好。