/// <summary> /// Close player for writing frames. /// </summary> public void CloseWrite() { if (!OpenedForWriting) { throw new InvalidOperationException("Player is not opened for writing frames!"); } try { try { if (!ffplayp.HasExited) { ffplayp.Kill(); } } catch { } InputDataStream.Dispose(); } finally { OpenedForWriting = false; } }
/// <summary> /// Closes output audio file. /// </summary> public void CloseWrite() { if (!OpenedForWriting) { throw new InvalidOperationException("File is not opened for writing!"); } try { InputDataStream.Dispose(); ffmpegp.WaitForExit(); csc?.Cancel(); if (!UseFilename) { OutputDataStream?.Dispose(); } try { if (ffmpegp?.HasExited == false) { ffmpegp.Kill(); } } catch { } } finally { OpenedForWriting = false; } }
/// <summary> /// Writes frame to output. Make sure to call OpenWrite() before calling this. /// </summary> /// <param name="frame">Frame containing media data</param> public virtual void WriteFrame(Frame frame) { if (!OpenedForWriting) { throw new InvalidOperationException("Media needs to be prepared for writing first!"); } InputDataStream.Write(frame.RawData.Span); }