Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SplitWithMkvMerge.lua -- VLC extension --
- --[[
- INSTALLATION:
- Put the file in the VLC subdir /lua/extensions, by default:
- * Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
- * Windows (current user): %APPDATA%\VLC\lua\extensions\
- (create directories if they don't exist)
- Restart the VLC.
- Then you simply use the extension by going to the "View" menu and selecting it.
- USAGE:
- Clicking the create button while playing a movie allows you to write a "start timestamp", clicking a second time adds an "end timestamp". You can add more of such time ranges but you have to make sure the last stamp is an "end timestamp".
- If you have the needed time ranges that you want to have split out of the movie simply click on the "> split tool" button to send it to mkvMerge.
- If everything is set up correctly it shoul create the video clips automatically.
- You could use the "> Clipboard" button to copy the timestamps only into the clipboard to insert then manually into mkvToolnix gui (output/split with timestamps) for more options.
- Note:
- This extension has been tested for VLC 3.0.4 on Win7 x64 sp1.
- It needs mkvMerge.exe which is part of the mkvToolnix set. Download: https://mkvtoolnix.download/downloads.html#windows
- Once installed, paste your path to mkvMerge.exe between the "" of mkvMerge_path in this extension.
- Because the function save_to_clipboard needs clip.exe, you've to make sure your windows system has it (just type "echo a |clip" in the cmd prompt window to check whether letter "a" has been put in the system clipboard).
- If it doesn't exist, you can download it from here:
- http://www.labnol.org/software/tutorials/copy-dos-command-line-output-clipboard-clip-exe/2506/
- --]]
- function descriptor()
- return {
- title = "Timestamps to mkvToolnix";
- version = "1.0 not released";
- author = "elisacol";
- url = '';
- shortdesc = "Timestamps to mkvToolnix";
- description = "<div style=\"background-color:lightgreen;\"><b>Send timestamps to mkvToolnix for cutting/splitting videos. (Based on Time2Clip extension.)</b></div>";
- }
- end
- function activate()
- local item = vlc.input.item()
- uri = item:uri()
- uri = string.gsub(uri, '^file:///', '')
- uri = string.gsub(uri, '/', '\\')
- uri = string.gsub(uri, '%%20', '\032')
- mkvMerge_path = "D:/PortablePrograms/mkvtoolnix/mkvmerge.exe"
- -- vlc_path = "C:\\Program Files\\VideoLAN\\VLC\\lua\\extensions\\"
- -- vlc_path = string.gsub (vlc_path, '%%20', '\032')
- create_dialog()
- end
- function deactivate()
- end
- function close()
- vlc.deactivate()
- end
- function create_dialog()
- w = vlc.dialog("Stamps2Toolnix")
- w1 = w:add_label("<b>Timestamps:</b>",1,1,1,1)
- w2 = w:add_text_input("0",2,1,1,1)
- w3 = w:add_button("> Clipboard", send_Clip,3,1,1,1)
- w4 = w:add_button("Create", click_SAVE,2,2,1,1)
- w5 = w:add_button("> Auto Split ", send_Split,3,2,1,1)
- --[[ For testing only
- w6 = w:add_html("<ul><li>Make sure the path to mkvMerge is set in the lua script! <a href=\""..vlc_path.."\">Open the script</a>, search for <b>mkvMerge_path =</b> and insert the path between the <b>\" \"</b>. Save the script! Restart VLC!</li><li>While watching the video click once on <b>Create</b> to create a start timestamp. Click a second time to create an end stamp. This time range will be used by mkvMerge to cut out your clip.</li><li>You can click as often as you want to mark time ranges but you have to make sure your last click is an end timestamp.</li><li>Click on the <b>Clipboard</b> button to copy all timestamps to the clipboard. You can paste them manually into mkvToolnix gui's output splitting dialog if you want to make specific adjustments.</li><li>If you have set the path to mkvMerge correctly you can also send it directly by clicking the <b>Auto Split</b> button. MkvMerge will try to split your videos depending on the timestamps with the most useful settings.</li></ul>",1,3,3,3)
- w7 = w:add_label( vlc_path , send_Clip, 1,4,4,1)
- --]]
- end
- number = 0
- tpool={}
- function click_SAVE()
- local input = vlc.object.input()
- if input then
- local curtime=vlc.var.get(input, "time")
- local curtime=math.floor(curtime/1000)
- local curtime=curtime/1000
- local hours = math.floor(curtime/3600)
- local minutes = math.floor((curtime%3600)/60)
- local seconds = math.floor(curtime%60)
- if number % 2 == 0
- then
- timeString = string.format("%02d:%02d:%02d-",hours,minutes,seconds)
- else
- timeString = string.format("%02d:%02d:%02d,",hours,minutes,seconds)
- end
- table.insert(tpool, timeString)
- finalString = table.concat( tpool )
- finalString = finalString:sub(1, -2)
- w2:set_text(finalString)
- number = number + 1
- end
- end
- 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
Add Comment
Please, Sign In to add comment