ffswak 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: ffswak
3
+ Version: 0.1.0
4
+ Summary: A Python wrapper for common ffmpeg video editing tasks
5
+ License-Expression: GPL-3.0-only
6
+ Project-URL: Repository, https://github.com/coppit/ffswak
7
+ Project-URL: Issues, https://github.com/coppit/ffswak/issues
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: ffmpeg-python<0.3,>=0.2
12
+ Requires-Dist: humanize<5,>=4
13
+ Requires-Dist: psutil<8,>=7
14
+ Requires-Dist: rich<15,>=14
15
+ Dynamic: license-file
16
+
17
+ # ffswak.py
18
+
19
+ A Python wrapper for `ffmpeg` that simplifies common video editing tasks.
20
+
21
+ Things you can do:
22
+
23
+ * Scale the video so that it isn't too large
24
+ * Extract a short clip from a long video
25
+ * Rotate the video, automatically zooming so that there are no black spaces on the sides
26
+ * Stabilize a shaky video
27
+ * Crop to zoom in on part of the video
28
+ * Re-encode the video using the HEVC encoder (h265)
29
+
30
+ # Getting Started
31
+
32
+ Make sure you have ffmpeg and ffprobe installed, and that you have Python 3.11 or newer:
33
+
34
+ ```sh
35
+ ffmpeg --version
36
+ ffprobe --version
37
+ python3 --version
38
+ ```
39
+
40
+ Install [uv](https://docs.astral.sh/uv/):
41
+
42
+ ```sh
43
+ curl -LsSf https://astral.sh/uv/install.sh | sh
44
+ ```
45
+
46
+ Or on macOS:
47
+
48
+ ```sh
49
+ brew install uv
50
+ ```
51
+
52
+ Then install ffswak from its [GitHub repository](https://github.com/coppit/ffswak):
53
+
54
+ ```sh
55
+ uv tool install git+https://github.com/coppit/ffswak.git
56
+ ```
57
+
58
+ Alternatively, with [pipx](https://pipx.pypa.io/):
59
+
60
+ ```sh
61
+ pipx install git+https://github.com/coppit/ffswak.git
62
+ ```
63
+
64
+ Or with pip:
65
+
66
+ ```sh
67
+ python3 -m pip install git+https://github.com/coppit/ffswak.git
68
+ ```
69
+
70
+ Optionally, edit the variables at the top of `ffswak.py` to configure the default output dimensions and default output
71
+ directory.
72
+
73
+ Test it out:
74
+
75
+ ```sh
76
+ ffswak --help
77
+ ```
78
+
79
+ # Usage Examples
80
+
81
+ ## Example 1: Scale and re-encode one video
82
+
83
+ ```sh
84
+ ffswak input.mov
85
+ ```
86
+
87
+ Scale down the video to fit in 1920x1080 (or 1080x1920 if it's a portrait video). Re-encode with the HEVC codec,
88
+ using the same video bitrate. Re-encode the audio using the AAC codec, if the bitrate is higher than 192k. Save the
89
+ output to `~/Pictures/Import`, generating a new filename if the file already exists. Keep the pixel format, bit depth,
90
+ frame rate, etc. the same.
91
+
92
+ If the resulting file is less than 10% smaller, issue a warning. If it's less than 2% smaller (or even larger!) copy the
93
+ input file to the output location and issue a warning.
94
+
95
+ ## Example 2: Join clips from two videos, with a fade transition
96
+
97
+ ```sh
98
+ ffswak input1.mov -10 input2.mp4 0:15-1:10
99
+ ```
100
+
101
+ Same as above, but join portions of two videos with a .5s fade transition. When possible, the time ranges will be
102
+ increased by .5s so that the part you care about isn't lost in the transition. If a time is omitted, such as `-10` or
103
+ `10-`, it implies the start or end of the input. You can also specify multiple time ranges for a single input, such as
104
+ `input.mov 5-10 15-20`.
105
+
106
+ If one video is 1280x720 and the other is 720x1280, the resulting output will be 1280x1080, with black bars. (1280 wide
107
+ because the 1280x720 is less than 1920x1080, but only 1080 high because 720x1280 is taller than the default max size of
108
+ 1920x1080.) The output frame rate, pixel format, video/audio bitrates, etc. will be the maximum of the values from the
109
+ input files.
110
+
111
+ ## Example 3: Stabilize and join multiple videos
112
+
113
+ ```sh
114
+ ffswak -s input1.mov input2.mov
115
+ ```
116
+
117
+ Stabilize all the videos and join them. The output file will be named input1-input2.mp4.
118
+
119
+ ## Example 4: Global versus per-input options
120
+
121
+ ```sh
122
+ ffswak -O ~/Desktop -v 2 -- input1.mov -s input2.mov
123
+ ```
124
+
125
+ Increase the volume of all the videos by 100%, but stabilize only the second video. Write the output file to the
126
+ ~/Desktop directory.
127
+
128
+ Use the `--` syntax whenever you need to specify per-input options. Global options go before the `--`. Per-input options
129
+ go before the file name, and any time ranges go after the file name.
130
+
131
+ ## Example 5: Cropping and slowing one clip
132
+
133
+ ```sh
134
+ ffswak -- input.mov 0-10 -cs .5 -cl bc -s .5 input.mov 10-15 input.mov 15-20
135
+ ```
136
+
137
+ For a 5-second clip in the middle, slow it down 50% and crop it to be 50% of the original size, centered on the bottom
138
+ center of the original image.
139
+
140
+ # All Options
141
+
142
+ This help message shows all of the options
143
+
144
+ ```
145
+ usage: ffswak.py [global options] -- [per-file options] input_file [time_ranges ...] [ [per-file options] input_file [time_ranges... ] ... ]
146
+
147
+ A Python wrapper for ffmpeg that simplies common video editing tasks.
148
+
149
+ TIME FORMAT is [[HH:]MM:]SS[.frac] or NNN[.frac] or .frac. Time ranges do not include
150
+ transition times. A warning will be issued if the end of an input file requires the transition to
151
+ include part of the specified time range.
152
+
153
+ Global options apply to all files. Video options override global options for a specific
154
+ file. "--" can be omitted if there are no per-video options.
155
+
156
+ Global-Only Options:
157
+ General options, and options for the output video.
158
+
159
+ -F, --frame-rate-limit FRAME_RATE_LIMIT
160
+ Maximum frame rate.
161
+ -D, --dimensions-limit DIMENSIONS_LIMIT
162
+ Maximum dimensions. .5 means 50% as wide and tall; .5,1 means half as wide, full height; 16:9 means the largest possible video with that aspect ratio;
163
+ 1280x720 means exactly that size
164
+ -o, --output-file OUTPUT_FILE
165
+ Output file. Relative paths use -O if specified, otherwise the current directory.
166
+ Absolute paths override -O. Existing filenames get a random suffix.
167
+ -O, --output-dir OUTPUT_DIR
168
+ Output directory, also used as the base for relative -o paths.
169
+ Without -o, defaults to the configured output directory.
170
+ -d, --debug Enable debugging messages
171
+ --help Show this help message and exit.
172
+
173
+ Video Options:
174
+ Options for videos. Can be specified at the global or per-video level.
175
+
176
+ -cl, --crop-location CROP_LOCATION
177
+ Cropped portion should be in the top/middle/bottom and left/center/right. ".2,.3" means 20% over from the left, and 30% down from the top. 100% means
178
+ the right side of the crop window will be aligned with the right side of the original video.
179
+ -cs, --crop-size CROP_SIZE
180
+ Cropped portion size. .5 means 50% as wide and tall; .5,1 means half as wide, full height; 1280x720 means exactly that size
181
+ -p, --speedup SPEEDUP
182
+ Change the speed. 2 means twice as fast. Audio tempo is adjusted to match.
183
+ -r, --rotate ROTATE Rotate the video, cropping as needed. Positive values are clockwise.
184
+ -v, --volume VOLUME Modify volume level. 2 means twice as loud. 0 means omit the audio track.
185
+ -s, --stabilize Stabilize the video
186
+ -t, --tripod TRIPOD Enable tripod mode, stabilizing on the time specified in TIME FORMAT.
187
+ -R, --reverse Reverse the video.
188
+ -T, --transition-duration TRANSITION_DURATION
189
+ Transition duration when concatenating ranges, in TIME FORMAT.
190
+ -I, --interlace-test Enable testing the video for interlacing.
191
+
192
+ Generally speaking, bitrate, frame rate, etc. will be chosen to avoid degrading the quality.
193
+ Width and height will be automatically adjusted (with a warning) when it's obvious that they are
194
+ wrong. e.g. Width and height will be swapped when all the inputs are portrait instead of landscape.
195
+ ```
196
+
197
+ # Known Issues and Limitations
198
+
199
+ iPhones produce extra metadata streams. Those get lost if the file is re-encoded. ffswak preserves a small whitelist of
200
+ global descriptive tags only when all non-blank source values agree. (Missing values do not prevent preservation.) It
201
+ computes `creation_time` from the earliest selected source clip (each file's recording time plus the start offset of
202
+ each clip). The whitelist includes GPS/location tags for personal-media use, so remove location metadata before sharing
203
+ a video if you do not want to disclose where it was recorded. Alternatively, remove location tags from
204
+ `PRESERVED_METADATA_KEYS` in the script. Run ffprobe on the input and output to compare metadata.
205
+
206
+ I add features as I need them. Feel free to suggest enhancements or report problems in the
207
+ [issue tracker](https://github.com/coppit/ffswak/issues).
208
+
209
+ # Author
210
+
211
+ David Coppit `<david@coppit.org>`
212
+
213
+ # License
214
+
215
+ ffswak is licensed under the GNU General Public License, version 3 only. See [LICENSE](LICENSE). Its
216
+ interlace-detection policy is adapted from mpv's
217
+ [`TOOLS/idet.sh`](https://github.com/mpv-player/mpv/blob/master/TOOLS/idet.sh), which is GPL-2.0-or-later and therefore
218
+ compatible with GPL-3.0.
219
+
220
+ # Development
221
+
222
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup and checks. The detailed regression-test guide is in
223
+ [tests/README.md](tests/README.md). Maintainers can find release instructions in [DEVELOPMENT.md](DEVELOPMENT.md).
@@ -0,0 +1,7 @@
1
+ ffswak.py,sha256=6LNpPmXI4Pye62Q-cqwjSNL947rNYmSnTdAUY2guD5s,128651
2
+ ffswak-0.1.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ ffswak-0.1.0.dist-info/METADATA,sha256=DayaSQMVgE6bns-HJ_jKFRgCd_a_5pDAdaGO7D3aDXU,8831
4
+ ffswak-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ ffswak-0.1.0.dist-info/entry_points.txt,sha256=FJUTdL1U514rtTjduoMgIfdVvDEjoxKZ1p4LkI5KjlU,39
6
+ ffswak-0.1.0.dist-info/top_level.txt,sha256=Lz84UDTwXMCMt2Rbxpjm521z00tWHqRI4uH2G0X3W6c,7
7
+ ffswak-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ffswak = ffswak:main