Provides a wrapper around the ffmpeg command line and process.
More...
|
static void | SetCmdParam (string name, string value) |
| Sets the value for a variable that can be used in the command arguments.
|
|
static string | GetCmdParam (string name) |
| Get the value that a command variable will be replaced with.
|
|
static string | GetExecutableDir () |
|
static string | GetExecutablePath (bool quoted=false) |
|
static bool | ExecutableExists (bool actuallyCheck=false) |
|
static bool | IsRunning () |
| - Returns
- Whether the ffmpeg executable is running.
|
|
static void | InitParams () |
| Initializes certain parameters, such as video output size (based on window size) and output file name (based on current time).
|
|
static void | LoadConfig () |
| Reads some settings from PlayerPrefs.
|
|
static void | SaveConfig () |
| Saves some settings to PlayerPrefs.
|
|
static void | StartRecording () |
| Starts the FFmpeg executable, which will be ready to accept frames sent to it with ReceiveFrame(ref NativeArray<byte>, uint).
|
|
static void | ReceiveFrame (ref NativeArray< byte > narray, uint frameNum) |
| Passes a frame to FFmpeg while recording.
|
|
static void | EndRecording () |
| (Asynchronously) waits half a second for frames to finish being sent, then tells ffmpeg that frames are done being sent and closes ffmpeg.
|
|
static void | ForceKill () |
| Forcibly closes ffmpeg.
|
|
|
static float | VideoScale = 1f |
| The amount the output resolution will be scaled by from the window resolution.
|
|
static int | w |
| The final output size, based on the window size and VideoScale.
|
|
static readonly string | ExecArgsDef |
| The default execution arguments, with unparsed variables.
|
|
static readonly float | ArgsVer = 1f |
|
|
static uint | FrameRate [get, set] |
| The framerate the video will be recorded with.
|
|
static bool | IsRecording = false [get, set] |
| Is ffmpeg currently running and recording frames.
|
|
static bool | IsReencoding = false [get, set] |
| Currently not used, but may be used if the initial output needs to be modified, such as recompressed, changed, or audio added.
|
|
static int int h | VideoSize [get] |
|
static string | ExecArgs = ExecArgsDef [get, set] |
| The current execution arguments, with unparsed variables.
|
|
static string | OutDir = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)+"/OMIDIV/" [get, set] |
| The output directory of.
|
|
static string | OutFile = "" [get, set] |
| The full filename for the output file.
|
|
Provides a wrapper around the ffmpeg command line and process.
◆ ExecutableExists()
static bool FFmpegWrapper2.ExecutableExists |
( |
bool | actuallyCheck = false | ) |
|
|
static |
- Parameters
-
actuallyCheck | If true, queries the file system, otherwise returns a cached value. See remarks. |
- Returns
- Whether the executable exists.
This method is called on each draw, so actuallyCheck reduces the amount of filesystem ops. It is called with actuallyCheck = true
when the VideoRecorder refresh button is pressed.
◆ GetCmdParam()
static string FFmpegWrapper2.GetCmdParam |
( |
string | name | ) |
|
|
static |
Get the value that a command variable will be replaced with.
- Parameters
-
name | The variable that will be replaced. |
- Returns
- The value it will be replaced with.
- See also
- SetCmdParam(string, string)
◆ GetExecutableDir()
static string FFmpegWrapper2.GetExecutableDir |
( |
| ) |
|
|
static |
- Returns
- The directory of the ffmpeg executable.
This will be Application.streamingAssetsPath/ffmpeg/
◆ GetExecutablePath()
static string FFmpegWrapper2.GetExecutablePath |
( |
bool | quoted = false | ) |
|
|
static |
- Parameters
-
quoted | If true, puts the path in quotes (useful if it contains spaces). |
- Returns
- The full path of the executable, with platform file types accounted for.
- Exceptions
-
PlatformNotSupportedException | If the platform is not Windows, Mac, or Linux Standalone/Editor. |
◆ InitParams()
static void FFmpegWrapper2.InitParams |
( |
| ) |
|
|
static |
Initializes certain parameters, such as video output size (based on window size) and output file name (based on current time).
Will be called by StartRecording, so you don't need to call it yourself.
◆ ReceiveFrame()
static void FFmpegWrapper2.ReceiveFrame |
( |
ref NativeArray< byte > | narray, |
|
|
uint | frameNum ) |
|
static |
Passes a frame to FFmpeg while recording.
- Parameters
-
narray | The frame data. Should be VideoSize width*height*4 in size. |
frameNum | The number of the frame being sent. Can be sent out of order with a gap of up to 15. |
Frames are sent from Unity's AsyncGPUReadback in FFmpegRenderFeature. Unfortunately, they aren't sent in order, so they have to be buffered and reordered.
◆ SetCmdParam()
static void FFmpegWrapper2.SetCmdParam |
( |
string | name, |
|
|
string | value ) |
|
static |
Sets the value for a variable that can be used in the command arguments.
- Parameters
-
name | The variable that will be replaced. |
value | The value to replace it with. |
Exec Args:
-loglevel loglevel% -f ...
static void SetCmdParam(string name, string value)
Sets the value for a variable that can be used in the command arguments.
Definition FFmpegWrapper2.cs:41
Parsed command args passed to ffmpeg:
-loglevel error -f ...
Use fields/properties/setters within this class if they exist, for example OutDir
- See also
- GetCmdParam(string)
◆ ArgsVer
readonly float FFmpegWrapper2.ArgsVer = 1f |
|
static |
Changed when the default args are changed enough that the user's overriden arguments should be replaced with the default.
◆ ExecArgsDef
readonly string FFmpegWrapper2.ExecArgsDef |
|
static |
Initial value:=
"-loglevel error " +
"-f rawvideo " +
"-vcodec rawvideo " +
"-framerate %framerate% " +
"-pix_fmt argb " +
"-s %video_size% " +
"-i - " +
"-vf \"vflip\" " +
"-pix_fmt %pix_fmt% " +
"-c:v %vcodec% " +
"-crf %crf% " +
"\"%outfile%.%file_ext%\""
The default execution arguments, with unparsed variables.
- See also
- ExecArgs
The final output size, based on the window size and VideoScale.
Both dimensions will be rounded down to a multiple of 2.
◆ OutFile
string FFmpegWrapper2.OutFile = "" |
|
staticgetset |
The full filename for the output file.
Only valid during and after a recording has started.
Only valid during and after a recording has started.
The documentation for this class was generated from the following file:
- L:/Coding/Unity/OMIDIV/Assets/Scripts/VideoExport/FFmpegWrapper2.cs