In windows, pretty easy to send pipe via cmd.exe, I simply write
.FileName = "cmd.exe"; and
.Arguments = "d:\ifme\addons\ffmpeg\ffmpeg -i d:\Videos\sata.mp4 -pix_fmt yuv420p -f yuv4mpegpipe - 2> nul | d:\ifme\addons\x265\x265lo -p medium --crf 28 -f 523 -o d:\ifme\temp\video.hevc --dither --y4m -";
but in Linux (Ubuntu 14.04.1) I write:
.FileName = "/bin/bash";
.Arguments = "-c /home/anime4000/Desktop/ifme/addons/ffmpeg/ffmpeg -i /home/anime4000/Videos/sata.mp4 -pix_fmt yuv420p -f yuv4mpegpipe - 2> /dev/null | /home/anime4000/Desktop/ifme/addons/x265/x265lo -p medium --crf 28 -f 523 -o /home/anime4000/Desktop/ifme/temp/video.hevc --dither --y4m -";
I got FFmpeg error which is no command specified...
I use create file method:
System.IO.File.WriteAllText("cmd.sh", "/home/anime4000/Desktop/ifme/addons/ffmpeg/ffmpeg -i /home/anime4000/Videos/sata.mp4 -pix_fmt yuv420p -f yuv4mpegpipe - 2> /dev/null | /home/anime4000/Desktop/ifme/addons/x265/x265lo -p medium --crf 28 -f 523 -o /home/anime4000/Desktop/ifme/temp/video.hevc --dither --y4m -");
.FileName = "sh";
.Arguments = "cmd.sh";
I got an error which is x265lo file not exist, but file was there with execute permission
So, how to get proper pipe command with C# Mono?
Note: x265lo is a 8 bit BPP build, x265hi is a 16 bit BPP build, because contain two x265 with different BPP
(Sorry, this should be a comment but I don't have enough reputation here.)
I don't know what's wrong specifically, but you should be able to determine how Mono calls your shell by doing something like this:
strace -fv -s4096 -e trace=execve /path/to/your/program args-to-your-program
Once you have done this, please update your question with the relevant execve() lines.
Related
I am currently trying to horizontally stack multiple video files and receiving this error
[libvorbis # 000001bb38f23a80] Queue input is backward in
timerate=N/A speed= 0x
[libvorbis # 000001bb38f23a80] Queue input is backward in
timetrate= 799.4kbits/s dup=0 drop=3894 speed=15.7x
[libvorbis # 000001bb38f23a80] Queue input is backward in
timetrate= 798.7kbits/s dup=0 drop=3924 speed=15.8x
[Parsed_hstack_2 # 000001bb3a3411c0] Input 1 height 480 does not
match input 0 height 360.op=3929 speed= 16x
[Parsed_hstack_2 # 000001bb3a3411c0] Failed to configure output pad
on Parsed_hstack_2
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argumentError
while processing the decoded data for stream #0:0
This is my command.
ffmpeg -i RT05974d20e9550b89697b15f8bc3feb78.mkv -i RTb295d0534191e1acb22a45bb971a12e6.mka -i RTc2de0d06575c6c225b44dbce73104ed8.mkv -i RT3904b3a60273760ec9e9c181ea35bdc4.mka -i RT13386752138abbe5eb941da3f7fdfdc5.mka -i RTe31da14ad7c898ad8d8ce6bbafc5e387.mkv -i RT103bfe5f4b129860f69cd8e820f3a10b.mka -i RT2e5859b6a555070f3305735c698966d0.mka -filter_complex "[2:v]tpad=start_duration=120:color=black[vpad]; [3:a]adelay=120000:all=1[a2pad]; [4:a]adelay=150000:all=1[a3pad]; [5:v]tpad=start_duration=20:color=black[v2pad]; [6:a]adelay=200000:all=1[a5pad]; [7:a]adelay=240000:all=1[a6pad]; [0:v][vpad][v2pad]hstack=inputs=3[vout]; [1:a][a2pad][a3pad][a5pad][a6pad]amix=inputs=5:weights=1|1|1|1|1[aout]" -map [vout] -map [aout] output.mkv
I then also checked each file individually to make sure that their height and width were correct.
ffprobe -v error -select_streams v -show_entries stream=width,height -of csv=p=0:s=x RT05974d20e9550b89697b15f8bc3feb78.mkv
640x480
ffprobe -v error -select_streams v -show_entries stream=width,height -of csv=p=0:s=x RTc2de0d06575c6c225b44dbce73104ed8.mkv
640x480
ffprobe -v error -select_streams v -show_entries stream=width,height -of csv=p=0:s=x RTe31da14ad7c898ad8d8ce6bbafc5e387.mkv
640x480
Full log pasted here - https://pastebin.com/0XEipXjA
Log when only two files are used - https://pastebin.com/AVYisBeh
Log when that first video file is not used (works) - https://pastebin.com/8YfHRsQ1
What am I doing incorrectly?
Looks like the first input's resolution is changing midway.
Suppress reinitializing filters, and force initial resolution using scale.
ffmpeg -reinit_filter 0 -i RT05974d20e9550b89697b15f8bc3feb78.mkv -i RTb295d0534191e1acb22a45bb971a12e6.mka -i RTc2de0d06575c6c225b44dbce73104ed8.mkv -i RT3904b3a60273760ec9e9c181ea35bdc4.mka -i RT13386752138abbe5eb941da3f7fdfdc5.mka -i RTe31da14ad7c898ad8d8ce6bbafc5e387.mkv -i RT103bfe5f4b129860f69cd8e820f3a10b.mka -i RT2e5859b6a555070f3305735c698966d0.mka -filter_complex "[0:v]scale=iw:ih,setsar=1[v0];[2:v]tpad=start_duration=120:color=black[vpad]; [3:a]adelay=120000:all=1[a2pad]; [4:a]adelay=150000:all=1[a3pad]; [5:v]tpad=start_duration=20:color=black[v2pad]; [6:a]adelay=200000:all=1[a5pad]; [7:a]adelay=240000:all=1[a6pad]; [v0][vpad][v2pad]hstack=inputs=3[vout]; [1:a][a2pad][a3pad][a5pad][a6pad]amix=inputs=5:weights=1|1|1|1|1[aout]" -map [vout] -map [aout] output.mkv
Given the following C#/.NET console application running on my Azure Batch Pool/Task:
class Program
{
static async Task Main(string[] args)
{
try
{
Console.WriteLine(args[0]);
Console.WriteLine(args[1]);
}
catch
{
Console.WriteLine($"Could not parse arguments");
}
}
}
How can I pass the args when adding a command line to my tasks in a Linux/Ubuntu VM. I have tried the following with no success:
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -args 'arg1' 'arg2'
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -args 'arg1', 'arg2'
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program 'arg1' 'arg2'
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program 'arg1', 'arg2'
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -i 'arg1' 'arg2'
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -i 'arg1', 'arg2'
I am able to run the application but the arguments are not passed in and I only get to the "Could not parse arguments" output...
After throwing every variation possible at this (and looking at this example) it looks like you have to concatenate the string value of the package name with the args to the environment variable in a certain way to make sure the parameters carry through to the command.
Here is what finally did it for me
/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0"/Program 'arg1' 'arg2'"
Hope this helps anyone who is looking for it!
So im trying to run multiple commands in a one command line, im using WGET to download a few files to a local path this part works so far.
Here is what Ive got
startInfo.Arguments = #"/K wget -x -np -S -N -nH -r -R ""index.html*""
http://my-server.ip -P """ +
Properties.Settings.Default.userAddonDir+" && exit";
with this I should expect CMD to launch WGET with the command line:
-x -np -S -N -nH -r -R ""index.html*""
from my server:
http://my-server.ip
to my users local path for example:
E:/Folder/Sub Folder/
then once wget is finished it should see
&& Exit
and close cmd...
things to note, the users local path is likely to have white space so I've wrapped it in quotes to prevent the path being cut off. (hence all the quotes)
but what the path resolves to is odd. not to sure
E:/Folder/Sub Folder/ && exit/
If I place any more "" it breaks any ideas or pointers as im at a loss.
Thanks in advance.
Change your command to
string x = #"E:\temp";
string t = #"/K wget -x -np -S -N -nH -r -R ""index.html*"" http://my-server.ip -P """ +
x + #""" && exit";
After the operator + the initial verbatim character is no more effective. You need to reapply it to the last part of your string constant && exit
However, have you tried to launch your command with /C instead of /K?
This will automatically close the command window so you don't need anymore the Exit command
I have a php code that calls ffmpeg from the windows command line (because I run apache locally) with:
//ffmpeg -i input.mp4 -r 20 output.gif
echo exec('C:\ffmpeg\bin\ffmpeg.exe -i videos/file.avi -r 10 -s 450x230 videos/file.gif');
And it works fine! Now I wrote a C# program and I try to do the same thing with:
System.Diagnostics.Process.Start
but it fails.
Question: How do I execute the same command from the PHP code but from inside a C# code?
Process process = Process.Start(
new ProcessStartInfo
{
FileName = #"C:\ffmpeg\bin\ffmpeg.exe",
Arguments = "-i videos/file.avi -r 10 -s 450x230 videos/file.gif",
WindowStyle = ProcessWindowStyle.Hidden
}
);
process.WaitForExit();
If it fails an exception will be raised, e.g.
System.ComponentModel.Win32Exception with HResult=-2147467259 if the executable wasn't found.
I am trying to Run DelTemp-Final.vbs on a remote server which is being imported from a web portal.
I tried to use native C# to get the task done, No luck. So I opted for PS tools to help me out. I am stuck with he below scenario. Please help
Psexec is working using command prompt, but not working with c#
Below is the command prompt output which is working fine:
C:\inetpub\wwwroot\DelTemp\Scripts>psexec \\testusit1 -u XXXX\xxxxxxx -p xxxx
Xxxxxxxx -accepteula -i 0 -d c:\windows\system32\cscript.exe /nologo "\\testusi
t2\C$\karthik\DelTemp-Final.vbs"
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
c:\windows\system32\cscript.exe started on testusit1 with process ID 5452.
C:\inetpub\wwwroot\DelTemp\Scripts>psexec \\testusit2 -u XXXX\xxxxxxx -p xxxxx
xxxxxxxxx -accepteula -i 0 -d c:\windows\system32\cscript.exe /nologo "\\testusi
t2\C$\karthik\DelTemp-Final.vbs"
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
c:\windows\system32\cscript.exe started on testusit2 with process ID 7416.
Whereas, the same command does not work when included with c# in asp.net
Process p=new Process();
p.StartInfo.UseShellExecute=false;
p.StartInfo.RedirectStandardOutput=true;
p.StartInfo.RedirectStandardError=true;
p.StartInfo.RedirectStandardInput=true;
p.StartInfo.FileName=#"C:\inetpub\wwwroot\DelTemp\Scripts\PsExec.exe";
p.StartInfo.Arguments="\\\\"+li.Text+" -u XXXX\\xxxxxx -p xxxxxxxxxxx -accepteula -i 0 -d c:\\windows\\system32\\cscript.exe /nologo \\\\testusit2\\C$\\karthik\\DelTemp-Final.vbs";
p.Start();
string output=p.StandardOutput.ReadToEnd();
string errormessage=p.StandardError.ReadToEnd();
p.WaitForExit();
txtValueA.Text +="PSexec argument :" + p.StartInfo.Arguments;
txtValueA.Text +="<br/> Output : " + output+"| error messsage: "+errormessage;
Output of the above code for two servers is as follows:
PSexec argument :\\testusit1 -u XXXX\xxxxxxxxxx -p xxxxxxxxxx -accepteula -i 0 -d
c:\windows\system32\cscript.exe /nologo \\testusit2\C$\karthik\DelTemp-Final.vbs Output : | error
messsage: PsExec v2.11 - Execute processes remotely Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com The handle is invalid. Connecting to testusit1... Starting
PSEXESVC service on testusit1... Connecting with PsExec service on testusit1... Error deriving
session key:
PSexec argument :\\testusit2 -u XXXX\xxxxxxxxxxx-p xxxxxxxxxx -accepteula -i 0 -d
c:\windows\system32\cscript.exe /nologo \\testusit2\C$\karthik\DelTemp-Final.vbs Output : | error
messsage: PsExec v2.11 - Execute processes remotely Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com Access is denied. Connecting to testusit2... Starting PSEXESVC
service on testusit2... Could not start PSEXESVC service on testusit2: Connecting to testusit2...
Starting PSEXESVC service on testusit2...
Please assist.. Is there any changes I need to do to the script? Any help is greatly appreciated.
Thanks a lot in advance :)
Try directing your output to an event handler instead. I just ran a variation of this on my server with psexec executing ipconfig on the remote machine and I was able to view all output.
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.FileName = #"C:\inetpub\wwwroot\DelTemp\Scripts\PsExec.exe";
p.StartInfo.Arguments = "\\\\" + li.Text + " -u XXXX\\xxxxxx -p xxxxxxxxxxx -accepteula -i 0 -d c:\\windows\\system32\\cscript.exe /nologo \\\\testusit2\\C$\\karthik\\DelTemp-Final.vbs";
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
txtValueA.Text += "PSexec argument :" + p.StartInfo.Arguments;
txtValueA.Text += "<br/> Output : " + output + "| error messsage: " + errormessage;
}
public static void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
}
//Standard output event handler for PSEXEC
public static void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
}