Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Process proc = new Process();
proc.StartInfo.FileName = Path.Combine(WorkingFolder, "ffmpeg");
proc.StartInfo.Arguments = String.Format("$ ffmpeg -i input.mp3 pipe:1");
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
FileStream baseStream = proc.StandardOutput.BaseStream as FileStream;
byte[] audioData;
int lastRead = 0;
using (MemoryStream ms = new MemoryStream())
byte[] buffer = new byte[5000];
lastRead = baseStream.Read(buffer, 0, buffer.Length);
ms.Write(buffer, 0, lastRead);
} while (lastRead > 0);
audioData = ms.ToArray();
using(FileStream s = new FileStream(Path.Combine(WorkingFolder, "pipe_output_01.mp3"), FileMode.Create))
s.Write(audioData, 0, audioData.Length);
It's log from ffmpeg, the first file is readed:
Input #0, mp3, from 'norm.mp3':
Metadata:
encoder : Lavf58.17.103
Duration: 00:01:36.22, start: 0.023021, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.27
Then pipe:
[NULL @ 0x7fd58a001e00] Unable to find a suitable output format for '$'
$: Invalid argument
If I run "-i input.mp3 pipe:1", the log is:
Unable to find a suitable output format for 'pipe:1' pipe:1: Invalid
argument
How do I set correct output? And how should ffmpeg know what the output format is at all?
–
Whenever you use a pipe out in ffmpeg, you need the
-f fmt
parameter to avoid the error you are seeing.
You can get a list of possible formats by typing
ffmpeg -formats
.
If you want a wav file for instance, add
-f wav
.
In your example, arguments should be:
-i input.mp3 -f wav pipe:1
You can replace wav with flac or any other audio format you like.
Looks to me like there's a typo in
"$ ffmpeg -i input.mp3 pipe:1"
. If you just want to invoke
ffmpeg
with options like
-i
and so on, leave out the
$
character.
Just
"ffmpeg -i input.mp3 pipe:1"
.
. You already pass the main program name in
StartInfo.FileName
. So you should probably leave that out too. Try just
"-i input.mp3 pipe:1"
as your
Arguments
.
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.