Git Product home page Git Product logo

mpv-video-splice's People

Contributors

pvpscript avatar teawhydee 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpv-video-splice's Issues

Show slice indications in the timeline.

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!

scrot_2020-12-22-174000

Specifying output directory from config file instead of environment variables

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!

Not working on WIN10

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)

mktemp: too few X's in template

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.

default location on windows

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)

Windows 10 compatibility and improvements

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.

How to make it work in 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?

Simple mod to output timecodes in SRT format for subtitles

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.

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.