cutcutcodec.core.io.write_ffmpeg.ContainerOutputFFMPEG
- class cutcutcodec.core.io.write_ffmpeg.ContainerOutputFFMPEG(in_streams: Iterable[Stream], filename: Path | str | bytes, streams_settings: Iterable[dict], container_settings: dict | None = None)[source]
Allow to write the output file to disk.
Attributes
- filenamepathlib.Path
The absolute path + name of the file to encode (readonly).
- streams_settingslist[dict]
Information related to each codec (readonly).
- container_settingsdict
Global container file information (readonly).
Examples
>>> import os >>> from cutcutcodec.core.filter.audio.subclip import FilterAudioSubclip >>> from cutcutcodec.core.filter.video.subclip import FilterVideoSubclip >>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise >>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise >>> from cutcutcodec.core.io.write_ffmpeg import ContainerOutputFFMPEG >>> streams_settings = [ ... {"encodec": "libopus", "rate": 8000}, ... {"encodec": "libx264", "rate": 12, "shape": (2, 2)}, ... ] >>> container_settings = {"format": "matroska"} >>> (stream_a,) = FilterAudioSubclip(GeneratorAudioNoise(0).out_streams, 0, 1).out_streams >>> (stream_v,) = FilterVideoSubclip(GeneratorVideoNoise(0).out_streams, 0, 1).out_streams >>> streams = (stream_a, stream_v) >>> ContainerOutputFFMPEG(streams, os.devnull, streams_settings, container_settings).write() >>>
Initialise and create the class.
Parameters
- in_streamstyping.Iterable[Stream]
The ordered video or audio streams to be encoded. For more information, please refer to initializator of
cutcutcodec.core.classes.container.ContainerOutput.- filenamepathlike
Path to the file to be encoded.
- streams_settingstyping.Iterable[dict]
These are the encoding parameters associated with each stream. They contain all the information about the codecs. For audio streams, here is the format to follow:
“encodec”: str, # name of the codec or encoding library (ex libopus)
“rate”: int or str, # samplerate in Hz (ex 48000)
“options”: dict, # (optional) option for codec (ex {“application”: “voip”})
“bitrate”: int, # (optional) the flow in bits/s (ex 1024000)
For video streams, here is the format to follow:
“encodec”: str, # name of the codec or encoding library (ex libx264)
“rate”: numbers.Real or str, # the framerate in Hz (ex “30000/1001”)
“shape”: tuple[int, int], # shape (height, width) of the frames
“options”: dict, # (optional) option for codec (ex {“crf”: “23”})
“bitrate”: int, # (optional) the flow in bits/s (ex 6400000)
“pix_fmt”: str, # (optional) pixel format (ex “yuv444p10le”)
- container_settingsdict, optional
Global container file information. must contain the following fields:
“format”: str or None, # specific format to use, defaults to autodect
“container_options”: dict, # (optional) options to pass to the container
“options”: dict, # (optional) options to pass to the container and all streams
- property filename: Path
Return the absolute path + name of the file to encode.