videoclip/README.md

98 lines
3.4 KiB
Markdown
Raw Normal View History

2020-10-24 08:40:22 +00:00
![screenshot](https://user-images.githubusercontent.com/69171671/97077527-0836ef00-15d4-11eb-92a5-bfa236a6b118.png)
2020-08-21 04:16:38 +00:00
# videoclip
2020-10-24 07:20:28 +00:00
Easily create video and audio clips with mpv in a few keypresses.
Videoclips are saved as `.mp4` or `.webm`.
2020-08-21 05:04:26 +00:00
2020-08-21 04:26:24 +00:00
## Installation
2020-10-23 15:40:14 +00:00
### Manually
Save [videoclip.lua](https://raw.githubusercontent.com/Ajatt-Tools/videoclip/master/videoclip.lua)
in the [mpv scripts](https://github.com/mpv-player/mpv/wiki/User-Scripts) folder:
| OS | Location |
| --- | --- |
| GNU/Linux | `~/.config/mpv/scripts/` |
| Windows | `C:/Users/Username/AppData/Roaming/mpv/scripts/` |
Note: in [Celluloid](https://www.archlinux.org/packages/community/x86_64/celluloid/)
user scripts are installed by switching to the "Plugins" tab
in the preferences dialog and dropping the files there.
2020-10-24 07:20:28 +00:00
### Using curl
```
$ curl -o ~/.config/mpv/scripts/subs2srs.lua 'https://raw.githubusercontent.com/Ajatt-Tools/mpvacious/master/subs2srs.lua'
```
### Using git
If you already have your dotfiles set up according to
[Arch Wiki recommendations](https://wiki.archlinux.org/index.php/Dotfiles#Tracking_dotfiles_directly_with_Git), execute:
2020-08-21 04:26:24 +00:00
```
$ config submodule add 'https://github.com/Ajatt-Tools/videoclip.git' ~/.config/mpv/scripts/videoclip
```
2020-10-24 07:20:28 +00:00
If not, either proceed to Arch Wiki and come back when you're done, or simply clone the repo:
2020-08-21 04:26:24 +00:00
```
$ git clone 'https://github.com/Ajatt-Tools/videoclip.git' ~/.config/mpv/scripts/videoclip
```
2020-10-24 07:20:28 +00:00
Since you've just cloned the script to its own subfolder,
you need to tell mpv where to look for it.
Open or create `~/.config/mpv/scripts/modules.lua` and add these lines:
2020-08-21 04:26:24 +00:00
```
local mpv_scripts_dir_path = os.getenv("HOME") .. "/.config/mpv/scripts/"
function load(relative_path) dofile(mpv_scripts_dir_path .. relative_path) end
load("videoclip/videoclip.lua")
```
2020-10-24 07:20:28 +00:00
### Updating with git
2020-08-21 04:28:58 +00:00
Submodules are updated using standard git commands:
```
$ config submodule update --remote --merge
```
or
```
$ cd ~/.config/mpv/scripts/videoclip && git pull
```
2020-08-21 04:41:10 +00:00
## Configuration
Configuration file is located at ```~/.config/mpv/script-opts/videoclip.conf```
2020-10-23 15:48:20 +00:00
and should be created by the user if needed. If a parameter is not specified
2020-08-21 04:41:10 +00:00
in the config file, the default value will be used.
mpv doesn't tolerate spaces before and after `=`.
2020-08-21 04:41:10 +00:00
Example configuration file:
```
# Absolute paths to the folders where generated clips will be placed.
2020-08-21 04:41:10 +00:00
# `~` or `$HOME` are not supported due to mpv limitations.
video_folder_path=/home/user/Videos
audio_folder_path=/home/user/Music
2020-08-21 04:41:10 +00:00
# Menu size
2020-10-23 15:48:20 +00:00
font_size=24
2020-08-21 04:41:10 +00:00
2020-10-23 15:48:20 +00:00
# Video settings
video_width=-2
video_height=480
video_bitrate=1M
# Available video formats: mp4, vp9, vp8
video_format=mp4
2020-08-21 04:41:10 +00:00
# The range of the scale is 051, where 0 is lossless,
# 23 is the default, and 51 is worst quality possible.
2020-09-20 00:43:41 +00:00
# Insane values like 9999 still work but produce the worst quality.
2020-08-21 04:44:43 +00:00
video_quality=23
2020-08-21 04:41:10 +00:00
# Use the slowest preset that you have patience for.
# https://trac.ffmpeg.org/wiki/Encode/H.264
2020-08-21 04:44:43 +00:00
preset=faster
2020-08-21 04:41:10 +00:00
2020-10-23 15:48:20 +00:00
# Audio settings
# Sane values for audio bitrate are from 16k to 64k.
audio_bitrate=32k
# Create silent videoclips by default. Possble values: `yes` or `no`.
mute_audio=yes
2020-08-21 04:41:10 +00:00
```
Key bindings are configured in ```~/.config/mpv/input.conf```.
This step is not necessary.
```
2020-08-31 19:45:35 +00:00
c script-binding videoclip-menu-open
2020-08-21 04:41:10 +00:00
```
2020-08-21 04:59:41 +00:00
## Usage
- Open a file in mpv and press `c` to open the script menu.
2020-09-20 00:55:19 +00:00
- Follow the onscreen instructions. You need to set the `start point`,
`end point`, and then press `c` to create the clip.