View Single Post
Old 01-09-2019, 10:57 AM   #9
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

So here is the complete code:
Code:
-- Time2Clip.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.
Note:
	This extension has been tested for VLC 2.0.1 on Win7 sp1.
	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 = "Time2Clip";
		version = "1.0";
		author = "valuex";
		url = 'http://addons.videolan.org/content/show.php?content=149618';
		shortdesc = "Time2Clip";
		description = "<div style=\"background-color:lightgreen;\"><b>just a simple VLC extension </b></div>";
}
end
function activate()
	create_dialog()
end
function deactivate()

end
function close()
	vlc.deactivate()
end

function create_dialog()
	w = vlc.dialog("Time2Clip")
	w1 = w:add_label("<b>Timestamp:</b>",1,1,1,1)
	w2 = w:add_text_input("0",2,1,1,1)
	w3 = w:add_button("jumpto", click_SEEK,1,2,1,1)
	w4 = w:add_button("Save_to_Clip", click_SAVE,2,2,1,1)
end
number = 0
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
        number = number + 1
		w2:set_text(timeString)
		save_to_clipboard(timeString)
	end
end

function click_SEEK()
	local time_togo = w2:get_text()
	local input = vlc.object.input()
	if input then
		vlc.var.set(input, "time", time_togo)	--jump to specified time
	end
end

function save_to_clipboard(var)
	strCmd = 'echo | set /p dummyName='..var..'|clip'
	os.execute(strCmd)
end
Its origin is the VLC extension Time2Clip https://forum.videolan.org/viewtopic.php?t=101114 which didn't work with VLC 3.0. I managed to get it to work properly and to offer me the right time format. I also changed the output with cmd.exe as it wasn't able to give me the time stamp without a space and break after it.

To use this script put it into the extensions folder of VLC 3.0 and open it per menu/view time2clip. It needs clip.exe which should be installed on windows 7. I have no idea if this works on Win 8 or 10. This needs to be tested.

How does it help? - Play a movie which you want to cut into parts without encoding. Open the extension and click once at the save_to_clip button to copy the first time stamp (paste it directly into mkvtoolnix or into a notepad document) and a second time to copy the second (end) time stamp.
(Okay, this explanation makes no sense so maybe I will create a tutorial in the video section as many poeple run into the problem with cutting videos in Reaper.)

My dream would be to start mkvtoolnix right out of this script and sending the timestamps directly. Have no idea if this is possible. But as long as I know mkvtoolnix can get managed over command line.
Eliseat is offline   Reply With Quote