User Tools

Site Tools


mantis:ztx:start

Zenteknix Utilities

Desktop Recording

This is a pair of scripts, a ksh wrapper to launch an ffmpeg capture and a Tcl/Tk GUI for terminating the capture process.

deskvid

#!/bin/ksh
# Copyright (c) 1994-2016 Matt Samudio (Zenteknix)  All Rights Reserved.
# Contact information for Zenteknix is available at http://www.zenteknix.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
VID="$HOME/video/desktop-$$.mkv"
#XDR="1920x1080"								# "1920x1200", "800x600"
XDR="2560x1440"									# "1920x1200", "800x600"
XDO="0,0"									# XDO="734,51"
#APO="-f alsa -ac 2 -i hw:0,0"					# "" (suppresses audio capture)
APO=""
 
ffmpeg ${APO} -f x11grab -s ${XDR} -r 24 -i :0.0+${XDO} -vcodec libx264 -preset ultrafast -threads 4 ${VID} 2>&1 > /dev/null &
dvidkill $! &

dvidkill

#!/usr/bin/wish
# Copyright (c) 1994-2016 Matt Samudio (Zenteknix)  All Rights Reserved.
# Contact information for Zenteknix is available at http://www.zenteknix.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
package require Tk
 
proc calcMetersFromFeet {} {  
   if {[catch {
       set ::meters [expr {round($::feet*0.3048*10000.0)/10000.0}]
   }]!=0} {
       set ::meters ""
   }
}
 
proc layoutConversionGUI {} {
	grid [ttk::frame .c -padding "3 3 12 12"] -column 0 -row 0 -sticky nwes
	grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1
 
	grid [ttk::entry .c.feet -width 7 -textvariable feet] -column 2 -row 1 -sticky we
	grid [ttk::label .c.meters -textvariable meters] -column 2 -row 2 -sticky we
	grid [ttk::button .c.calc -text "Stop" -command killVidRecProc] -column 3 -row 3 -sticky w
 
	grid [ttk::label .c.flbl -text "feet"] -column 3 -row 1 -sticky w
	grid [ttk::label .c.islbl -text "is equivalent to"] -column 1 -row 2 -sticky e
	grid [ttk::label .c.mlbl -text "meters"] -column 3 -row 2 -sticky w
 
	foreach w [winfo children .c] {grid configure $w -padx 5 -pady 5}
}
 
proc layoutVideoGUI {} {
	grid [ttk::frame .c -padding "3 3 12 12"] -column 0 -row 0 -sticky nwes
	grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1
	grid [ttk::label .c.plbl -text "Video Recording PID:"] -column 1 -row 1 -sticky w
	grid [ttk::label .c.procid -text "$::vpid"] -column 2 -row 1 -sticky we
	grid [ttk::button .c.calc -text "Stop" -command killVidRecProc] -column 2 -row 3 -sticky w
	foreach w [winfo children .c] {grid configure $w -padx 5 -pady 5}
}
 
proc killVidRecProc {} {
	try {
		exec kill $::vpid
		set status 0
	} trap CHILDSTATUS { results options } {
		set status [lindex [dict get $options -errorcode] 2]
	}
 
	if { $status == 0 } {
		exit 0
	}
}
 
wm title . "Desktop Video Capture"
 
#layoutConversionGUI
#bind . <Return> {calculate}
#focus .c.feet
 
set vpid [lindex $argv 0]
puts $vpid
layoutVideoGUI
focus .c.procid
bind . <Return> {killVidRecProc}
mantis/ztx/start.txt · Last modified: 2016/03/10 08:28 by admin