   defp cap_relative_time({_, _} = frame, nil) do
     frame
   end
+
   defp cap_relative_time({t, s}, time_limit) do
     {min(t, time_limit), s}
   end
+
   defp cap_relative_time(stream, time_limit) do
     Stream.map(stream, &cap_relative_time(&1, time_limit))
   end

  defp extract_v2_metadata(path) do
    with {:ok, line} when is_binary(line) <- File.open(path, fn f -> IO.read(f, :line) end),
         {:ok, %{"version" => 2} = header} <- decode_json(line) do
      metadata = %{version: 2,
                   terminal_columns: header["width"],
                   terminal_lines: header["height"],
                   terminal_type: get_in(header, ["env", "TERM"]),
                   command: header["command"],
                   duration: get_v2_duration(path),
                   recorded_at: header["timestamp"] && Timex.from_unix(header["timestamp"]),
                   title: header["title"],
                   theme_fg: get_in(header, ["theme", "fg"]),
                   theme_bg: get_in(header, ["theme", "bg"]),
                   theme_palette: get_in(header, ["theme", "palette"]),
                   idle_time_limit: header["idle_time_limit"],
                   shell: get_in(header, ["env", "SHELL"])}
      {:ok, metadata}
    else
      {:ok, :eof} ->
        {:error, :unknown_format}
      {:ok, %{"version" => version}} ->
        {:error, {:unsupported_format, version}}
      {:error, :invalid} ->
        {:error, :unknown_format}
    end

    :ok = FileStore.download_file(store_data_path, local_data_path)
    stdout_stream({local_timing_path, local_data_path})
  end

  def stdout_stream(%Asciicast{} = asciicast) do
    {:ok, local_path} = Briefly.create()
    store_path = Asciicast.file_store_path(asciicast, :file)
    :ok = FileStore.download_file(store_path, local_path)
    stdout_stream(local_path)
  end

  def stdout_stream(asciicast_file_path) when is_binary(asciicast_file_path) do
    first_two_lines =
      asciicast_file_path
      |> File.stream!([], :line)
      |> Stream.take(2)
      |> Enum.to_list()

    case first_two_lines do
      ["{" <> _ = header_line, "[" <> _] ->
