deffcode.ffhelper
Following methods are exclusively design to handle FFmpeg related tasks. These tasks includes validation of installed FFmpeg binaries, downloading of FFmpeg binaries(on Windows), and parsing of FFmpeg metadata into useful information using various pattern matching methods.
For usage examples, kindly refer our Basic Recipes and Advanced Recipes
get_valid_ffmpeg_path¶
Validate the given FFmpeg path/binaries, and returns a valid FFmpeg executable path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_ffmpeg | string | path to custom FFmpeg executables | '' |
is_windows | boolean | is running on Windows OS? | False |
ffmpeg_download_path | string | FFmpeg static binaries download location (Windows only) | '' |
verbose | bool | enables verbose for its operations | False |
Returns: A valid FFmpeg executable path string.
Source code in deffcode/ffhelper.py
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
download_ffmpeg_binaries¶
Generates FFmpeg Static Binaries for windows(if not available)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | path for downloading custom FFmpeg executables | required |
os_windows | boolean | is running on Windows OS? | False |
os_bit | string | 32-bit or 64-bit OS? | '' |
Returns: A valid FFmpeg executable path string.
Source code in deffcode/ffhelper.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
validate_ffmpeg¶
Validate FFmpeg Binaries. Returns True if validity test passes successfully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
verbose | bool | enables verbose for its operations | False |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in deffcode/ffhelper.py
get_supported_pixfmts¶
Find and returns all FFmpeg's supported pixel formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
Returns: List of supported pixel formats as (PIXEL FORMAT, NB_COMPONENTS, BITS_PER_PIXEL).
Source code in deffcode/ffhelper.py
get_supported_vdecoders¶
Find and returns all FFmpeg's supported video decoders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
Returns: List of supported decoders.
Source code in deffcode/ffhelper.py
get_supported_demuxers¶
Find and returns all FFmpeg's supported demuxers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
Returns: List of supported demuxers.
Source code in deffcode/ffhelper.py
validate_imgseqdir¶
Validates Image Sequence by counting number of Image files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source | string | video source to be validated | required |
extension | string | extension of image sequence. | 'jpg' |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in deffcode/ffhelper.py
is_valid_image_seq¶
Checks Image sequence validity by testing its extension against FFmpeg's supported pipe formats and number of Image files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
source | string | video source to be validated | None |
verbose | bool | enables verbose for its operations | False |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in deffcode/ffhelper.py
is_valid_url¶
Checks URL validity by testing its scheme against FFmpeg's supported protocols.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
url | string | URL to be validated | None |
verbose | bool | enables verbose for its operations | False |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in deffcode/ffhelper.py
check_sp_output¶
Executes a subprocess command and returns its stdout (or stderr when requested). On timeout, performs a two-step graceful shutdown — sends SIGTERM first to allow FFmpeg to flush buffers and release hardware resources (decoders, capture devices), then escalates to SIGKILL if the process fails to exit within a short grace period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args | based on input | Non Keyword Arguments | () |
kwargs | based on input | Keyword Arguments force_retrieve_stderr (bool): If True, returns stderr. Also suppresses | {} |
Returns: A bytes value.
Source code in deffcode/ffhelper.py
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | |