Reputation: 47
string strParam;
string Path_FFMPEG = @"C:\Windows\system32\cmd.exe";
string WorkingDirectory = @"C:\Users\Braintech\documents\visual studio 2013\Projects\convertVideo\convertVideo";
string command1 = "ffmpeg -i video1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts";
string command2 = "ffmpeg -i video2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts";
string command3 = "ffmpeg -i" + "concat:intermediate1.ts|intermediate2.ts" + " -c copy -bsf:a aac_adtstoasc Output.mp4";
string Command = @"" + command1 + " & " + command2 + " & " + command3 + " ";
strParam = "ffmpeg -f concat -i " + file + " -c copy " + strResult;
process(Path_FFMPEG, Command, WorkingDirectory);
public static void process(string Path_FFMPEG, string Command, string WorkingDirectory)
{
try
{
Process ffmpeg = new Process();
ProcessStartInfo ffmpeg_StartInfo = new ProcessStartInfo(Path_FFMPEG, Command);
ffmpeg_StartInfo.WorkingDirectory = WorkingDirectory;
ffmpeg_StartInfo.UseShellExecute = false;
ffmpeg_StartInfo.RedirectStandardError = true;
ffmpeg_StartInfo.RedirectStandardOutput = true;
ffmpeg.StartInfo = ffmpeg_StartInfo;
ffmpeg_StartInfo.CreateNoWindow = true;
ffmpeg.EnableRaisingEvents = true;
ffmpeg.Start();
ffmpeg.WaitForExit(30000);
ffmpeg.Close();
ffmpeg.Dispose();
ffmpeg = null;
}
catch (Exception ex)
{
}
}
I m trying to merge two video using ffmpeg. But it is working manually but not able to execute using c# code.it works when i run the command on cmd manually. But when i am trying to run using c# it not works.Please help someone. Thanks in advance.
Upvotes: 0
Views: 1192
Reputation: 35
issue is with the path. you should give file path in your Commands
may be the below code will help
in which the mylist.txt file contain
file '01.mp4' file '04.mp4'
Dim _ffmpeg As String = "D:\Develop\Experiment\mergermp4Vb\mergermp4Vb\Videos\ffmpeg.exe"
Dim params = "-f concat -i D:\Develop\Experiment\mergermp4Vb\mergermp4Vb\Videos\mylist2.txt -c copy D:\Develop\Experiment\mergermp4Vb\mergermp4Vb\Videos\0104.mp4"
Dim _FFmpegProcessPropertys As New ProcessStartInfo
_FFmpegProcessPropertys.FileName = _ffmpeg
_FFmpegProcessPropertys.Arguments = params
_FFmpegProcessPropertys.UseShellExecute = False
_FFmpegProcessPropertys.RedirectStandardOutput = True
_FFmpegProcessPropertys.RedirectStandardError = True
_FFmpegProcessPropertys.CreateNoWindow = True
Dim FFmpegProcess = Process.Start(_FFmpegProcessPropertys)
Upvotes: 0
Reputation: 3237
Returning the byte
array is really a NO-go.
So, instead of returning the whole video as a byte
array, why not saving it somewhere (ex. your Web API), if it's not already saved as a file, and send the video URI back as the response?
The video player you are going to use will for sure know how to handle that URI.
Another option is to enable 206 PARTIAL CONTENT
support in your Web API and use the URI of your Web API in your video player.
See here https://stackoverflow.com/a/33634614/2528907
Upvotes: 0
Reputation: 1062855
Basically, don't try to load it into an array. For large files, you should have a range of overloads of the File()
method that take a path or Stream
, and know what to do. For example:
return File("/TestVideo/Wildlife.wmv", "video/x-ms-wmv");
or:
return File(videoPath, "video/x-ms-wmv");
However, video is really a special case and may benefit from more specialized handling.
Upvotes: 1