# `PhoenixReplay.Export.FFmpeg`
[🔗](https://github.com/elixir-vibe/phoenix_replay/blob/v0.6.2/lib/phoenix_replay/export/ffmpeg.ex#L2)

Runs `ffmpeg` and follows it until it is done.

[MuonTrap](https://hexdocs.pm/muontrap) runs it, so it never outlives
the process that started it, even when the VM itself goes down, and
stopping it is ending that process: MuonTrap terminates `ffmpeg`, and
kills it if it does not exit.

`ffmpeg` is expected to report its progress on stdout, with
`-progress pipe:1`. While it does, it is working. When it says nothing
for `timeout`, it is taken as stuck and stopped. The export server
cancels a running export by sending `{PhoenixReplay.Export, :cancel}`,
which stops it too.

# `error`

```elixir
@type error() :: {:ffmpeg, pos_integer() | :timeout | :crashed} | :cancelled
```

Why `ffmpeg` did not finish: its exit status, that it went quiet, or
that running it failed.

# `progress`

```elixir
@type progress() :: (non_neg_integer() -&gt; any())
```

Called with how much of the video is encoded so far, in milliseconds.

# `run`

```elixir
@spec run(Path.t(), [String.t()], progress(), pos_integer()) ::
  :ok | {:error, error()}
```

Runs the `ffmpeg` at `executable` with `args`, calling `progress` as
it encodes. Returns once it exits, is cancelled, or goes quiet for
`timeout` milliseconds.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
