View Source Vtc.Framerate (vtc v0.17.5)

The rate at which a video file frames are played back, measured in frames-per-second (24/1 = 24 frames-per-second). For more on framerate and why Vtc chooses to represent it as a rational number, see NTSC: Framerate vs timebase and The Rational Rationale

struct-fields

Struct Fields

  • playback: The rational representation of the real-world playback speed as a fraction in frames-per-second.

  • ntsc: Atom representing which, if any, NTSC convention this framerate adheres to.

using-as-an-ecto-type

Using as an Ecto Type

See PgFramerate for information on how to use Framerate in your postgres database as a native type.

Link to this section Summary

Types

Type for new/2 coerce_ntsc? option.

Options for new/2 and new!/2.

Enum of Ntsc types.

Type returned by new/2

t()

Type of Framerate

Parse

Creates a new Framerate with a playback speed or timebase.

As new/2 but raises an error instead.

Inspect

Returns true if the value represents and NTSC framerate.

The rational representation of the SMPTE timecode's 'logical speed'. For more on timebase and it's relationship to framerate, see: NTSC: Framerate vs timebase.

Ecto Migrations

The database type for PgFramerate.

Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Link to this section Types

Link to this type

new_opt_coerce_ntsc?()

View Source
@type new_opt_coerce_ntsc?() :: boolean() | :if_trunc

Type for new/2 coerce_ntsc? option.

@type new_opts() :: [
  ntsc: ntsc(),
  coerce_ntsc?: new_opt_coerce_ntsc?(),
  allow_float?: boolean(),
  invert?: boolean()
]

Options for new/2 and new!/2.

@type ntsc() :: :non_drop | :drop | nil

Enum of Ntsc types.

values

Values

  • :non_drop A non-drop NTSC value.
  • :drop A drop-frame ntsc value.
  • nil: Not an NTSC value

For more information on NTSC standards and framerate conventions, see Frame.io's blog post on the subject.

@type parse_result() :: {:ok, t()} | {:error, Vtc.Framerate.ParseError.t()}

Type returned by new/2

@type t() :: %Vtc.Framerate{ntsc: ntsc(), playback: Ratio.t()}

Type of Framerate

Link to this section Parse

@spec new(Ratio.t() | number() | String.t(), new_opts()) :: parse_result()

Creates a new Framerate with a playback speed or timebase.

arguments

Arguments

  • rate: Either the playback rate or timebase. For NTSC framerates, the value will be rounded to the nearest correct value.

options

Options

  • ntsc: Atom representing the which (or whether an) NTSC standard is being used. Default: nil.

  • coerce_ntsc?: If and how to coerce values to the nearest NTSC value. Default: false

    • true: If ntsc is non-nil, values will be coerced to the nearest valid NTSC rate. So 24 would be coerced to 24000/1001, as would 23.98. This option must be set to true when ntsc is non-nil and a float is passed.

    • false: Do not coerce value. Passed value must conform exactly to a valid NTSC framerate.

    • :if_trunc: Will coerce value to a valid NTSC rate using the ntsc opt value if the below criteria are met. If the criteria are not met, the value will be parsed as-is with ntsc set to nil:

      • The incoming value is a float, with two or more significant digits that match the truncated+rounded form. So 23.98 and 23.976 would be coerced to 24000/1001 but 23.99 and 23.96 would both be left as-is.

      • The incoming value is a Rational, and precisely represents a valid NTSC framerate.

      • The incoming value is a Rational, that when cast to float, matches the above criteria.

      • The incoming value is a string representation of any of the above.

    • allow_fractional_float?: If true, will allow non-integer float values to be converted to Rational values when parsing framerates. Can be combined with :if_trunc to parse floating point values, coercing to NTSC if it appears to be an abbreviated NTSC value.

  • invert?: If true, the resulting rational rate value will be flipped so that 1/24 becomes 24/1. This can be helpful when you are parsing a rate given in seconds-per-frame rather than frames-per-second. Default: false.

@spec new!(Ratio.t() | number() | String.t(), new_opts()) :: t()

As new/2 but raises an error instead.

Link to this section Inspect

@spec ntsc?(t()) :: boolean()

Returns true if the value represents and NTSC framerate.

Will return true on a Framerate with an :ntsc value of :non_drop and :drop.

Link to this function

smpte_timebase(framerate)

View Source
@spec smpte_timebase(t()) :: Ratio.t()

The rational representation of the SMPTE timecode's 'logical speed'. For more on timebase and it's relationship to framerate, see: NTSC: Framerate vs timebase.

Returned value is in frames-per-second.

Link to this section Ecto Migrations

@spec type() :: atom()

The database type for PgFramerate.

Can be used in migrations as the fields type.

Link to this section Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.