ffmpeg_media_type
¶
FFProbeInfo
dataclass
¶
FFProbeInfo(
*,
format: FFProbeFormat,
streams: tuple[FFProbeStream, ...]
)
MediaInfo
dataclass
¶
MediaInfo(
*,
type: Literal["image", "video", "audio"],
width: int = 0,
height: int = 0,
duration: float = 0,
format: str | None = None,
size: int = 0,
suggest_ext: str | None = None
)
The Basic Media info.
suggest_ext
class-attribute
instance-attribute
¶
suggest_ext: str | None = None
The suggested file extension.
detect
¶
detect(uri: str | Path) -> MediaInfo
Detect the media type of a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri |
str | Path
|
the URI of the file |
required |
Returns:
Type | Description |
---|---|
MediaInfo
|
the media type information |
Raises:
Type | Description |
---|---|
FFmpegMediaTypeError
|
If the ffmpeg command fails. |
FFMpegMediaCorruptedError
|
If the media file is corrupted. |
Source code in src/ffmpeg_media_type/info.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
ffprobe
¶
ffprobe(input_url: str | Path) -> FFProbeInfo
Get media information using FFprobe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_url |
str | Path
|
the URI of the media file |
required |
Returns:
Type | Description |
---|---|
FFProbeInfo
|
the media information |
Raises:
Type | Description |
---|---|
FFmpegMediaTypeError
|
If the FFprobe command fails. |
Source code in src/ffmpeg_media_type/utils/ffprobe.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
generate_thumbnail
¶
generate_thumbnail(
video_path: str | Path,
suffix: str = ".png",
*,
width: int = 320,
height: int = -1,
time_offset: float = 0
) -> str
Generate a thumbnail from a video file at a specified time offset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path |
str | Path
|
the path to the video file |
required |
suffix |
str
|
the suffix of the generated thumbnail |
'.png'
|
width |
int
|
the width of the generated thumbnail |
320
|
height |
int
|
the height of the generated thumbnail |
-1
|
time_offset |
float
|
the time offset in seconds to generate the thumbnail |
0
|
Raises:
Type | Description |
---|---|
FFmpegMediaTypeError
|
If the ffmpeg command fails. |
Returns:
Type | Description |
---|---|
str
|
the path to the generated thumbnail |
Source code in src/ffmpeg_media_type/utils/thumbnail.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|