ffmpeg writer: cleanup
This commit is contained in:
parent
3abd2da5c6
commit
11d2216c98
|
@ -77,31 +77,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
void OpenFileSegment()
|
||||
{
|
||||
ffmpeg = new Process();
|
||||
try
|
||||
{
|
||||
ffmpeg = new Process();
|
||||
#if WINDOWS
|
||||
ffmpeg.StartInfo.FileName = System.IO.Path.Combine(PathManager.GetBasePathAbsolute(), "dll", "ffmpeg.exe");
|
||||
ffmpeg.StartInfo.FileName = System.IO.Path.Combine(PathManager.GetBasePathAbsolute(), "dll", "ffmpeg.exe");
|
||||
#else
|
||||
ffmpeg.StartInfo.FileName = "ffmpeg"; // expecting native version to be in path
|
||||
ffmpeg.StartInfo.FileName = "ffmpeg"; // expecting native version to be in path
|
||||
#endif
|
||||
|
||||
string filename = String.Format("{0}_{1,4:D4}{2}", baseName, segment, ext);
|
||||
string filename = String.Format("{0}_{1,4:D4}{2}", baseName, segment, ext);
|
||||
ffmpeg.StartInfo.Arguments = String.Format("-y -f nut -i - {1} \"{0}\"", filename, token.commandline);
|
||||
ffmpeg.StartInfo.CreateNoWindow = true;
|
||||
|
||||
ffmpeg.StartInfo.Arguments = String.Format("-y -f nut -i - {1} \"{0}\"", filename, token.commandline);
|
||||
// ffmpeg sends informative display to stderr, and nothing to stdout
|
||||
ffmpeg.StartInfo.RedirectStandardError = true;
|
||||
ffmpeg.StartInfo.RedirectStandardInput = true;
|
||||
ffmpeg.StartInfo.UseShellExecute = false;
|
||||
|
||||
ffmpeg.StartInfo.CreateNoWindow = true;
|
||||
commandline = "ffmpeg " + ffmpeg.StartInfo.Arguments;
|
||||
|
||||
// ffmpeg sends informative display to stderr, and nothing to stdout
|
||||
ffmpeg.StartInfo.RedirectStandardError = true;
|
||||
ffmpeg.StartInfo.RedirectStandardInput = true;
|
||||
ffmpeg.StartInfo.UseShellExecute = false;
|
||||
ffmpeg.ErrorDataReceived += new DataReceivedEventHandler(StderrHandler);
|
||||
|
||||
commandline = "ffmpeg " + ffmpeg.StartInfo.Arguments;
|
||||
stderr = new Queue<string>(consolebuffer);
|
||||
|
||||
ffmpeg.ErrorDataReceived += new DataReceivedEventHandler(StderrHandler);
|
||||
|
||||
stderr = new Queue<string>(consolebuffer);
|
||||
|
||||
ffmpeg.Start();
|
||||
ffmpeg.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
ffmpeg.Dispose();
|
||||
ffmpeg = null;
|
||||
throw;
|
||||
}
|
||||
ffmpeg.BeginErrorReadLine();
|
||||
|
||||
muxer = new NutMuxer(width, height, fpsnum, fpsden, sampleRate, channels, ffmpeg.StandardInput.BaseStream);
|
||||
|
@ -132,6 +139,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// how long should we wait here?
|
||||
ffmpeg.WaitForExit(20000);
|
||||
ffmpeg.Dispose();
|
||||
ffmpeg = null;
|
||||
stderr = null;
|
||||
commandline = null;
|
||||
|
@ -269,7 +277,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.channels = channels;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "FFmpeg writer";
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
// this code isn't really any good for general purpose nut creation
|
||||
|
||||
#region binary write helpers
|
||||
|
||||
/// <summary>
|
||||
/// variable length value, unsigned
|
||||
|
@ -100,6 +101,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
stream.Write(b, 0, 8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// big endian 32 bit unsigned
|
||||
/// </summary>
|
||||
|
@ -115,6 +117,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
stream.Write(b, 0, 4);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// big endian 32 bit unsigned
|
||||
/// </summary>
|
||||
|
@ -131,6 +134,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
stream.Write(b, 0, 4);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CRC calculator
|
||||
|
||||
static readonly uint[] CRCtable = new uint[]
|
||||
{
|
||||
0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9,
|
||||
|
@ -156,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return crc;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// writes a single packet out, including checksums
|
||||
|
@ -264,6 +271,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
#region fields
|
||||
|
||||
/// <summary>
|
||||
/// stores basic AV parameters
|
||||
|
@ -320,6 +328,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
Queue<NutFrame> audioqueue;
|
||||
|
||||
#endregion
|
||||
|
||||
#region header writers
|
||||
|
||||
/// <summary>
|
||||
/// write out the main header
|
||||
|
@ -409,6 +420,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
header.Flush();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// stores a single frame with syncpoint, in mux-ready form
|
||||
/// used because reordering of audio and video can be needed for proper interleave
|
||||
|
@ -502,14 +515,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
return left >= right;
|
||||
}
|
||||
|
||||
|
||||
static NutFrame()
|
||||
{
|
||||
//dbg = new StreamWriter(".\\nutframe.txt", false);
|
||||
}
|
||||
|
||||
//static StreamWriter dbg;
|
||||
|
||||
/// <summary>
|
||||
/// write out frame, with syncpoint and all headers
|
||||
/// </summary>
|
||||
|
@ -519,10 +524,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
dest.Write(data, 0, data.Length);
|
||||
//dbg.WriteLine(string.Format("{0},{1},{2}", pts, ptsnum, ptsden));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// write a video frame to the stream
|
||||
/// </summary>
|
||||
|
@ -540,9 +543,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
audioqueue.Dequeue().WriteData(output);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// write an audio frame to the stream
|
||||
/// </summary>
|
||||
|
@ -629,4 +629,3 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue