mendevi.encode

Perform encoding measures.

Functions

encode(src, **kwargs)

Transcode an existing video.

encode_and_store(database, env_id, src, **kwargs)

Transcode a video file and store the result in the database.

get_transcode_cmd(src, dst, **kwargs)

Return the ffmpeg encode cmd.

Details

mendevi.encode.encode(src: Path, **kwargs) tuple[Path, str, dict[str]][source]

Transcode an existing video.

Parameters

srcpathlib.Path

The source video file to be transcoded.

**kwargsdict

Transmitted to get_transcode_cmd().

Returns

dstpathlib.Path

The transcoded video path. The stem contains the md5 hash of the file content.

cmdstr

The ffmpeg command.

activitydict[str]

The computeur activity during the transcoding process.

mendevi.encode.encode_and_store(database: Path, env_id: int, src: Path, **kwargs)[source]

Transcode a video file and store the result in the database.

Parameters

databasepathlike

The path of the existing database to be updated.

**kwargs

Transmitted to encode().

Examples

>>> import pathlib, tempfile
>>> from mendevi.database.complete import add_environment
>>> from mendevi.database.create import create_database
>>> from mendevi.encode import encode_and_store
>>> src = pathlib.Path("/data/dataset/video/despacito.mp4")
>>> create_database(database := pathlib.Path(tempfile.mktemp(suffix=".sqlite")))
>>> env_id = add_environment(database)
>>> encode_and_store(
...     database, env_id, src,
...     encoder="libx264", profile="sd", effort="fast", quality=0.5, threads=8
... )
>>> database.unlink()
>>>
mendevi.encode.get_transcode_cmd(src: Path, dst: Path, **kwargs) list[str][source]

Return the ffmpeg encode cmd.