/usr/share/xcrysden/Tcl/movieEncoders.tcl is in xcrysden-data 1.5.60-1build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | #############################################################################
# Author: #
# ------ #
# Anton Kokalj Email: Tone.Kokalj@ijs.si #
# Department of Physical and Organic Chemistry Phone: x 386 1 477 3523 #
# Jozef Stefan Institute Fax: x 386 1 477 3811 #
# Jamova 39, SI-1000 Ljubljana #
# SLOVENIA #
# #
# Source: $XCRYSDEN_TOPDIR/Tcl/__file__
# ------ #
# Copyright (c) 2008 by Anton Kokalj #
#############################################################################
proc determine_movie_encoders {} {
global xcMisc
set gif_encoder_priority_list {convert gifsicle whirlgif}
set movie_encoder_priority_list {mencoder ppmtompeg}
if { [info exists xcMisc(gif_encoder)] } {
set gif_encoder_priority_list [linsert $gif_encoder_priority_list 0 [file tail $xcMisc(gif_encoder)]]
}
if { [info exists xcMisc(movie_encoder)] } {
set movie_encoder_priority_list [linsert $movie_encoder_priority_list 0 [file tail $xcMisc(movie_encoder)]]
}
foreach enc $gif_encoder_priority_list {
if { [info exists xcMisc($enc)] } {
set xcMisc(gif_encoder) $enc
break
}
}
foreach enc $movie_encoder_priority_list {
if { [info exists xcMisc($enc)] } {
set xcMisc(movie_encoder) $enc
break
}
}
}
# ------------------------------------------------------------------------
#
# AVI/MPEG movies
#
# ------------------------------------------------------------------------
proc encode_movie {filelist outfile} {
global gifAnim xcMisc system
if { $gifAnim(temp_files_dir) == "pwd" } {
set dir $system(PWD)
cd $system(PWD)
} else {
set dir $system(SCRDIR)
cd $system(SCRDIR)
}
set cmdLine [cmdLine_$xcMisc(movie_encoder) $filelist $outfile $dir]
set cw [DisplayUpdateWidget "Encoding" "Encoding the movie"]
eval xcCatchExecReturnRedirectStdErr $cmdLine
destroy $cw
}
proc cmdLine_ppmtompeg {filelist outfile input_dir} {
global xcMisc
return "$xcMisc(ppmtompeg) [mpegCreateParamFile $outfile $input_dir [join $filelist\n]]"
}
proc cmdLine_mencoder {filelist outfile input_dir} {
global gifAnim xcMisc
if { [regexp {\.ppm[ \n\r,]|\.ppm$} $filelist] } {
# we need to convert all *.PPM files to *.PNG files
set cw [DisplayUpdateWidget "Converting" "Converting frame files to PNG format"]
foreach image $gifAnim(filelist) {
set newfile [file rootname $image].png
scripting::_printToFile_imageConvert $image $newfile
}
set tmplist $filelist
regsub -all -- {\.ppm} $tmplist .png filelist
destroy $cw
}
set delay [expr {$gifAnim(delay) <= 0.0 ? 1 : $gifAnim(delay)}]
set fps [expr 100.0 / $delay]
set cmdLine "$xcMisc(mencoder) mf://[join $filelist ,]"
if { [string toupper [file extension $outfile]] == ".AVI" } {
# create AVI file
append cmdLine " -mf fps=$fps -o $outfile -ovc lavc -lavcopts vcodec=mpeg4"
} else {
# create MPEG file
append cmdLine " -of mpeg -mf fps=$fps -o $outfile -ovc lavc -lavcopts vcodec=mpeg2video"
}
if { $gifAnim(edit_param) } {
set cmdLine [gifAnim:editParam $cmdLine]
}
return $cmdLine
}
# ------------------------------------------------------------------------
#
# Animated GIF
#
# ------------------------------------------------------------------------
proc encode_gif {filelist outfile} {
global gifAnim xcMisc mesa_bg system
# determine the background color
if { $gifAnim(gif_transp) } {
if { ! [info exists mesa_bg(current)] } {
set mesa_bg(current) \#000000
}
if { [string index $mesa_bg(current) 0] == "#" } {
set bg_color $mesa_bg(current)
} else {
set bg_color [rgb_f2h $mesa_bg(current)]
}
set gifAnim(bg_color) $bg_color
}
# construct the execution command-line for encoding
set cmdLine [cmdLine_$xcMisc(gif_encoder) $filelist $outfile]
# encode ...
if { $gifAnim(temp_files_dir) == "pwd" } {
cd $system(PWD)
} else {
cd $system(SCRDIR)
}
if { $gifAnim(edit_param) } {
set cmdLine [gifAnim:editParam $cmdLine]
}
puts stderr "cmdLine=$cmdLine"
flush stderr
set cw [DisplayUpdateWidget "Encoding" "Encoding the Animated-GIF movie"]
if { $xcMisc(gif_encoder) != "gifsicle" } {
eval xcCatchExecReturnRedirectStdErr $cmdLine
} else {
eval exec_gifsicle $cmdLine
}
destroy $cw
}
proc cmdLine_convert {filelist outfile} {
global gifAnim xcMisc
if { $gifAnim(gif_transp) } {
append comlin " -dispose Previous"
}
append comlin " $filelist -set delay $gifAnim(delay) -loop $gifAnim(loop)"
if { $gifAnim(gif_global_colormap) && !$gifAnim(gif_transp) } {
append comlin " +map"
}
if { $gifAnim(gif_transp) } {
append comlin " -transparent $gifAnim(bg_color)"
}
if { $gifAnim(gif_minimize) } {
append comlin " -layers optimize"
}
return [format "%s %s %s" $xcMisc(convert) $comlin $outfile]
}
proc cmdLine_gifsicle {filelist outfile} {
global gifAnim xcMisc
set flags "--no-warnings --delay $gifAnim(delay) --loopcount=$gifAnim(loop)"
if { $gifAnim(gif_transp) } {
append flags " --disposal background --transparent=$gifAnim(bg_color)"
}
if { $gifAnim(gif_minimize) } {
append flags " -O2"
}
if { $gifAnim(gif_global_colormap) } {
# ignored
}
return [format "%s %s %s > %s" $xcMisc(gifsicle) $flags $filelist $outfile]
}
proc cmdLine_whirlgif {filelist outfile} {
global gifAnim xcMisc
set flags " -time $gifAnim(delay) -loop $gifAnim(loop)"
if { $gifAnim(gif_minimize) } {
append flags " -minimize"
}
if { $gifAnim(gif_global_colormap) } {
append flags " -globalmap"
}
if { $gifAnim(gif_transp) } {
append flags " -disp prev -trans $gifAnim(bg_color)"
}
return [format "%s %s %s %s %s" $xcMisc(whirlgif) $flags -o $outfile $filelist]
}
proc exec_gifsicle {args} {
xcDebug -stderr "Executing: $args"
if { [catch {eval exec $args 2> gifsicle.stderr} errMsg] } {
# gifsicle returns wrong status of 1 when -transparent option
# is used
set msg [ReadFile gifsicle.stderr]
if { [string match {*Usage: gifsicle*} $msg] } {
ErrorDialogInfo "while executing\nexec $args" $msg\n$errMsg
uplevel 1 {
return 1
}
}
}
return 0
}
|