videoclip/README.md

160 lines
4.7 KiB
Markdown
Raw Permalink 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 08:40:41 +00:00
2021-04-14 20:23:27 +00:00
[![Chat](https://img.shields.io/badge/chat-join-green)](https://tatsumoto-ren.github.io/blog/join-our-community.html)
2020-10-24 08:40:41 +00:00
![GitHub](https://img.shields.io/github/license/Ajatt-Tools/videoclip)
![GitHub top language](https://img.shields.io/github/languages/top/Ajatt-Tools/videoclip)
![Lines of code](https://img.shields.io/tokei/lines/github/Ajatt-Tools/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`.
2021-04-14 20:23:27 +00:00
Subtitles can be embedded into the clips.
2020-08-21 05:04:26 +00:00
## Prerequisites
1) [Install mpv](https://mpv.io/installation/).
2) Add the directory where `mpv` is installed
to the [PATH](https://www.mojeek.com/search?q=path+variable).
If you're using GNU/Linux, this step is likely unnecessary
because package managers (`apt`, `pacman`, etc.)
place executable files to `/usr/bin` which is already added to the `PATH`.
If you have installed `mpv` to a non-standard location,
or if you're not using the GNU operating system,
you need to make sure that `mpv` is added to the `PATH`.
2020-08-21 04:26:24 +00:00
## Installation
2021-04-14 20:23:27 +00:00
2023-12-08 22:24:53 +00:00
### Using git
2023-12-09 16:04:06 +00:00
Clone the repository to the `mpv/scripts` directory.
The command below works on the GNU operating system with `git` installed.
2023-12-08 22:24:53 +00:00
``` bash
git clone 'https://github.com/Ajatt-Tools/videoclip.git' ~/.config/mpv/scripts/videoclip
```
To update the user-script on demand later, you can execute:
``` bash
cd ~/.config/mpv/scripts/videoclip && git pull
```
2020-10-23 15:40:14 +00:00
### Manually
2021-04-14 20:23:27 +00:00
Download
[the repository](https://github.com/Ajatt-Tools/videoclip/archive/refs/heads/master.zip)
and extract the folder containing
`videoclip.lua`
to your [mpv scripts](https://github.com/mpv-player/mpv/wiki/User-Scripts) directory:
2020-10-23 15:40:14 +00:00
| 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.
2021-04-15 01:15:44 +00:00
<details>
<summary>Expected directory tree</summary>
```
~/.config/mpv/scripts
|-- other_addon_1
|-- other_addon_2
`-- videoclip
|-- main.lua
|-- ...
`-- videoclip.lua
```
</details>
2020-08-21 04:41:10 +00:00
## Configuration
2021-04-14 20:23:27 +00:00
2020-10-24 11:48:25 +00:00
The config file should be created by the user, if needed.
| OS | Config location |
| --- | --- |
| GNU/Linux | `~/.config/mpv/script-opts/videoclip.conf` |
| Windows | `C:/Users/Username/AppData/Roaming/mpv/script-opts/videoclip.conf` |
If a parameter is not specified 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:
2021-04-14 20:23:27 +00:00
2020-08-21 04:41:10 +00:00
```
# 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
2021-12-29 09:22:55 +00:00
# Clean filenames (remove special characters) (yes or no)
clean_filename=yes
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
# FPS / framerate. Set to "auto" or a number.
video_fps=auto
#video_fps=60
2020-08-21 04:41:10 +00:00
2020-10-23 15:48:20 +00:00
# Audio settings
2021-07-10 20:56:03 +00:00
# Available formats: opus or aac
audio_format=opus
# Opus sounds good at low bitrates 32-64k, but aac requires 128-256k.
2020-10-23 15:48:20 +00:00
audio_bitrate=32k
# Catbox.moe upload settings
# Whether uploads should go to litterbox instead of catbox.
# catbox files are stored permanently, while litterbox is temporary
2023-06-21 14:39:34 +00:00
litterbox=yes
# If using litterbox, time until video expires
# Available values: 1h, 12h, 24h, 72h
litterbox_expire=72h
2020-08-21 04:41:10 +00:00
```
2021-04-14 20:23:27 +00:00
2020-10-24 11:48:25 +00:00
### Key bindings
| OS | Config location |
| --- | --- |
| GNU/Linux | `~/.config/mpv/input.conf` |
| Windows | `C:/Users/Username/AppData/Roaming/mpv/input.conf` |
Add this line if you want to change the key that opens the script's menu.
2021-04-14 20:23:27 +00:00
2020-08-21 04:41:10 +00:00
```
2020-08-31 19:45:35 +00:00
c script-binding videoclip-menu-open
2020-08-21 04:41:10 +00:00
```
2021-04-14 20:23:27 +00:00
2020-08-21 04:59:41 +00:00
## Usage
2021-04-14 20:23:27 +00:00
2020-08-21 04:59:41 +00:00
- 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.
2021-07-10 20:56:03 +00:00
It is possible to create silent videoclips.
To do that, first mute audio in mpv.
The default key binding is `m`.
If a video has visible subtitles, they will be embedded automatically.
Toggle them off in mpv if you don't want any subtitles to be visible.
The default key binding is `v`.