为什么cmd只是打印命令而不起作用?

时间:2019-10-11 16:41:47

标签: vb.net ffmpeg

我尝试创建一个可以上传mp4的网站,然后我的服务器将其转码为ts并创建一个m3u8播放列表。     我想使用cmd来控制ffmpeg来做到这一点,而我使用Visual Basic来做到这一点。

这是我的代码:

  Dim fileName As String = "borderoflife"
  Dim file As String = "borderoflife.mp4"
  Dim appPath As String = "C:\allen0916\"
  Dim saveDir As String = "test2\"

  Dim savePath As String = appPath & saveDir
  Dim saveResult As String = savePath & file

  Dim Content_Type_A As String = "video/mp4"

  Dim m3u8Path As String = Path.Combine(savePath, fileName + ".m3u8")
  Dim para As String = String.Format("/C ffmpeg -i {0} -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls {1} ", saveResult, m3u8Path)

  Dim output As String = "none" 
  Dim p As Process = New Process()

  p.StartInfo.FileName = "cmd.exe"
  p.StartInfo.UseShellExecute = False 
  p.StartInfo.RedirectStandardInput = True 
  p.StartInfo.RedirectStandardOutput = True 
  p.StartInfo.RedirectStandardError = True 
  p.StartInfo.CreateNoWindow = True 
  p.Start()
  p.StandardInput.WriteLine(para) 
  p.StandardInput.WriteLine("exit")
  p.StandardInput.AutoFlush = True
  p.StandardInput.Close() 
  output = p.StandardOutput.ReadToEnd() 
  p.WaitForExit()
  p.Close()

 If System.IO.File.Exists(m3u8Path) <> True Then
      context.Response.Write(output)
  Else
      context.Response.Write("Success")
  End If  

并且每次输出仅返回:

Microsoft Windows [version 10.0.17763.737]
(c) 2018 Microsoft Corporation. 

c:\windows\system32\inetsrv>/C ffmpeg -i C:\allen0916\test2\borderoflife.mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls C:\allen0916\test2\borderoflife.m3u8 

c:\windows\system32\inetsrv>exit

似乎cmd.exe只是打印我的命令而无法正常工作, 有人知道为什么吗?

0 个答案:

没有答案