01-17-2019, 02:10 AM | #1 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
My new VLC Auto split extension!
Hi,
finally I finished my very first programming experiment. And I'm pretty proud to present you Video split with mkvMerge, an VLC extension which allows you to easily split movies into clips with mkvToolnix. (Without re-encoding!) This is also meant to be a good solution for video editing in Reaper as Reaper is actually not capable of splitting videos without re-encoding. How does it work? Firstly you need mkvToolnix. And of course VLC. The extension allows you to create timestamps on the fly while watching a movie or searching thru it. Its pretty straight forward. Your time ranges get copied into a list which will be sent formatted to mkvMerge for the splitting process. Here it is in action: First run routine demands the path to mkvMerge.exe which gets saved into mkvMergePath.txt next to the extension script. Clicking the Create start/end point button adds new timestamps to the list. Those time ranges will be displayed as clips in the clip list. Sending the timestamps to mkvMerge with one click. It saves all clips next to the source video. I have no idea of how compatible this lua script is. I only tested it on win 7 64 bit and VLC v 3.04 which works flawlessly. But I'm pretty sure there are still many traps that I didn't think about. If someone wants to test it and runs into trouble I will try to fix that. Though I'm not experienced. So please try it out. Put the lua file into the VLC directory/lua/extensions directory and start the extension in the menu -> view Split Video with mkvMerge EDIT: New Version with clean button and better path handling. Here is the file: Split_with_mkvMerge.lua By the way. Theoretically this could be easily ported to apple and linux systems as only the paths and filenames should be renamed. Though I'm not sure but I think the system commands also needed to fit the system code. Would be cool if someone could port it to other systems or even optimizes the code a bit. (I know it looks silly at certain places. )
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Last edited by Eliseat; 01-19-2019 at 03:10 AM. |
01-17-2019, 02:19 AM | #2 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
I forgot the links to mkvToolnix and VLC:
https://mkvtoolnix.download/downloads.html#windows https://www.videolan.org/vlc/download-windows.html In my opinion, the only parts that needs to be changed for running on other systems like apple or linux would be the send functions. Code:
function send_Clip() timeStamps = w2:get_text() input = vlc.object.input() if input then strCmd = 'echo | set /p dummyName='..timeStamps..'|clip' os.execute(strCmd) end end function send_Split() timeStamps = w2:get_text() input = vlc.object.input() if input then strCmd = mkvMerge_path..' --output "'..uri..'.mkv" "'..uri..'" --split parts:'..timeStamps os.execute(strCmd) end end Greetings Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-17-2019, 06:34 AM | #3 |
Human being with feelings
Join Date: Mar 2007
Posts: 4,018
|
Nice :-)
It would be great if we could send it from within Reaper timeline (check points). What I mean is I use one big footage (may be 30-60minutes) and then on timeline I split it and make few or lots of usable scenes (every scene about few seconds or more long) for saving a "masterproject" it would be helpfull if the video items in timeline would be splitted without reencoding by using such script and even mkvToolnix etc. and then replaced in project as multiple video source files instead of the original source big video file. akademie |
01-17-2019, 08:23 AM | #4 | |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Quote:
The re-import of the split files wouldn't be possible without time shifts, length differences etc. And I have no idea of how to handle such things. Or if its even possible to do it from inside Reaper. This needs to be planned from a way more advanced Reaper scripter.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
|
01-17-2019, 10:14 AM | #5 |
Human being with feelings
Join Date: Mar 2007
Posts: 4,018
|
Yeah, I do understand.
So the best would be if Reaper had "no re-encode" option in rendering ;-) |
01-17-2019, 11:25 AM | #6 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Of course. Or Reaper could use mkvMerge in a native way to split videos. (Same way as it uses VLC and ffmpeg for preview) BUT! There is another problem according to mkvToolnix's splitting option. It allows timestamps only in chronological/sequential order. So if you make overlapping cuts you also get an error.
Anyway. VLC with mkvMErge and my extension is the best and most comfortable option at the moment.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-17-2019, 01:48 PM | #7 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
This is very useful....if only I could make it work.
I placed the LUA script in "c:\Program Files\VideoLAN\VLC\lua\extensions". I can see the menu option "Split video with mkvToolnix". I run a video, click the menu option and then...nothing happens. What did I do wrong? I use VLC v3.04, x64 and the mkvtoolnix-64-bit-30.1.0 portable version. |
01-17-2019, 03:31 PM | #8 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
So you don't even get the first run dialog?
If yes, go to tool -> massages. Choose verbosity 2 (debug) and click once more in the view menu at the plugin. This should give out a message of whats going on. You can select and copy it to post it here in this thread or privately per forum massage. Maybe then I can help you.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-17-2019, 04:28 PM | #9 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
Ah...I just learned about messages in VLC!
This is what it says: qt debug: activating or triggering extension 'Split video with mkvToolnix' lua debug: Reactivating extension Split video with mkvToolnix lua warning: Error while running script C:\Program Files\VideoLAN\VLC\lua\extensions\Split_with_mkvMe rge.lua, function activate(): ...\VideoLAN\VLC\lua\extensions\Split_with_mkvMerg e.lua:54: bad argument #1 to 'output' (C:\Program Files\VideoLAN\VLC\lua\extensions\mkvMergePath.txt : Permission denied) lua error: Could not activate extension! lua debug: Deactivating 'Split video with mkvToolnix' Maybe I must create the file "mkvMergePath.txt" first because it needs admin rights? I run Win 7 x64. I should also mention that I have the program mkvtoolnix-64-bit-30.1.0 installed on my D hard drive and running as portable. |
01-17-2019, 11:38 PM | #10 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Permission denied!
This means you are not logged on as administrator and VLC is not allowed to write to the extensions directory. You can avoid this by using an user account with admin rights or by adding the mkvMergePath.txt manually. (Or you set the permission individual for VLC and the user. But I have no idea of how to do this.) To do it manually, create a text file with the name mkvMergePath.txt and paste the path to mkvMerge.exe in it. (first line) For example: c:/program files/mkvtoolnix/mkvMerge.exe (shift + right click on mkvmerge.exe -> copy as path, remove "" and other formatting signs.) Save this text file manually next to the extension. To explain what happened: The extension needs the path to work correctly so it searches for the mkvMergePath.txt. If there is no such file it will be created and the extension asks for writing the path into it. I thought this would be the best way. But its seems that this leads into problems if the writing permission is not allowed. Maybe someone has an idea of how to handle this in a better way. Greetings Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-18-2019, 05:07 AM | #11 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
Yes! I created the file manually via admin rights and now it is working.
Thank you for this great tool! |
01-18-2019, 05:55 AM | #12 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
One more question: where are the splitted files located? I cannot find them?
When I use the action"Auto Split", I see a very short window appearing and disappearing and then nothing happens: also the clips stay in the row "Clips to get split: " Maybe this is also some kind admin right issue I have to solve? |
01-18-2019, 06:35 AM | #13 | |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Quote:
Please repeat the splitting process with open VLC massage turned on to let VLC show whats going on. If there stands something about --output can't be found than its the source path of the video file. The "Clips to get split" list doesn't clean up in the process. This could be a future option because if a new video gets loaded without closing the VLC window the list stays the same. (Not good!) But I'm not sure if this should happen automatically as always something could go wrong. Maybe a "clean" button would be better. I will take a look at it. And please post the verbose massages so I can see what makes the trouble. And you also could take a look ate the file and folder name. Do they have special characters in the path? If yes, I have to take a look at this also. Those characters need to be escaped from the text. But I need to know which ones make problems. Many thanks for testing it. I'm aware that this extension isn't very stable yet because there are so many system settings, versions and unexpected situations ...
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Last edited by Eliseat; 01-18-2019 at 06:41 AM. |
|
01-18-2019, 06:56 AM | #14 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
First: thank you for helping Eli!
Okay, my file name is very simple: Doobie Brothers - Dark eyed cajun woman.mp4 As an axample I want to make two splits (so two video files) and then push the button Auto Split. It's a very long logfile, but creating start and end points works without errors. So I just copy the the end of the log: lua debug: Clicking 'C:\Program Files\VideoLAN\VLC\lua\extensions\Split_with_mkvMe rge.lua': 'Create end point (2)' lua debug: Clicking 'C:\Program Files\VideoLAN\VLC\lua\extensions\Split_with_mkvMe rge.lua': '> Auto Split ' qt debug: Dialog 'Split video with mkvToolnix' received a closeEvent lua debug: Deactivating 'Split video with mkvToolnix' lua debug: Deleting dialog 'Split video with mkvToolnix' lua debug: Waiting for the dialog to be deleted... qt debug: Deleting extension dialog 'Split video with mkvToolnix' main debug: auto hiding mouse cursor main debug: auto hiding mouse cursor No error shown. Do you have any idea? |
01-18-2019, 07:25 AM | #15 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Hm, that's weird.
I'm not sure if the extension or mkvmerge makes the trouble. Could you please check ... Maybe I found it: Could it be that your mkvMerge path contains a space character? Like "Portable apps" or something? I just made some test cases and found out that the path ends at the space character if there is one inside of the path. That needs fixed.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-18-2019, 07:36 AM | #16 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
The problem is, if I set the path in "" it only starts mkvMerge without sending the files. I need to find a work around for this. And I hope this is also your problem.
Will fix it. But have to think about it.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-18-2019, 07:43 AM | #17 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
I use the portable version and it is on my D harddrive with this path:
"D:\Program Files\mkvtoolnix\mkvmerge.exe" So there is a "space" character between "Program" and "Files" but that is regular Windows like it is on the C drive. Maybe the portable version of mkvmerge.exe does not work and it has to be installed? |
01-18-2019, 07:58 AM | #18 | |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Quote:
You could - only for testing as this needs to be fixed - move the mkvtoolnix folder on another place without spaces in between. I'm pretty sure it will run then. Many thanks for hinting me that. This is a serious problem.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
|
01-18-2019, 08:13 AM | #19 |
Human being with feelings
Join Date: May 2009
Posts: 29,269
|
The old 8.1 style path might work in that situation, it's something good to know...
Such as: C:\PROGRA~1\ ^Where the number = the occurrence of that string in the directory in alphabetical order. To determine the "short path" name of a directory, CD to one level up and run dir /x 01/17/19 03:38 PM <DIR> PROGRA~1 Program Files 01/14/19 10:41 AM <DIR> PROGRA~2 Program Files (x86) If you work that somehow into what you are doing, it may solve the issue... "D:\PROGRA~1\mkvtoolnix\mkvmerge.exe" Ideally quote escaping etc. is better, if possible... assuming there is no code that demands the 8.1 format.
__________________
Music is what feelings sound like. |
01-18-2019, 08:24 AM | #20 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
Well, I tried and made a new directory d:\Test and put the mkvTool in there. But unfortunately I don't get the chance from VLC to enter the new path. I deleted the lua file and started VLC to see if the entry in the View menu had disappeared. It did. Then I copied the lua file again and started VLC, but still the first window to enter the direction of the mkvTool does not appear.
But....I changed the path in the mkvMergePath.txt file to the new destination and now it works. Thanks Eli! |
01-18-2019, 08:31 AM | #21 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Thank you, karbomusic. But the problem is, I never know which system paths a user has. There could always be a space here or there - and even in the file name. I took your advice and placed the path between "". But it didn't work in this case.
There are many internet discussions about that with less solid answers. I've found this which could be a solution: https://stackoverflow.com/questions/...h-file/1851129 Though I don't know why CMD accepts spaces in paths if setting it into a variable. But if it works ... I could do this in one line what wouldn't be much effort. Set the variable, call the variable! We'll see if it helps. I will try out different solutions. Something will fix it. Many thanks for your help. Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-18-2019, 08:32 AM | #22 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Great!
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-18-2019, 08:41 AM | #23 |
Human being with feelings
Join Date: Aug 2014
Location: Netherlands
Posts: 882
|
|
01-18-2019, 08:44 AM | #24 | |
Human being with feelings
Join Date: May 2009
Posts: 29,269
|
Quote:
If I weren't so busy I'd take a look and try to solve but sort of overloaded with things to accomplish right now. I also have not looked closely at any of what you are doing so I don't want to be too wrong. As far as passing as a variable it may be getting passed as literal string (fancy name for the quotes were assumed because it was a variable). By chaining tools/scripts like this, it is possible to run into some nearly impossible restriction.
__________________
Music is what feelings sound like. |
|
01-18-2019, 10:08 AM | #25 | |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Quote:
I want to learn and this is why I want to find a solution by myself. But it feels kind of stupid that Windows doesn't have a proper way to do such things. The internet is full of discussion about this. I mean, if you have a "program files" as default directory, why wont you allow white spaces for it? "" Would be enough but this doesn't work in any case.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
|
01-18-2019, 10:16 AM | #26 | ||
Human being with feelings
Join Date: May 2009
Posts: 29,269
|
Quote:
https://en.wikipedia.org/wiki/Comman...pace_character Quote:
__________________
Music is what feelings sound like. Last edited by karbomusic; 01-18-2019 at 10:25 AM. |
||
01-19-2019, 03:20 AM | #27 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
I did it! (✿◔‿◔)
And it was really tricky as all variations didn't seem to help. So I decided to use Lua's [[ everything goes ]] string without any escaping and bamm! It worked. I cam to this conclusion because the path with spaces inside was okay. It was possible to send it all alone to CMD and it just opened mkvmerge in the console. So it was not the path but the string chain after it which broke the whole commando line. Anyway. Now it works with spaces. And I added a "clean" button which allows to delete all timestamps if the video source changes but the dialog stays open. Download updated in the first post. But here again: Attachment 35494
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
01-19-2019, 05:27 AM | #28 |
Human being with feelings
Join Date: May 2009
Posts: 29,269
|
Yay! and nice job.
__________________
Music is what feelings sound like. |
02-02-2019, 10:30 AM | #29 |
Human being with feelings
Join Date: Apr 2016
Posts: 50
|
Thanks for the script, very usefull.
I split my mkv file with "AC3 audio" and got a new audio "AC3_cut" with "Delay relative to video : 24 ms". Delay is visible in MediaInfo. It would be useful to make splits without delays. Can you fix it? Last edited by HDWind; 02-02-2019 at 11:05 AM. |
02-03-2019, 06:46 AM | #30 | |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Quote:
there are probably some downsides relating to sound/video synchronization. But this is made by mkvToolnix. You have to understand that mkvMerge gets the timestamps and tries to cut as near as possible at the given timestamp. But it only is able to cut exactly on keyframes (codec kexframes) because in some codecs those are the only non-interpolated frames at all. For example: If every 13th frame is a keyframe, all frames in between will be interpolated from the decoder. Its not possible to cut a video on an interpolated frame without re-encoding (with loss) except if you save every decoded frame (like in Reapers preview, where every interpolated frame is displayed as solid frame) uncompressed. For me its impossible to change mkvToolnix's behavior as the script has no idea where the keyframes are. If you want to cut it manually and have a lot more options you should use the "> Clipboard" button to copy all timestamps into the clipboard. After copying you could open the video with mkvToolnix gui and paste the timesptamps in the output panel after choosing the right split option (split based on timestamps). I'm not sure if you have the ability to get rid of your problem. And I even have no idea why you get this delay. It could be the case that audio and video get split separately while audio gets split exactly on point and video only at nearest point on keyframe. I will take a look as soon as possible if there is a solution for that. Greetings ELi
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Last edited by Eliseat; 02-03-2019 at 06:52 AM. |
|
Thread Tools | |
Display Modes | |
|
|