| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8abe60f commit 8d142c5
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ help: | |||
| 17 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new | |
| 18 | 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | |
| 19 | 19 | %: Makefile | |
| 20 | + @rm -rf html doctrees | ||
| 20 | 21 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | |
| 21 | 22 | ||
| 22 | 23 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,6 +51,7 @@ <h1 id="index">Index</h1> | |||
| 51 | 51 | | <a href="#F"><strong>F</strong></a> | |
| 52 | 52 | | <a href="#G"><strong>G</strong></a> | |
| 53 | 53 | | <a href="#H"><strong>H</strong></a> | |
| 54 | + | <a href="#I"><strong>I</strong></a> | ||
| 54 | 55 | | <a href="#M"><strong>M</strong></a> | |
| 55 | 56 | | <a href="#O"><strong>O</strong></a> | |
| 56 | 57 | | <a href="#R"><strong>R</strong></a> | |
@@ -114,6 +115,14 @@ <h2 id="H">H</h2> | |||
| 114 | 115 | </ul></td> | |
| 115 | 116 | </tr></table> | |
| 116 | 117 | ||
| 118 | + <h2 id="I">I</h2> | ||
| 119 | + <table style="width: 100%" class="indextable genindextable"><tr> | ||
| 120 | + <td style="width: 33%; vertical-align: top;"><ul> | ||
| 121 | + <li><a href="index.html#ffmpeg.input">input() (in module ffmpeg)</a> | ||
| 122 | + </li> | ||
| 123 | + </ul></td> | ||
| 124 | + </tr></table> | ||
| 125 | + | ||
| 117 | 126 | <h2 id="M">M</h2> | |
| 118 | 127 | <table style="width: 100%" class="indextable genindextable"><tr> | |
| 119 | 128 | <td style="width: 33%; vertical-align: top;"><ul> | |
@@ -125,10 +134,12 @@ <h2 id="M">M</h2> | |||
| 125 | 134 | <h2 id="O">O</h2> | |
| 126 | 135 | <table style="width: 100%" class="indextable genindextable"><tr> | |
| 127 | 136 | <td style="width: 33%; vertical-align: top;"><ul> | |
| 128 | - <li><a href="index.html#ffmpeg.overlay">overlay() (in module ffmpeg)</a> | ||
| 137 | + <li><a href="index.html#ffmpeg.output">output() (in module ffmpeg)</a> | ||
| 129 | 138 | </li> | |
| 130 | 139 | </ul></td> | |
| 131 | 140 | <td style="width: 33%; vertical-align: top;"><ul> | |
| 141 | + <li><a href="index.html#ffmpeg.overlay">overlay() (in module ffmpeg)</a> | ||
| 142 | + </li> | ||
| 132 | 143 | <li><a href="index.html#ffmpeg.overwrite_output">overwrite_output() (in module ffmpeg)</a> | |
| 133 | 144 | </li> | |
| 134 | 145 | </ul></td> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ | |||
| 30 | 30 | # Add any Sphinx extension module names here, as strings. They can be | |
| 31 | 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | |
| 32 | 32 | # ones. | |
| 33 | - extensions = ['sphinx.ext.autodoc'] | ||
| 33 | + extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon'] | ||
| 34 | 34 | ||
| 35 | 35 | # Add any paths that contain templates here, relative to this directory. | |
| 36 | 36 | templates_path = ['_templates'] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,27 +8,53 @@ | |||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | 10 | def file_input(filename): | |
| 11 | + """Input file URL (ffmpeg ``-i`` option) | ||
| 12 | + | ||
| 13 | + Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__ | ||
| 14 | + """ | ||
| 11 | 15 | return InputNode(file_input.__name__, filename=filename) | |
| 12 | 16 | ||
| 13 | 17 | ||
| 18 | + def input(filename): | ||
| 19 | + """Shorthand for ``file_input``""" | ||
| 20 | + return file_input(filename) | ||
| 21 | + | ||
| 22 | + | ||
| 14 | 23 | @operator(node_classes={OutputNode, GlobalNode}) | |
| 15 | - def overwrite_output(parent): | ||
| 16 | - return GlobalNode(parent, overwrite_output.__name__) | ||
| 24 | + def overwrite_output(parent_node): | ||
| 25 | + """Overwrite output files without asking (ffmpeg ``-y`` option) | ||
| 26 | + | ||
| 27 | + Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__ | ||
| 28 | + """ | ||
| 29 | + return GlobalNode(parent_node, overwrite_output.__name__) | ||
| 17 | 30 | ||
| 18 | 31 | ||
| 19 | 32 | @operator(node_classes={OutputNode}) | |
| 20 | - def merge_outputs(*parents): | ||
| 21 | - return OutputNode(parents, merge_outputs.__name__) | ||
| 33 | + def merge_outputs(*parent_nodes): | ||
| 34 | + return OutputNode(parent_nodes, merge_outputs.__name__) | ||
| 22 | 35 | ||
| 23 | 36 | ||
| 24 | 37 | @operator(node_classes={InputNode, FilterNode}) | |
| 25 | - def file_output(parent, filename): | ||
| 26 | - return OutputNode([parent], file_output.__name__, filename=filename) | ||
| 38 | + def file_output(parent_node, filename): | ||
| 39 | + """Output file URL | ||
| 40 | + | ||
| 41 | + Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__ | ||
| 42 | + """ | ||
| 43 | + return OutputNode([parent_node], file_output.__name__, filename=filename) | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + @operator(node_classes={InputNode, FilterNode}) | ||
| 47 | + def output(parent_node, filename): | ||
| 48 | + """Shorthand for ``file_output``""" | ||
| 49 | + return file_output(parent_node, filename) | ||
| 50 | + | ||
| 27 | 51 | ||
| 28 | 52 | ||
| 29 | 53 | __all__ = [ | |
| 30 | 54 | 'file_input', | |
| 31 | 55 | 'file_output', | |
| 56 | + 'input', | ||
| 32 | 57 | 'merge_outputs', | |
| 58 | + 'output', | ||
| 33 | 59 | 'overwrite_output', | |
| 34 | 60 | ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,64 +5,201 @@ | |||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | 7 | @operator() | |
| 8 | - def setpts(parent, expr): | ||
| 9 | - return FilterNode([parent], setpts.__name__, expr) | ||
| 8 | + def setpts(parent_node, expr): | ||
| 9 | + """Change the PTS (presentation timestamp) of the input frames. | ||
| 10 | + | ||
| 11 | + Args: | ||
| 12 | + expr: The expression which is evaluated for each frame to construct its timestamp. | ||
| 13 | + | ||
| 14 | + Official documentation: `setpts, asetpts <https://ffmpeg.org/ffmpeg-filters.html#setpts_002c-asetpts>`__ | ||
| 15 | + """ | ||
| 16 | + return FilterNode([parent_node], setpts.__name__, expr) | ||
| 10 | 17 | ||
| 11 | 18 | ||
| 12 | 19 | @operator() | |
| 13 | - def trim(parent, **kwargs): | ||
| 14 | - return FilterNode([parent], trim.__name__, **kwargs) | ||
| 20 | + def trim(parent_node, **kwargs): | ||
| 21 | + """Trim the input so that the output contains one continuous subpart of the input. | ||
| 22 | + | ||
| 23 | + Args: | ||
| 24 | + start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the | ||
| 25 | + first frame in the output. | ||
| 26 | + end: Specify the time of the first frame that will be dropped, i.e. the frame immediately preceding the one | ||
| 27 | + with the timestamp end will be the last frame in the output. | ||
| 28 | + start_pts: This is the same as start, except this option sets the start timestamp in timebase units instead of | ||
| 29 | + seconds. | ||
| 30 | + end_pts: This is the same as end, except this option sets the end timestamp in timebase units instead of | ||
| 31 | + seconds. | ||
| 32 | + duration: The maximum duration of the output in seconds. | ||
| 33 | + start_frame: The number of the first frame that should be passed to the output. | ||
| 34 | + end_frame: The number of the first frame that should be dropped. | ||
| 35 | + | ||
| 36 | + Official documentation: `trim <https://ffmpeg.org/ffmpeg-filters.html#trim>`__ | ||
| 37 | + """ | ||
| 38 | + return FilterNode([parent_node], trim.__name__, **kwargs) | ||
| 15 | 39 | ||
| 16 | 40 | ||
| 17 | 41 | @operator() | |
| 18 | - def overlay(main_parent, overlay_parent, eof_action='repeat', **kwargs): | ||
| 42 | + def overlay(main_parent_node, overlay_parent_node, eof_action='repeat', **kwargs): | ||
| 43 | + """Overlay one video on top of another. | ||
| 44 | + | ||
| 45 | + Args: | ||
| 46 | + x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In | ||
| 47 | + case the expression is invalid, it is set to a huge value (meaning that the overlay will not be displayed | ||
| 48 | + within the output visible area). | ||
| 49 | + y: Set the expression for the y coordinates of the overlaid video on the main video. Default value is 0. In | ||
| 50 | + case the expression is invalid, it is set to a huge value (meaning that the overlay will not be displayed | ||
| 51 | + within the output visible area). | ||
| 52 | + eof_action: The action to take when EOF is encountered on the secondary input; it accepts one of the following | ||
| 53 | + values: | ||
| 54 | + | ||
| 55 | + * ``repeat``: Repeat the last frame (the default). | ||
| 56 | + * ``endall``: End both streams. | ||
| 57 | + * ``pass``: Pass the main input through. | ||
| 58 | + | ||
| 59 | + eval: Set when the expressions for x, and y are evaluated. | ||
| 60 | + It accepts the following values: | ||
| 61 | + | ||
| 62 | + * ``init``: only evaluate expressions once during the filter initialization or when a command is | ||
| 63 | + processed | ||
| 64 | + * ``frame``: evaluate expressions for each incoming frame | ||
| 65 | + | ||
| 66 | + Default value is ``frame``. | ||
| 67 | + shortest: If set to 1, force the output to terminate when the shortest input terminates. Default value is 0. | ||
| 68 | + format: Set the format for the output video. | ||
| 69 | + It accepts the following values: | ||
| 70 | + | ||
| 71 | + * ``yuv420``: force YUV420 output | ||
| 72 | + * ``yuv422``: force YUV422 output | ||
| 73 | + * ``yuv444``: force YUV444 output | ||
| 74 | + * ``rgb``: force packed RGB output | ||
| 75 | + * ``gbrp``: force planar RGB output | ||
| 76 | + | ||
| 77 | + Default value is ``yuv420``. | ||
| 78 | + rgb (deprecated): If set to 1, force the filter to accept inputs in the RGB color space. Default value is 0. | ||
| 79 | + This option is deprecated, use format instead. | ||
| 80 | + repeatlast: If set to 1, force the filter to draw the last overlay frame over the main input until the end of | ||
| 81 | + the stream. A value of 0 disables this behavior. Default value is 1. | ||
| 82 | + | ||
| 83 | + Official documentation: `overlay <https://ffmpeg.org/ffmpeg-filters.html#overlay-1>`__ | ||
| 84 | + """ | ||
| 19 | 85 | kwargs['eof_action'] = eof_action | |
| 20 | - return FilterNode([main_parent, overlay_parent], overlay.__name__, **kwargs) | ||
| 86 | + return FilterNode([main_parent_node, overlay_parent_node], overlay.__name__, **kwargs) | ||
| 21 | 87 | ||
| 22 | 88 | ||
| 23 | 89 | @operator() | |
| 24 | - def hflip(parent): | ||
| 25 | - return FilterNode([parent], hflip.__name__) | ||
| 90 | + def hflip(parent_node): | ||
| 91 | + """Flip the input video horizontally. | ||
| 92 | + | ||
| 93 | + Official documentation: `hflip <https://ffmpeg.org/ffmpeg-filters.html#hflip>`__ | ||
| 94 | + """ | ||
| 95 | + return FilterNode([parent_node], hflip.__name__) | ||
| 26 | 96 | ||
| 27 | 97 | ||
| 28 | 98 | @operator() | |
| 29 | - def vflip(parent): | ||
| 30 | - return FilterNode([parent], vflip.__name__) | ||
| 99 | + def vflip(parent_node): | ||
| 100 | + """Flip the input video vertically. | ||
| 101 | + | ||
| 102 | + Official documentation: `vflip <https://ffmpeg.org/ffmpeg-filters.html#vflip>`__ | ||
| 103 | + """ | ||
| 104 | + return FilterNode([parent_node], vflip.__name__) | ||
| 31 | 105 | ||
| 32 | 106 | ||
| 33 | 107 | @operator() | |
| 34 | - def drawbox(parent, x, y, width, height, color, thickness=None, **kwargs): | ||
| 108 | + def drawbox(parent_node, x, y, width, height, color, thickness=None, **kwargs): | ||
| 109 | + """Draw a colored box on the input image. | ||
| 110 | + | ||
| 111 | + Args: | ||
| 112 | + x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0. | ||
| 113 | + y: The expression which specifies the top left corner y coordinate of the box. It defaults to 0. | ||
| 114 | + width: Specify the width of the box; if 0 interpreted as the input width. It defaults to 0. | ||
| 115 | + heigth: Specify the height of the box; if 0 interpreted as the input height. It defaults to 0. | ||
| 116 | + color: Specify the color of the box to write. For the general syntax of this option, check the "Color" section | ||
| 117 | + in the ffmpeg-utils manual. If the special value invert is used, the box edge color is the same as the | ||
| 118 | + video with inverted luma. | ||
| 119 | + thickness: The expression which sets the thickness of the box edge. Default value is 3. | ||
| 120 | + w: Alias for ``width``. | ||
| 121 | + h: Alias for ``height``. | ||
| 122 | + c: Alias for ``color``. | ||
| 123 | + t: Alias for ``thickness``. | ||
| 124 | + | ||
| 125 | + Official documentation: `drawbox <https://ffmpeg.org/ffmpeg-filters.html#drawbox>`__ | ||
| 126 | + """ | ||
| 35 | 127 | if thickness: | |
| 36 | 128 | kwargs['t'] = thickness | |
| 37 | - return FilterNode([parent], drawbox.__name__, x, y, width, height, color, **kwargs) | ||
| 129 | + return FilterNode([parent_node], drawbox.__name__, x, y, width, height, color, **kwargs) | ||
| 38 | 130 | ||
| 39 | 131 | ||
| 40 | 132 | @operator() | |
| 41 | - def concat(*parents, **kwargs): | ||
| 42 | - kwargs['n'] = len(parents) | ||
| 43 | - return FilterNode(parents, concat.__name__, **kwargs) | ||
| 133 | + def concat(*parent_nodes, **kwargs): | ||
| 134 | + """Concatenate audio and video streams, joining them together one after the other. | ||
| 135 | + | ||
| 136 | + The filter works on segments of synchronized video and audio streams. All segments must have the same number of | ||
| 137 | + streams of each type, and that will also be the number of streams at output. | ||
| 138 | + | ||
| 139 | + Args: | ||
| 140 | + unsafe: Activate unsafe mode: do not fail if segments have a different format. | ||
| 141 | + | ||
| 142 | + Related streams do not always have exactly the same duration, for various reasons including codec frame size or | ||
| 143 | + sloppy authoring. For that reason, related synchronized streams (e.g. a video and its audio track) should be | ||
| 144 | + concatenated at once. The concat filter will use the duration of the longest stream in each segment (except the | ||
| 145 | + last one), and if necessary pad shorter audio streams with silence. | ||
| 146 | + | ||
| 147 | + For this filter to work correctly, all segments must start at timestamp 0. | ||
| 148 | + | ||
| 149 | + All corresponding streams must have the same parameters in all segments; the filtering system will automatically | ||
| 150 | + select a common pixel format for video streams, and a common sample format, sample rate and channel layout for | ||
| 151 | + audio streams, but other settings, such as resolution, must be converted explicitly by the user. | ||
| 152 | + | ||
| 153 | + Different frame rates are acceptable but will result in variable frame rate at output; be sure to configure the | ||
| 154 | + output file to handle it. | ||
| 155 | + | ||
| 156 | + Official documentation: `concat <https://ffmpeg.org/ffmpeg-filters.html#concat>`__ | ||
| 157 | + """ | ||
| 158 | + kwargs['n'] = len(parent_nodes) | ||
| 159 | + return FilterNode(parent_nodes, concat.__name__, **kwargs) | ||
| 44 | 160 | ||
| 45 | 161 | ||
| 46 | 162 | @operator() | |
| 47 | - def zoompan(parent, **kwargs): | ||
| 48 | - return FilterNode([parent], zoompan.__name__, **kwargs) | ||
| 163 | + def zoompan(parent_node, **kwargs): | ||
| 164 | + """Apply Zoom & Pan effect. | ||
| 165 | + | ||
| 166 | + Args: | ||
| 167 | + zoom: Set the zoom expression. Default is 1. | ||
| 168 | + x: Set the x expression. Default is 0. | ||
| 169 | + y: Set the y expression. Default is 0. | ||
| 170 | + d: Set the duration expression in number of frames. This sets for how many number of frames effect will last | ||
| 171 | + for single input image. | ||
| 172 | + s: Set the output image size, default is ``hd720``. | ||
| 173 | + fps: Set the output frame rate, default is 25. | ||
| 174 | + z: Alias for ``zoom``. | ||
| 175 | + | ||
| 176 | + Official documentation: `zoompan <https://ffmpeg.org/ffmpeg-filters.html#zoompan>`__ | ||
| 177 | + """ | ||
| 178 | + return FilterNode([parent_node], zoompan.__name__, **kwargs) | ||
| 49 | 179 | ||
| 50 | 180 | ||
| 51 | 181 | @operator() | |
| 52 | - def hue(parent, **kwargs): | ||
| 53 | - return FilterNode([parent], hue.__name__, **kwargs) | ||
| 182 | + def hue(parent_node, **kwargs): | ||
| 183 | + """Modify the hue and/or the saturation of the input. | ||
| 184 | + | ||
| 185 | + Args: | ||
| 186 | + h: Specify the hue angle as a number of degrees. It accepts an expression, and defaults to "0". | ||
| 187 | + s: Specify the saturation in the [-10,10] range. It accepts an expression and defaults to "1". | ||
| 188 | + H: Specify the hue angle as a number of radians. It accepts an expression, and defaults to "0". | ||
| 189 | + b: Specify the brightness in the [-10,10] range. It accepts an expression and defaults to "0". | ||
| 190 | + | ||
| 191 | + Official documentation: `hue <https://ffmpeg.org/ffmpeg-filters.html#hue>`__ | ||
| 192 | + """ | ||
| 193 | + return FilterNode([parent_node], hue.__name__, **kwargs) | ||
| 54 | 194 | ||
| 55 | 195 | ||
| 56 | 196 | @operator() | |
| 57 | - def colorchannelmixer(parent, *args, **kwargs): | ||
| 197 | + def colorchannelmixer(parent_node, *args, **kwargs): | ||
| 58 | 198 | """Adjust video input frames by re-mixing color channels. | |
| 59 | 199 | ||
| 60 | - `FFmpeg colorchannelmixer filter`_ | ||
| 61 | - | ||
| 62 | - .. _FFmpeg colorchannelmixer filter: | ||
| 63 | - https://ffmpeg.org/ffmpeg-filters.html#toc-colorchannelmixer | ||
| 200 | + Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__ | ||
| 64 | 201 | """ | |
| 65 | - return FilterNode([parent], colorchannelmixer.__name__, **kwargs) | ||
| 202 | + return FilterNode([parent_node], colorchannelmixer.__name__, **kwargs) | ||
| 66 | 203 | ||
| 67 | 204 | ||
| 68 | 205 | __all__ = [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,10 +81,11 @@ def _get_output_args(node, stream_name_map): | |||
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | 83 | @operator(node_classes={OutputNode, GlobalNode}) | |
| 84 | - def get_args(parent): | ||
| 84 | + def get_args(node): | ||
| 85 | + """Get command-line arguments for ffmpeg.""" | ||
| 85 | 86 | args = [] | |
| 86 | 87 | # TODO: group nodes together, e.g. `-i somefile -r somerate`. | |
| 87 | - sorted_nodes, child_map = _topo_sort(parent) | ||
| 88 | + sorted_nodes, child_map = _topo_sort(node) | ||
| 88 | 89 | input_nodes = [node for node in sorted_nodes if isinstance(node, InputNode)] | |
| 89 | 90 | output_nodes = [node for node in sorted_nodes if isinstance(node, OutputNode) and not | |
| 90 | 91 | isinstance(node, GlobalNode)] | |
@@ -101,8 +102,9 @@ def get_args(parent): | |||
| 101 | 102 | ||
| 102 | 103 | ||
| 103 | 104 | @operator(node_classes={OutputNode, GlobalNode}) | |
| 104 | - def run(parent, cmd='ffmpeg'): | ||
| 105 | - args = [cmd] + parent.get_args() | ||
| 105 | + def run(node, cmd='ffmpeg'): | ||
| 106 | + """Run ffmpeg on node graph.""" | ||
| 107 | + args = [cmd] + node.get_args() | ||
| 106 | 108 | _subprocess.check_call(args) | |
| 107 | 109 | ||
| 108 | 110 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments