Giter Site home page Giter Site logo

ajatt-tools / videoclip Goto Github PK

View Code? Open in Web Editor NEW
106.0 4.0 14.0 115 KB

๐Ÿ— Easily create videoclips with mpv.

Home Page: https://tatsumoto-ren.github.io/blog/join-our-community

License: GNU General Public License v3.0

Lua 100.00%
mpv-script addon mpv clip videoclip audioclip ajatt

videoclip's Introduction

screenshot

videoclip

Chat GitHub GitHub top language Lines of code

Easily create video and audio clips with mpv in a few keypresses. Videoclips are saved as .mp4 or .webm. Subtitles can be embedded into the clips.

Prerequisites

  1. Install mpv.

  2. Add the directory where mpv is installed to the PATH.

    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.

Installation

Using git

Clone the repository to the mpv/scripts directory. The command below works on the GNU operating system with git installed.

git clone 'https://github.com/Ajatt-Tools/videoclip.git' ~/.config/mpv/scripts/videoclip

To update the user-script on demand later, you can execute:

cd ~/.config/mpv/scripts/videoclip && git pull

Manually

Download the repository and extract the folder containing videoclip.lua to your mpv scripts directory:

OS Location
GNU/Linux ~/.config/mpv/scripts/
Windows C:/Users/Username/AppData/Roaming/mpv/scripts/

Note: in Celluloid user scripts are installed by switching to the "Plugins" tab in the preferences dialog and dropping the files there.

Expected directory tree
~/.config/mpv/scripts
|-- other_addon_1
|-- other_addon_2
`-- videoclip
    |-- main.lua
    |-- ...
    `-- videoclip.lua

Configuration

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 =.

Example configuration file:

# Absolute paths to the folders where generated clips will be placed.
# `~` or `$HOME` are not supported due to mpv limitations.
video_folder_path=/home/user/Videos
audio_folder_path=/home/user/Music

# Menu size
font_size=24
# Clean filenames (remove special characters) (yes or no)
clean_filename=yes

# Video settings
video_width=-2
video_height=480
video_bitrate=1M
# Available video formats: mp4, vp9, vp8
video_format=mp4
# The range of the scale is 0โ€“51, where 0 is lossless,
# 23 is the default, and 51 is worst quality possible.
# Insane values like 9999 still work but produce the worst quality.
video_quality=23
# Use the slowest preset that you have patience for.
# https://trac.ffmpeg.org/wiki/Encode/H.264
preset=faster
# FPS / framerate. Set to "auto" or a number.
video_fps=auto
#video_fps=60

# Audio settings
# Available formats: opus or aac
audio_format=opus
# Opus sounds good at low bitrates 32-64k, but aac requires 128-256k.
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
litterbox=yes
# If using litterbox, time until video expires
# Available values: 1h, 12h, 24h, 72h
litterbox_expire=72h

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.

c script-binding videoclip-menu-open

Usage

  • Open a file in mpv and press c to open the script menu.
  • Follow the onscreen instructions. You need to set the start point, end point, and then press c to create the clip.

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.

videoclip's People

Contributors

batteredbunny avatar brainless-afk avatar cephian avatar microchipq avatar rnpnr avatar shichiha avatar tatsumoto-ren avatar thecolorman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

videoclip's Issues

Can't open the menu

I followed every step of the guide but when I press the hotkey nothing happens.

Not working on streams?

It works perfectly when I play a local file, but for some reason it says "couldn't create the clip. Does path exist?" when I stream.

Effects

Any way to preserve modified effects, like speed or pitch?

Fixed - FPS

I'd like to choose a fixed 29fps. So is it possible?

clip with HDR

The tool only works with SDR video
how would I have it clip an HDR one?

encoder.lua:162: attempt to index local 'location_info' (a nil value)

[videoclip] Press 'c' to open the videoclip menu.
(+) Video --vid=1 () (vp9 1920x1080 29.972fps)
(+) Audio --aid=1 --alang=eng (
) (opus 2ch 48000Hz)
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu] 1920x1080 yuv420p
[videoclip] Please wait...
[videoclip] The following args will be executed: mpv "/home/whitley/ff.webm" --loop-file=no --keep-open=no --no-ocopy-metadata --no-sub --audio-channels=2 --oacopts-add=vbr=on --oacopts-add=application=voip --oacopts-add=compression_level=10 --vf-add=format=yuv420p --sub-font-provider=auto --embeddedfonts=yes '--sub-font=Noto Sans CJK JP' --ovc=libx264 --oac=libopus --start=2.069 --end=79.279 --aid=1 --mute=no --volume=100.000000 --ovcopts-add=b=1M --oacopts-add=b=32k --ovcopts-add=crf=23 --ovcopts-add=preset=faster --vf-add=scale=-2:480 --ytdl-format= '--o=/home/drew/Pictures/mpv/Single Mom Goes VIRAL For Crying On Her Birthday Lets Break This Down _00m02s069ms-01m19s279ms.mp4' --sid=no --secondary-sid=no --sub-delay=0.000000 --sub-visibility=yes --secondary-sub-visibility=yes
[videoclip]
[videoclip] stack traceback:
[videoclip] /home/whitley/.config/mpv/scripts/videoclip/videoclip.lua:283: in function 'create_clip'
[videoclip] /home/whitley/.config/mpv/scripts/videoclip/videoclip.lua:220: in function 'fn'
[videoclip] mp.defaults:230: in function 'fn'
[videoclip] mp.defaults:65: in function 'handler'
[videoclip] mp.defaults:382: in function 'handler'
[videoclip] mp.defaults:512: in function 'call_event_handlers'
[videoclip] mp.defaults:554: in function 'dispatch_events'
[videoclip] mp.defaults:505: in function mp.defaults:504
[videoclip] [C]: at 0x55e012716760
[videoclip] [C]: at 0x55e012714bd0
[videoclip] Lua error: /home/whitley/.config/mpv/scripts/videoclip/encoder.lua:162: attempt to index local 'location_info' (a nil value)

On Gentoo.

Consider removing parentheses from clip name?

I set clean_file=no, however parens and spaces still appear

Eliminate spaces and parenthesis.

FROM
    filename = string.format(
            '%s (%s-%s)',
            filename,
            human_readable_time(main_menu.timings['start']),
            human_readable_time(main_menu.timings['end'])

TO
    filename = string.format(
            '%s_%s_%s',
            filename,
            human_readable_time(main_menu.timings['start']),
            human_readable_time(main_menu.timings['end'])

can't create a clip

Why can't I create a clip and always prompt me that the path doesn't exist? It still prompts me after using the absolute path

Clip doesn't copy resolution from original video

Why is it that the video gets resized by default when creating a clip? I would have thought most people would want to keep the original resolution when creating a clip, but there doesn't appear to be an option for this.

Error: Audio streams are not allowed.

Making a video clip with MPV and posting it on 4chan gives me this error message. : Error: Audio streams are not allowed.
I made sure to choose vp8 format and mute audio in the options menu.

Clip without re-encoding?

Not too sure if this is entirely possible but, is it possible to extract sections without re-encoding, or at least keeping the exact same format as the original?

I think this would make a really good way to extract sections from very long videos, but if it re-encodes the entire section, I'm assuming it would take longer.

More whitespaces to a whitespace

I want to tweak this from return str:gsub('[%c%p%s]', '') to return str:gsub('[%c%p]'%s{2,}', '').

Example name of a file:
Video - Music Event 0001.mp4

I expect:
Video Music Event 0001.mp4

encode compatibility

i've noticed that the default encode may not be recognized in some platforms.
this is not a issue of videoclip itself, but it's just that the encoding is not widely used in the web, so as workaround i've made a script that converts a given video to a more compatible format.
my suggestion is that we could have a option in the dotfiles to enable this "compatible mode" instead of the default one (the user can choose whether to keep the default or change to the compatible-mode).

here's the simple script:

https://pastebin.com/EbnMaGjR

Script doesn't work on Windows.

Paths are not being recognized by the script.
All I get is "E:\profile\Downloads" "Error: couldn't create the clip. Does E:\profile\Downloads exist?"

  • The folder exists and the path is correct
  • Using "" \\ \ / or // doesn't make any difference.
  • Changing the path by "hardcoding" it in the script (bypassing config file) does the same.

won't create video clip + change in slashes with preferences?

no matter what i do, i cannot create a video clip and it'll just be stuck at "Please wait...". i don't know if this is an issue with my preferences of output being too high or what but i've tried messing with those and it still has the same result?
Screenshot 2024-03-07 165338

there's also a problem with my preferences not saving within mpv and the slashes being messed up halfway through. (note that i don't have a -master folder so i don't know if i have to create that to fix the issue)
Screenshot 2024-03-07 164643

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.