EDN Admin
Well-known member
This is the code ublic void Start(string FileName, int BitmapRate)
{
p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p
ProcessStartInfo psi = new ProcessStartInfo();
//psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = false;
psi.FileName = @"Dipetestpipetestffmpegx86ffmpeg.exe";
psi.WorkingDirectory = @"Dipetestpipetestffmpegx86";
psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \.pipemytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + FileName;
process = Process.Start(psi);
process.EnableRaisingEvents = false;
p.WaitForConnection();
}
I want to keep the FileName and the WorkingDirectory to be the same as it now .
But in the Arguments i want that the file im creating test.avi for example will be out created on a directory i can select/change.
This is the entire code of using the process the ffmpeg.exe and the pipe im writing toublic void Start(string FileName, int BitmapRate)
{
p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p
ProcessStartInfo psi = new ProcessStartInfo();
//psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = false;
psi.FileName = @"Dipetestpipetestffmpegx86ffmpeg.exe";
psi.WorkingDirectory = @"Dipetestpipetestffmpegx86";
psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \.pipemytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + FileName;
process = Process.Start(psi);
process.EnableRaisingEvents = false;
p.WaitForConnection();
}
public void PushFrame(Bitmap bmp)
{
int length;
// Lock the bitmaps bits.
//bmp = new Bitmap(1920, 1080);
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
//Rectangle rect = new Rectangle(0, 0, 1280, 720);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
bmp.PixelFormat);
int absStride = Math.Abs(bmpData.Stride);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Declare an array to hold the bytes of the bitmap.
//length = 3 * bmp.Width * bmp.Height;
length = absStride * bmpData.Height;
byte[] rgbValues = new byte[length];
//Marshal.Copy(ptr, rgbValues, 0, length);
int j = bmp.Height - 1;
for (int i = 0; i < bmp.Height; i++)
{
IntPtr pointer = new IntPtr(bmpData.Scan0.ToInt32() + (bmpData.Stride * j));
System.Runtime.InteropServices.Marshal.Copy(pointer, rgbValues, absStride * (bmp.Height - i - 1), absStride);
j--;
}
p.Write(rgbValues, 0, length);
bmp.UnlockBits(bmpData);
The only thing i want is to put a variable of the output file name directory so i can change if i want.
For now the file name i give in Form1 :ffmp.Start("test.avi", 25);
Will be created all the time here : @"Dipetestpipetestffmpegx86ffmpeg.exe";
I want that the test.avi will be created in any directory i will select/change to.
View the full article
{
p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p
ProcessStartInfo psi = new ProcessStartInfo();
//psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = false;
psi.FileName = @"Dipetestpipetestffmpegx86ffmpeg.exe";
psi.WorkingDirectory = @"Dipetestpipetestffmpegx86";
psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \.pipemytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + FileName;
process = Process.Start(psi);
process.EnableRaisingEvents = false;
p.WaitForConnection();
}
I want to keep the FileName and the WorkingDirectory to be the same as it now .
But in the Arguments i want that the file im creating test.avi for example will be out created on a directory i can select/change.
This is the entire code of using the process the ffmpeg.exe and the pipe im writing toublic void Start(string FileName, int BitmapRate)
{
p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p
ProcessStartInfo psi = new ProcessStartInfo();
//psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = false;
psi.FileName = @"Dipetestpipetestffmpegx86ffmpeg.exe";
psi.WorkingDirectory = @"Dipetestpipetestffmpegx86";
psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \.pipemytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + FileName;
process = Process.Start(psi);
process.EnableRaisingEvents = false;
p.WaitForConnection();
}
public void PushFrame(Bitmap bmp)
{
int length;
// Lock the bitmaps bits.
//bmp = new Bitmap(1920, 1080);
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
//Rectangle rect = new Rectangle(0, 0, 1280, 720);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
bmp.PixelFormat);
int absStride = Math.Abs(bmpData.Stride);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Declare an array to hold the bytes of the bitmap.
//length = 3 * bmp.Width * bmp.Height;
length = absStride * bmpData.Height;
byte[] rgbValues = new byte[length];
//Marshal.Copy(ptr, rgbValues, 0, length);
int j = bmp.Height - 1;
for (int i = 0; i < bmp.Height; i++)
{
IntPtr pointer = new IntPtr(bmpData.Scan0.ToInt32() + (bmpData.Stride * j));
System.Runtime.InteropServices.Marshal.Copy(pointer, rgbValues, absStride * (bmp.Height - i - 1), absStride);
j--;
}
p.Write(rgbValues, 0, length);
bmp.UnlockBits(bmpData);
The only thing i want is to put a variable of the output file name directory so i can change if i want.
For now the file name i give in Form1 :ffmp.Start("test.avi", 25);
Will be created all the time here : @"Dipetestpipetestffmpegx86ffmpeg.exe";
I want that the test.avi will be created in any directory i will select/change to.
View the full article