com.phronemophobic.clj-media
audio-format
(audio-format {:keys [channel-layout sample-format sample-rate], :as format})Convenience function for returning an audio format.
file
(file f)Returns media with the contents of the file f.
f should be a value that can be coerced to a file via
clojure.java.io/file.
filter-media-types
(filter-media-types media-types media)Returns media with only types in media-types.
frames
(frames media)(frames media stream)(frames media stream opts)Returns a reducible of frames of media.
Stream can either be:
- an index
:audio, which selects the first audio stream.:video, which selects the first video stream.
opts is an optional map with the following keys:
:format A media format description as returned by
audio-format or video-format. The
frames will be transcoded to the provided
format if not already in that format.
make-frame
(make-frame {:keys [bytes format time-base key-frame? pts], :as m})Returns an opaque, raw frame for creating media with make-media.
The following keys are required:
:format: map describing the format returned by audio-format or video-format.
:bytes: a byte array with the raw data adhering to :format.
:time-base: a ratio of that pts will be specified in. :time-base typically
matches the frame rate for video or sample rate for audio.
`time-base` can specified using 3 different methods:
- as a ratio: (eg. 1/60)
- as a 2 element vector of [numerator, denominator]: (eg. [1 60])
- as an integer. It will be treated as 1/time-base: (eg. 60).
:pts: the presentation timestamp in :time-base units.
(time in seconds) = pts * time-base.
The following keys are optional:
:key-frame?: specifies whether the current frame should be a key frame.
make-media
(make-media format frames)Returns media using raw data found in frames. frames
must be a sequence of frames created with make-frame.
probe
(probe f)Reads the file f and returns metadata about the media's format.
f Any value that can be coerced to a file via clojure.java.io/as-file.
remove-media-types
(remove-media-types media-types media)Returns media without any types in media-types.
video-format
(video-format {:keys [pixel-format], :as format})Convenience function for returning an audio format.
write!
(write! media dest)(write! media dest opts)Write media to the path given by dest.
opts can have the following options:
:audio-format
A map with the following keys:
:sample-rate: See :sample-rates found in list-codecs.
:sample-format: See :sample-formats found in list-codecs.
:channel-layout: See :name of :channel-layouts found in list-codecs.
"stereo" and "mono" are typical values.
:codec {:id codec-id}
:video-format
A map with the following keys.
:pixel-format: See :pixel-formats found in list-codecs.
:gop-size: optional the number of pictures in a group of pictures, or 0 for intra_only.
:codec: A codec in the form, {:id codec-id}. See list-codecs.