mendevi.encode¶
Perform encoding measures.
Functions
|
Transcode an existing video. |
|
Transcode a video file and store the result in the database. |
|
Return the ffmpeg encode cmd. |
|
Return the absolute target bitrate in kbit/s. |
Details
- mendevi.encode.encode(src: Path, **kwargs: dict) 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: dict) None[source]
Transcode a video file and store the result in the database.
Parameters¶
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: dict) list[str][source]
Return the ffmpeg encode cmd.
- mendevi.encode.quality_to_rate(kwargs: dict[str]) int[source]
Return the absolute target bitrate in kbit/s.
Based on https://twitch-overlay.fr/quelle-connexion-internet-choisir-pour-streamer-sur-twitch/ and https://bitmovin.com/blog/video-bitrate-streaming-hls-dash/
You can plot the bitrate with: mendevi plot mendevi.db -x bitrate -y psnr -f ‘mode = “vbr”’
The flow margin is taken to be twice as small and twice as large as the recommendations.