pvpscript / mpv-video-splice Goto Github PK
View Code? Open in Web Editor NEWAn mpv player script that helps you create a video out of cuts made in the current playing video
License: GNU General Public License v3.0
An mpv player script that helps you create a video out of cuts made in the current playing video
License: GNU General Public License v3.0
I don't know whether this is possible, but it would be nice to have the start and end times of slices shown on the OSD timeline. MPV does something like that for video chapters (as in the image), with each chapter boundary identified on the OSD timeline. The only problem would be identify which mark is a slice start/end time, as all marks look the same. Would it be possible to differentiate the marks? (Or color/number/identify the region between marks?)
Thanks!
Hi! I love this plugin. I'm wondering if I can specify my output directory from a configuration file or script, instead of from an environment variable. I'm on a mac and launching MPV from the finder when I double click a video file, and the OS does not seem to load a shell, so the environment variables aren't seen. I'm not really familiar with the MPV scripting, and I was trying to avoid editing the mpv-splice.lua file directly. Thanks!
Could please refactor script to make it work fow Windows?
'mktemp' is not recognized as an internal or external command,
operable program or batch file.
[mpv_splice] Process started!
[mpv_splice]
[mpv_splice] stack traceback:
[mpv_splice] mp.defaults:230: in function 'fn'
[mpv_splice] mp.defaults:65: in function 'handler'
[mpv_splice] mp.defaults:382: in function 'handler'
[mpv_splice] mp.defaults:512: in function 'call_event_handlers'
[mpv_splice] mp.defaults:554: in function 'dispatch_events'
[mpv_splice] mp.defaults:505: in function <mp.defaults:504>
[mpv_splice] [C]: at 0x7ff690554360
[mpv_splice] [C]: at 0x7ff690553a70
[mpv_splice] Lua error: C:\Users\PC\AppData\Roaming/mpv/scripts/mpv-splice.lua:294: attempt to index local 'cat_file_ptr' (a nil value)
Error caused by invoking mktemp (line 270). I fixed it by removing -t flag from the mktemp completely.
In my case, tmp_location was nil.
Also, for some reason on line 130 you don't have a comma, so the script crashes.
I am unable to locate the tmp or out folders on windows even though they are set in my environment variables?
Does LUA hand Windows folder using ~/ ? did not see the output or folders in my home directory either
local SCRIPT_NAME = "mpv-splice"
local default_tmp_location = "~/tmpXXX"
local default_output_location = mp.get_property("working-directory")
local splice_options = {
tmp_location = os.getenv("MPV_SPLICE_TEMP") and os.getenv("MPV_SPLICE_TEMP") or default_tmp_location,
output_location = os.getenv("MPV_SPLICE_OUTPUT") and os.getenv("MPV_SPLICE_OUTPUT") or default_output_location
}
opt.read_options(splice_options, SCRIPT_NAME)
When I first wrote this script, it was something that I made to learn the basics of Lua and be able to contribute a little with open source. Later, I ended up leaving it to collect dust... But since this is my project with the most starts here on github and there's multiple open issues (some very old, sorry) that complain about it not working on Windows, I'll pick it up again to make some improvements.
The first thing I'll improve is the code, that is beyond atrocious, and then I'll make it compatible with Windows.
Is this supposed to work with Windows? I would absolutely love to use it together with mpv, but I can't get it to export. I have already added ffmpeg to PATH.
Any ideas what I can do to get it to work?
This is not a bug report or feature request -- sorry for misusing the tracker and feel free to close this immediately --, just something pvpscript or other people might find interesting. Long story short, I modified this script a little in order to produce output in valid SRT format.
While I was looking for a way to produce an SRT subtitle file without too much manual editing, I came across mpv-video-splice and noticed that its "print slices" output (Alt+P) is already pretty close to being valid SRT. So I modified the code a little, added a function write_srt() and a new keybinding Alt+W to wrint all recorded timestamps to an SRT file, sorted chronologically. Existing SRT files are backed up (in case I hit Alt+W by mistake). A side effect of my changes is that timecode precision is increased by one digit.
This is how the output looks like:
1
00:00:00,567 --> 00:00:00,767
{}
2
00:00:01,367 --> 00:00:01,567
{}
3
00:00:01,867 --> 00:00:02,033
{}
The "{}"s are placeholders for the actual text. I chose "{}" because it is already a default selector syntax for string.format() in python, and I used a small python script to merge the SRT template generated by the mpv/lua script with a plain text file of the actual subtitles. My python script (which for the most part is busy reading paragraphs from the text file) looks like this:
paragraphs = []
# parse text paragraphs
with open("subtitles.txt") as text_file:
paragraph = ""
for line in text_file:
if line.isspace():
# save finished paragraph, if not empty
if (paragraph and not paragraph.isspace()):
paragraphs.append(paragraph)
paragraph = ""
else:
# continue assembling paragraph
paragraph += line
with open("subtitles-template.srt") as template_file:
with open("subtitles.srt", "w") as merged_file:
srt_data = template_file.read()
merged_file.write(srt_data.format(*paragraphs))
I am not suggesting that any of this functionality should be part of mpv-video-splice, as video splicing and subtitling are two quite diffferent tasks. In fact, maybe I will make a derived script as a pure subtitling tool. For now, I am just sharing the story of this mod here and the modded code in my fork.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.