Reference for youtube_dl_scraper/converter/video_converter.py
¶
youtube_dl_scraper.converter.video_converter.VideoConverter
¶
VideoConverter(input_path: str, output_path: str, video_codec: str, audio_codec: Optional[str], force_render: bool = False, experimental: bool = True)
Bases: BaseConverter
VideoConverter class provides functionality to convert video files into different formats by re-encoding or copying the existing streams with specified video and audio codecs.
Attributes:
Name | Type | Description |
---|---|---|
input_path |
str
|
Path to the input video file. |
output_path |
str
|
Path to the output video file. |
video_codec |
str
|
Desired video codec (e.g., "h264", "hevc"). |
audio_codec |
Optional[str]
|
Desired audio codec (e.g., "aac", "mp3"). |
force_render |
bool
|
If True, forces re-rendering even if codecs match. |
experimental |
bool
|
If True, allow for experimental codec supported by ffmpeg else don't. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path
|
str
|
Path to the input video file. |
required |
output_path
|
str
|
Path to the output video file. |
required |
video_codec
|
str
|
Desired video codec (e.g., "h264", "hevc"). |
required |
audio_codec
|
Optional[str]
|
Desired audio codec (e.g., "aac", "mp3"). |
required |
force_render
|
bool
|
If True, force re-rendering even if codecs match. |
False
|
experimental
|
bool
|
If True, allow for experimental codec supported by ffmpeg else don't. |
True
|
Source code in youtube_dl_scraper/converter/video_converter.py
convert
¶
Perform the conversion.
Skips re-rendering if the codecs already match, unless force_render is True.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to the converted video if successful. |
Source code in youtube_dl_scraper/converter/video_converter.py
get_codecs
staticmethod
¶
Retrieve the codecs of a file using ffmpeg-python.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the video file. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Optional[str]]
|
A dictionary with 'video' and 'audio' keys containing their respective codecs. |