Ok. I built a custom ffmpeg wrapper but it was just a dirty hack. it was not encapsulated clean.... it worked but it was just tooo ugly to develop some extension... wrapping looked something like this:
THIS DOES NOT WORK it is refactored to death:
class MencoderSharp
{
public static bool mencoder(System.Uri infovdrpath, string ratio, System.Uri destinationpath, BackgroundWorker worker, bool deleteConverted,string audioparameter, string videoparamter, bool testRun, DoWorkEventArgs e)
{
int returncode = 0;
foreach (string sourcepath in Directory.GetFiles(infovdrpath.ToString().Substring(0, infovdrpath.ToString().Length - 9), "0*.vdr"))
{
Process p = new Process();
//p.StartInfo.WorkingDirectory = @"C:\whatever";
p.StartInfo.FileName = @"mencoder.exe";
//http://msdn.microsoft.com/de-de/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
string arguments;
if (ratio == "4/3")
{
//4:3
arguments = "\"" + sourcepath + "\" " +audioparameter + " " + videoparamter + " " + destinationpath;
}
else
{
//16:9
arguments = "\"" + sourcepath + "\" " + audioparameter + " " + videoparamter + " " + destinationpath;
}
// for testing:
if (testRun)
{
//nur die ersten 6 sekunden mencodieren:
arguments = arguments + " -endpos 6";
}
//richTextBox1.Text = "\n\n" + richTextBox1.Text + arguments + "\n";
//p.StartInfo.Arguments = sourcepath + " -oac copy -aid 128 -ovc xvid -xvidencopts bitrate=800:aspect="+ratio+" -vf scale=-10:-1 -o \"" + destinationpaht + "\"";
//richTextBox1.Text += arguments;
p.StartInfo.Arguments = arguments;
//p.StartInfo.CreateNoWindow = true;
//richTextBox1.Text += arguments + "\n";
p.Start();
//nur eins darf synchron gelesen werden!! http://msdn.microsoft.com/de-de/library/system.diagnostics.processstartinfo.redirectstandarderror.aspx
//richTextBox1.Text = richTextBox1.Text + p.StandardOutput.ReadToEnd();
//richTextBox1.Text = richTextBox1.Text + p.StandardError.ReadToEnd();
if (worker.CancellationPending)
{
e.Cancel = true;
}
p.WaitForExit();
e.Result = p.ExitCode;
//Wenn das Konvertieren erfolgreich war, dann lösche doch bitte das original
if (p.ExitCode != 0)
{
returncode = 1;
}
//worker.ReportProgress(p.ExitCode);
}
if (returncode == 0)
{
foreach (string sourcepath in Directory.GetFiles(infovdrpath.Substring(0, infovdrpath.Length - 9), "0*.vdr"))
{
//Filenamen für die temporären transkodierten Datein generieren
string tempfilename = destinationpath.Insert(destinationpath.Length - 4, sourcepath.Substring(sourcepath.Length - 7, 3));
File.Move(tempfilename, tempfilename.Substring(0, tempfilename.Length - 4) + ".avi");
}
if (!testRun)
{
Directory.Delete(infovdrpath.Substring(0, infovdrpath.Length - 9), true);
richTextBox1.Text += infovdrpath.Substring(0, infovdrpath.Length - 9) + " wurde gelöscht\n";
}
}
else
{
//Wenn die Transkodierung unerfolgreich war, dann bitte die tmpdatein löschen
foreach (string sourcepath in Directory.GetFiles(infovdrpath.Substring(0, infovdrpath.Length - 9), "0*.vdr"))
{
//Filenamen für die temporären transkodierten Datein generieren
string tempfilename = destinationpath.Insert(destinationpath.Length - 4, sourcepath.Substring(sourcepath.Length - 7, 3));
if (File.Exists(tempfilename))
File.Delete(tempfilename);
}
}
}
}
.net
.net Wrapper for libvlc - use vlc to play videos in .net
http://wiki.videolan.org/C_Sharp
Conclusion:
By now JAVE seems to be the most attraktive ffmpeg wrapper for a highlevel lanugage. see http://www.sauronsoftware.it/projects/jave/manual.php#9 for what i mean. maybe i report later if it does the job ...
THIS DOES NOT WORK it is refactored to death:
class MencoderSharp
{
public static bool mencoder(System.Uri infovdrpath, string ratio, System.Uri destinationpath, BackgroundWorker worker, bool deleteConverted,string audioparameter, string videoparamter, bool testRun, DoWorkEventArgs e)
{
int returncode = 0;
foreach (string sourcepath in Directory.GetFiles(infovdrpath.ToString().Substring(0, infovdrpath.ToString().Length - 9), "0*.vdr"))
{
Process p = new Process();
//p.StartInfo.WorkingDirectory = @"C:\whatever";
p.StartInfo.FileName = @"mencoder.exe";
//http://msdn.microsoft.com/de-de/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
string arguments;
if (ratio == "4/3")
{
//4:3
arguments = "\"" + sourcepath + "\" " +audioparameter + " " + videoparamter + " " + destinationpath;
}
else
{
//16:9
arguments = "\"" + sourcepath + "\" " + audioparameter + " " + videoparamter + " " + destinationpath;
}
// for testing:
if (testRun)
{
//nur die ersten 6 sekunden mencodieren:
arguments = arguments + " -endpos 6";
}
//richTextBox1.Text = "\n\n" + richTextBox1.Text + arguments + "\n";
//p.StartInfo.Arguments = sourcepath + " -oac copy -aid 128 -ovc xvid -xvidencopts bitrate=800:aspect="+ratio+" -vf scale=-10:-1 -o \"" + destinationpaht + "\"";
//richTextBox1.Text += arguments;
p.StartInfo.Arguments = arguments;
//p.StartInfo.CreateNoWindow = true;
//richTextBox1.Text += arguments + "\n";
p.Start();
//nur eins darf synchron gelesen werden!! http://msdn.microsoft.com/de-de/library/system.diagnostics.processstartinfo.redirectstandarderror.aspx
//richTextBox1.Text = richTextBox1.Text + p.StandardOutput.ReadToEnd();
//richTextBox1.Text = richTextBox1.Text + p.StandardError.ReadToEnd();
if (worker.CancellationPending)
{
e.Cancel = true;
}
p.WaitForExit();
e.Result = p.ExitCode;
//Wenn das Konvertieren erfolgreich war, dann lösche doch bitte das original
if (p.ExitCode != 0)
{
returncode = 1;
}
//worker.ReportProgress(p.ExitCode);
}
if (returncode == 0)
{
foreach (string sourcepath in Directory.GetFiles(infovdrpath.Substring(0, infovdrpath.Length - 9), "0*.vdr"))
{
//Filenamen für die temporären transkodierten Datein generieren
string tempfilename = destinationpath.Insert(destinationpath.Length - 4, sourcepath.Substring(sourcepath.Length - 7, 3));
File.Move(tempfilename, tempfilename.Substring(0, tempfilename.Length - 4) + ".avi");
}
if (!testRun)
{
Directory.Delete(infovdrpath.Substring(0, infovdrpath.Length - 9), true);
richTextBox1.Text += infovdrpath.Substring(0, infovdrpath.Length - 9) + " wurde gelöscht\n";
}
}
else
{
//Wenn die Transkodierung unerfolgreich war, dann bitte die tmpdatein löschen
foreach (string sourcepath in Directory.GetFiles(infovdrpath.Substring(0, infovdrpath.Length - 9), "0*.vdr"))
{
//Filenamen für die temporären transkodierten Datein generieren
string tempfilename = destinationpath.Insert(destinationpath.Length - 4, sourcepath.Substring(sourcepath.Length - 7, 3));
if (File.Exists(tempfilename))
File.Delete(tempfilename);
}
}
}
}
.net
FFlib.NET
http://www.intuitive.sk/fflib/
- source code available for money
- free for personal and commercial use
- Last Rlease: 2008
ffmpeg-sharp
http://code.google.com/p/ffmpeg-sharp/
- GPL
- Last Rlease: 2009
SharpFFmpegJava
http://sourceforge.net/projects/sharpffmpeg/
- Last Rlease: 2006
JAVEOfftopic:
http://www.sauronsoftware.it/projects/jave/
Sample:
- GPL
- Last Rlease: 2009
public void encode(java.io.File source, java.io.File target, it.sauronsoftware.jave.EncodingAttributes attributes)
FOBS
http://fobs.sourceforge.net/
- GPL
- Last Rlease: 2008
FFMPEG-Java
http://fmj-sf.net/ffmpeg-java/getting_started.php
JMF wrapper for ffmpeg
http://sourceforge.net/projects/jffmpeg/files/jffmpeg/
- GPL, LGPL
- Last Rlease: 2006
.net Wrapper for libvlc - use vlc to play videos in .net
http://wiki.videolan.org/C_Sharp
Conclusion:
By now JAVE seems to be the most attraktive ffmpeg wrapper for a highlevel lanugage. see http://www.sauronsoftware.it/projects/jave/manual.php#9 for what i mean. maybe i report later if it does the job ...
Kommentare
Gruß, Jo
JAVE will nur java.io.file als parameter. das ist unbrauchbar für mich. ich will sourcen, die über ftp abzuholen sind, benutzen.
Sonst hat das ding, soweit ich mich erinnern kann, ganz gut funktioniert.
gruss stefan