Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/wish8.5
- ###########################前置宣告########################
- set ftype1 {
- {{全部} {*}}
- }
- proc scancodec { ffcmd } {
- set clist [split [exec -ignorestderr $ffcmd -formats] "\n"]
- set ll [llength $clist]
- for {set i 0} {$i<$ll} {incr i} {
- set line [lindex $clist $i]
- set line1 [lindex $line 0]
- if {$line1=="E" || $line1=="DE"} {lappend oclist $line}
- }
- set ocl [llength $oclist]
- for {set i 0} {$i<$ocl} {incr i} {
- lappend ::ocf [lindex [lindex $oclist $i] 1]
- }
- .area2.op3 configure -values $::ocf -state normal
- }
- proc conv {ffcmd ab ar sel inpdir outdir} {
- set ::probmx 0
- set ::count 0
- set par "-ar"
- if {$ar==""} { set par "" }
- set fls [split [exec ls $inpdir] "\n"]
- set ll [llength $fls]
- set ::probmx $ll
- .area4.prob configure -maximum $::probmx
- for {set i 0} {$i<$ll} {incr i} {
- set infile [lindex $fls $i]
- ######檢查檔名異常######
- set llf [string length $infile]
- set c ""
- set infile1 ""
- for {set j 0} {$j<$llf} {incr j} {
- set c [string index $infile $j]
- if {$c==" " || $c=="\[" || $c=="\]" } {
- set c "_"
- #append infile1 "_"
- }
- append infile1 $c
- }
- if {[string match $infile $infile1]==0} {
- file rename $inpdir/$infile $inpdir/$infile1
- set infile $infile1
- }
- ########################
- set outfile [lindex [split $infile "."] 0]
- eval "exec -ignorestderr $ffcmd -ab $ab $par $ar \
- -i $inpdir/$infile -f $sel $outdir/$outfile.$sel"
- incr ::count
- update
- after 1000
- }
- }
- set ab 192k
- set ::ocf ""
- set ::probmx 0
- set ::count 0
- ###########################主程式##########################
- if { [file exists /tmp/ffcmd]==1 } {
- set f [open /tmp/ffcmd r]
- set ffcmd [lindex [split [read $f] "\n"] 0]
- close $f
- }
- label .findff -text "轉檔指令位置:(注意:目前只支援ffmpeg)"
- label .ffpar -text "ffmpeg參數設定:(留空白則使用預設)"
- frame .area1 -relief flat
- frame .area2 -relief flat
- frame .area3 -relief flat
- frame .area4 -relief flat
- button .conv -text "開始轉檔" -command {
- conv $ffcmd $ab $ar $sel $inpdir $outdir
- }
- button .exit -text "離開" -command { exit }
- pack .findff .area1 .ffpar .area2 .area3 .area4 .conv .exit -side top -fill x
- entry .area1.ffpath -textvariable ffcmd
- button .area1.bw -text "瀏覽" -command {
- set ffcmd [tk_getOpenFile -title "轉檔程式的位置" -filetypes $ftype1]
- }
- button .area1.ok1 -text "確定" -command {
- scancodec $ffcmd
- set f [open /tmp/ffcmd w+]
- puts $f $ffcmd
- close $f
- }
- pack .area1.ffpath .area1.bw .area1.ok1 -side left
- label .area2.opl1 -text "音頻碼率"
- entry .area2.op1 -textvariable ab
- label .area2.opl2 -text "音頻採樣率"
- entry .area2.op2 -textvariable ar
- label .area2.opl3 -text "輸出格式"
- ttk::combobox .area2.op3 -values $::ocf -textvariable sel -state disabled
- grid .area2.opl1 -column 1 -row 1
- grid .area2.op1 -column 2 -row 1
- grid .area2.opl2 -column 1 -row 2
- grid .area2.op2 -column 2 -row 2
- grid .area2.opl3 -column 1 -row 3
- grid .area2.op3 -column 2 -row 3
- label .area3.inpl -text "來源音檔目錄"
- entry .area3.inp -textvariable inpdir
- button .area3.inpbw -text "瀏覽" -command {
- set inpdir [tk_chooseDirectory -title "來源目錄" -initialdir [pwd] ]
- }
- label .area3.outl -text "輸出音檔目錄"
- entry .area3.out -textvariable outdir
- button .area3.outbw -text "瀏覽" -command {
- set outdir [tk_chooseDirectory -title "輸出目錄" -initialdir [pwd] ]
- if {[file exists $outdir]==0} { file mkdir $outdir}
- }
- grid .area3.inpl -column 1 -row 1
- grid .area3.inp -column 2 -row 1
- grid .area3.inpbw -column 3 -row 1
- grid .area3.outl -column 1 -row 2
- grid .area3.out -column 2 -row 2
- grid .area3.outbw -column 3 -row 2
- label .area4.prol -text "處理進度:"
- ttk::progressbar .area4.prob -orient horizontal \
- -maximum $::probmx -variable ::count
- pack .area4.prol .area4.prob -side top -fill x
Advertisement
Add Comment
Please, Sign In to add comment