@echo off
sfk script "%~f0" -from begin %*
GOTO xend
sfk label begin -var
+if "%1 = " begin
+tell "[green]vedit 1.0.5 - edit a video file[def]"
+tell ""
+tell "vedit command input output[.ext] [-yes][def]"
+tell ""
+tell "1. run VLC with a video in the current folder"
+tell " (not in a sub folder), with a simple filename"
+tell " with just one extension (not foo.m3u8.mkv)."
+tell " press CTRL+B to show the bookmarks."
+tell " mark start and end of each part to extract."
+tell " there must be an even number of bookmarks."
+tell " CTRL+Y and save playlist file: parts.xspf"
+tell ""
+tell "2. type one of these commands:"
+tell ""
+tell " [green]vedit get parts.xspf outdir\video01[def]"
+tell " get parts and store as outdir\video01-part01/02/..."
+tell " keeping the original file extension/format"
+tell ""
+tell " [green]vedit get parts.xspf outdir\video01 .mpg[def]"
+tell " convert parts to .mpg format"
+tell ""
+tell " [green]vedit join parts.xspf video01[def]"
+tell " get parts and rejoin as video01.xyz"
+tell " keeping the origial extension/format"
+tell ""
+tell " [green]vedit join parts.xspf video01.mpg[def]"
+tell " join and convert to given format like .mpg"
+tell ""
+tell " [green]vedit wipe[def]"
+tell " cleanup the zzsfktmp folder"
+tell ""
+tell " [green]vedit shrink in.mov out.mov[def]"
+tell " create video with halve width and height"
+tell ""
+tell " [green]vedit scale in.mov 640:400 out.mov[def]"
+tell " scale video to given resolution"
+tell ""
+tell "if it fails try simple filenames, without folders,"
+tell "backslashes or special characters."
+tell ""
+stop
+endif
+setvar partlist=""
+setvar lastext=""
+setvar diffext=0
+setvar userext=""
+if "%1 = wipe" begin
+rmtree zzsfktmp -yes
+stop +endif
+if "%1 = get" begin
+if "%2 = " stop "missing input .xspf filename"
+if "%3 = " stop "missing output base, e.g. outdir\video01"
+call getparts %2 %3 %4 %5
+stop +endif
+if "%1 = join" begin
+if "%2 = " stop "missing input .xspf filename"
+if "%3 = " stop "missing output filebase/name, e.g. video01 or video.mpg"
+mkdir zzsfktmp
+call getparts %2 zzsfktmp/edit %4
+echo -pure "%3" +xed _\\_/_ +setvar out
+call joinparts #(out) %4
+stop +endif
+if "%1 = scale" begin
+if "%4 = " stop -all "usage: vedit scale in.mov 640:400 out.mov"
+setvar in="%2" +setvar out="%4"
+run %5 "ffmpeg -y -i #(qin) -vf scale=%3 #(qout)"
+if "%5 = -yes" list -time -size #(in) #(out)
+stop +endif
+if "%1 = shrink" begin
+if "%3 = " stop -all "usage: vedit shrink in.mov out.mov"
+setvar in="%2" +setvar out="%3"
+run %4 "ffmpeg -y -i #(qin) -vf scale=iw/2:-1 #(qout)"
+if "%4 = -yes" list -time -size "#(in)" "#(out)"
+stop +endif
+tell "unknown command: %1"
+end
sfk label getparts
// expects a VLC bookmark file like "parts.xspf" containing a record like:
// file:///C:/vid/foobar.mov
// bookmarks={name=myfile.MOV #0,time=749.750},{name=myfile.MOV #1,time=844.500},{name=myfile.MOV #2,time=1680.250},{name=myfile.MOV #3,time=1751.250}
+setvar infile="%1"
+setvar outbase="%2"
+setvar userext="%3"
+setvar yes="%4"
+if "#(userext) = -yes" begin
+setvar userext=""
+setvar yes="-yes"
+endif
+if "#(contains(infile,'.xspf')) = 0" stop -all "supply an .xspf file as input"
+setvar npart=1
+xex %1
"_*_[all]\n_"
"_bookmarks=**_[part2]\n_"
+perline -setvar line "call getpart1" -yes
+end
sfk label getpart1
+if "#(contains(line,'')) = 1" begin
+getvar line
+xex "_*_[setvar file][part2][endvar]_"
+getvar file +xed "_*/__" +decode -url +setvar file
// +tell "file: #(file)"
+stop +endif
// +tell "book: #(line)"
+getvar line
+xex
"_{name=* #*,time=*},{name=* #*,time=*}_[part2]\t[part6]\t[part12]\n_"
+perline -setvar book "call getpart2" -yes
+end
sfk label getpart2
+getvar book
+xex "_*\t*\t*
_[setvar title][part1][endvar]
[setvar sabs][part3][endvar]
[setvar eabs][part5][endvar]_"
+setvar iext="#(strrpos(file,'.'))"
+setvar ext="#(substr(file,iext))"
+if "#(userext) <> " setvar ext="#(userext)"
+if "#(lastext) = " setvar lastext=#(ext)
+if "#(lastext) <> #(ext)" setvar diffext=1
+calc "#(eabs)-#(sabs)" +setvar duration
+setvar partfile="#(outbase)-#(03npart)#(ext)"
+then run #(yes) "ffmpeg -y -ss #(sabs) -i #(qfile) -c copy -t #(duration) #(qpartfile)"
+calc "#(npart)+1" +setvar npart
+echo "file '#(partfile)'" +addtovar partlist
+end
sfk label joinparts
+setvar outfile="%1"
+setvar codec=""
+setvar iext="#(strrpos(outfile,'.'))"
+if "#(iext) = -1" begin
+if "#(diffext) = 1" call multiformerr
+if "#(diffext) = 0" setvar codec="-c copy"
+setvar outfile="%1#(ext)"
+endif
+if "#(iext) <> -1" begin
+setvar oext="#(substr(outfile,iext))"
+if "#(oext) = #(ext)" setvar codec="-c copy"
+endif
+getvar partlist +tofile zzsfktmp\infiles.txt
+then run %2 "ffmpeg -y -f concat -i zzsfktmp\infiles.txt #(codec) -timecode 00:00:00.0 #(qoutfile)"
+if "%2 = -yes" sel -time -size #(outfile)
+end
sfk label multiformerr
+tell "input files have multiple formats."
+tell "you must supply an output file extension, e.g. #(ext)"
+tell "joining different input formats may not work at all."
+stop -all
+end
:xend