SHA256
Add Render Cleanup Logic
This commit is contained in:
1 parent
459b2f3b0e
commit
f4062912a0
3 files changed
+143
-7
No files matched your search
@@ -6,7 +6,7 @@ using Unity.Collections;
|
||||
|
||||
namespace ADOFAIRenderer.Util.FFmpeg
|
||||
{
|
||||
public class FFmpegProcess
|
||||
public class FFmpegProcess : IDisposable
|
||||
{
|
||||
public static string FFmpegPath = "";
|
||||
|
||||
@@ -47,9 +47,58 @@ namespace ADOFAIRenderer.Util.FFmpeg
|
||||
public void Close()
|
||||
{
|
||||
if (_ffmpegProcess == null || _ffmpegProcess.HasExited || _inputStream == null) return;
|
||||
_inputStream.Flush();
|
||||
_inputStream.Close();
|
||||
_ffmpegProcess.WaitForExit();
|
||||
try
|
||||
{
|
||||
_inputStream.Flush();
|
||||
_inputStream.Close();
|
||||
|
||||
// Allow FFmpeg to finish encoding and exit gracefully without any timeout to prevent video corruption
|
||||
_ffmpegProcess.WaitForExit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore any issues during termination
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ffmpegProcess.Dispose();
|
||||
_ffmpegProcess = null;
|
||||
_inputStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_ffmpegProcess != null && !_ffmpegProcess.HasExited)
|
||||
{
|
||||
_ffmpegProcess.Kill();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore process already exited or access denied errors during cleanup
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
_inputStream?.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
_ffmpegProcess?.Dispose();
|
||||
_ffmpegProcess = null;
|
||||
_inputStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Kill();
|
||||
}
|
||||
|
||||
public static byte[] RentRawBytes(int size)
|
||||
|
||||
Reference in new issue
Block a user