RandomDump

From bernie's
Jump to navigation Jump to search

shelf

function e(s){
	//debugger
	var today = new Date();
	var time = today.toLocaleTimeString(); ;

	//writeLn(time+' '+string(s));
	writeLn(time + ' ' + s.toString());
	//$.writeln(s)
}


// [buttonlaber, effect name or preset name, "fx" or "preset", 
var simpleEffects = [
[ "Fst blur"	, "Fast Blur" 			, "fx" , [ "Blurriness" , 9 ] , [ "Repeat Edge Pixels" , 1 ] ],
[ "Ramp V"	 	, "Ramp"				, "fx" ],
[ "Ramp H"		, "Ramp"				, "fx" , [ "Start of Ramp" , [0 , 0] ] , [ "End of Ramp" , "Expression", "[thisComp.width,0]"] ],
[ "Lvls"		, "ADBE Easy Levels2"	, "fx" ],
[ "Huesat"		, "ADBE HUE SATURATION"	, "fx" ],
[ "Curves"		, "ADBE CurvesCustom"	, "fx" ],
[ "Invert"		, "ADBE Invert"	, "fx" ] 
];






{
	var panel;
	
	function bernieShelf(thisObj) {
		panel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "bernieShelf", [100, 100, 300, 300],{resizeable:true});
		var res = 			
		"group { \
			alignment: ['fill','fill'], \
			alignChildren: ['fill','top'], \
			}";		
		group = panel.add(res);
		addButtons(group);
		resfreshUI(panel);
		return panel;
		
	}


	function addButtons(src){
		for( i = 0 ; i < simpleEffects.length; i++){
			e(simpleEffects[i][0]);
			btn = src.add("button", undefined, simpleEffects[i][0]);
			//src.add ("statictext", [5,5,5,5], '_');
			btn.onClick = function(){
				alert(simpleEffects[i][0].toString());
				//e( 'Btn' + simpleEffects[i][0].toString() );
				//e( (ScriptUI.environment.keyboardState == shiftKey)?'shift On':'shift Off');
				//alert(simpleEffects[i][0]);
			}
		}
	}

	function resfreshUI(src){
		src.layout.layout(true);
		src.layout.resize();
		src.onResizing = src.onResize = function () {
			g = src.children[0];

			e(g.orientation);

			if(src.size[0]>src.size[1]){
				src.orientation = 'column';
				g.orientation = 'row';
			}else{
				src.orientation = 'row';
				g.orientation = 'column';	
			}
			src.layout.layout(true);
			this.layout.resize();
			
			}
		

	}


	bernieShelf(this);
}

h264

# the h264.py file
#
# windows, save into sendto folder so you can access with right click > send to
# to access the folder, write shell:sendto in Win-R (run) menu

debug = True
fps = '24'
codec = 'libx264'  #mjpeg -qscale:v 1 -vendor ap10 -pix_fmt yuvj422p
bitrate = '40000'
loglevel = 'panic' if debug else 'warning'
rawcommand = '-r {} -start_number {} -i "{}" -c:v {} -b:v {}k -pix_fmt yuv420p -hide_banner -loglevel {} -stats "{}"'

ffmpegcommand = '-r 24 -start_number {} -i "{}" -c:v libx264 -b:v 40000k -pix_fmt yuv420p -hide_banner -loglevel panic -stats "{}"'
if debug:
	ffmpegcommand = '-r 24 -start_number {} -i "{}" -c:v libx264 -b:v 40000k -pix_fmt yuv420p -hide_banner -loglevel warning -stats "{}"'

extension = '.mp4'
reg = r'^(.+?)([0-9]+)\.(png|exr|jpg)$'

import sys, os, pickle, subprocess
try:
	import Tkinter as tk
	import tkFileDialog as tkfg 
	import tkMessageBox as tkmb
except ImportError:
	import tkinter as tk
	import tkinter.filedialog as tkfg
	import tkinter.messagebox as tkmb

from os.path import expanduser
import re

target = sys.argv[1]

#get ffmpeg exe, nor error checking, save in a pickle in home folder if found
picklefp = expanduser('~')+'/.ffmpegpref.pckl'
pickle_data = ''
try:
	with open(picklefp, 'rb') as f:
		pickle_data = pickle.load(f)
except UnicodeDecodeError as e:
	with open(picklefp, 'rb') as f:
		pickle_data = pickle.load(f, encoding='latin1')
except Exception as e:
	print('No ffmpeg encoder found: ', e)

if not pickle_data:
	root = tk.Tk()
	root.withdraw()
	tkmb.showinfo("missing ffmpeg", "No ffmpeg executable found, please point to it")
	file_path = tkfg.askopenfilename()
	f = open(picklefp,'wb')
	file_path = '"'+file_path+'"'
	pickle.dump(file_path, f)
	pickle_data = file_path
	f.close()

#figure out image sequence(s) from file or folder, expect path/to/file/(whatever)(digits).(jpg/png/exr)

filelist = []
if os.path.isdir(target):
	for f in sorted(os.listdir(target)):
		match = re.match(reg, f,re.IGNORECASE)
		if match:
			filelist.append(match.groups())

if os.path.isfile(target):
	match = re.match(reg, target,re.IGNORECASE)
	if match:
		target = os.path.dirname(target)
		newReg = '('+os.path.basename(match.groups()[0])+')(\d*)\.('+match.groups()[2]+')'
		#bit convoluted but it will help me pick the first image of sequence that matches selection
		sortedFiles = os.listdir(target)
		sortedFiles.sort()
		for f in sortedFiles:
			match = re.match(newReg, f,re.IGNORECASE)
			if match:
				filelist.append(match.groups())

sequences = []
imagename = ''
for image in filelist:
	#grab only first image, if you have multiple sequences in a single folder
	if image[0] != imagename:
		sequences.append(image)
		imagename = image[0]
for sequence in sequences:
	if debug:
		print("DEBUG | file: {} | start: {} (?) | ext: {}".format(sequence[0],sequence[1],sequence[2]))

	#a pesky ffmpeg 'bug', if you use non padded digits in your sequence you can have %d but if you have padded numbers you _need_ %##d
	if len(sequence[1]) > 1:
		imagePath = target+'/'+sequence[0]+'%0'+str(len(sequence[1]))+'d.'+sequence[2]
	else:
		imagePath = target+'/'+sequence[0]+'%d.'+sequence[2]


	startFrame = int(sequence[1])
	videoPath = target+'/'+sequence[0].rstrip('._-')+extension
	if sequence[2].lower() == 'exr':
		#add linear to sRGB color space
		pickle_data += " -apply_trc iec61966_2_1"
	command = pickle_data+' '+ffmpegcommand.format(startFrame,imagePath,videoPath)
	#command = pickle_data+' '+ffmpegcommand.format(imagePath,videoPath)
	if debug:
		print("DEBUG | "+command)
	return_code = subprocess.call(command, shell=True)	


if debug:
	print(rawcommand.format(fps,startFrame,imagePath,codec,bitrate,loglevel,videoPath))
	print('\007') #play sound
	print("DEBUG | paused. Press a key to quit")
	try:
		raw_input()
	except:
		input()
import tkinter as tk
import tkinter.font as tkFont

class App:
    def __init__(self, root):
        #setting title
        root.title("ffmpeg encoder option")
        #setting window size
        width=300
        height=300
        screenwidth = root.winfo_screenwidth()
        screenheight = root.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        root.geometry(alignstr)
        root.resizable(width=False, height=False)

        fpsLabel=tk.Label(root)
        fpsLabel["text"] = "fps"
        fpsLabel.place(x=10,y=10,width=70,height=25)
        fpsEntry=tk.Entry(root)
        fpsEntry.insert(0, "24")
        fpsEntry.place(x=90,y=10,width=70,height=25)

        bitRateLabel=tk.Label(root)
        bitRateLabel["text"] = "bitrate"
        bitRateLabel.place(x=10,y=40,width=70,height=25)
        bitRateEntry=tk.Entry(root)
        bitRateEntry.insert(0, "40")
        bitRateEntry.place(x=90,y=40,width=70,height=25)

        bitRatembsLabel=tk.Message(root)
        bitRatembsLabel["text"] = "mb/s"
        bitRatembsLabel.place(x=170,y=40,width=100,height=25)

        cboxDebug=tk.Checkbutton(root)
        cboxDebug.place(x=90,y=70,width=207,height=30)
        cboxDebug["offvalue"] = "0"
        cboxDebug["onvalue"] = "1"
        cboxDebug["command"] = self.cboxDebug_command

    def cboxDebug_command(self):
        print("command")

if __name__ == "__main__":
    root = tk.Tk()
    app = App(root)
    root.mainloop()

idk

global string $currentFrameFile;
global int $frameN;
global int $originalFrame;
global string $error;
global int $playblastActive;
global int $tick;
$playblastActive = 0;
$currentFrameFile = $error = "";
$originalFrame = `currentTime -q`;
$frameN = 1;

global proc firePlayblast(){
	firePlayblastUI;
}
proc string findLayout( string $windowUI,string $name )
{//from bryan ewert
  string $controls[] = `lsUI -l -controlLayouts`;
  string $pattern = $windowUI + "*";
  string $layout = "";

  for ( $ui in $controls )
  {
    if ( `gmatch $ui $pattern` )
    {
      string $tokens[];
      int $numTokens = `tokenize $ui "|" $tokens`;
      if ( $numTokens > 1 )
      {
        $layout = $tokens[0] + "|" + $tokens[1];
          string $ca[] = `layout -q -ca $layout`;  
          for ( $c in $ca )
          {      
            return ($layout + "|" + $c);
            break;
          }
        break;
      }
    }
  }
  return false;
}
global proc string pad(float $n){return ($n<1000)? ( ($n<100 )?( ($n<10 )?"000"+$n:"00"+$n ):"0"+$n ) : $n+"";}
global proc string getImagePath(string $extraPath,int $extension){ 
    setAttr "defaultRenderGlobals.outFormatControl" 0;
    setAttr "defaultRenderGlobals.animation" 1;
    setAttr "defaultRenderGlobals.putFrameBeforeExt" 1;
    setAttr "defaultRenderGlobals.extensionPadding" 4;
    string $image = pad(`currentTime -q`);    
    string $tof[] = `renderSettings -gin $image -fp`;
    string $dir = `match "^.*/" $tof[0]`;
    string $filepart = `match "[^/\\]*$" $tof[0]`;
    $filepart = (!$extension)?`match "(.*)[^\.a-z]" $filepart`:$filepart;
    return $dir+$extraPath+$filepart;
}
global  proc string saveFireImage(){
    global string $error;
    global string $currentFrameFile;
//    "+`date -f "MMDD_hhmmss"`+"/
    $filePath = getImagePath("maxwellFirePlayblasts/",0)+".png";
    $mkdir = `sysFile -makeDir (match("^.*/",$filePath))`;
    string $vp = findLayout("MaxwellFIRE","maxwellViewport" );
    if($mkdir && $vp != "0"){
        evalDeferred(`maxwellViewport -e -saveIRImg ($filePath) $vp`);
        $currentFrameFile = $filePath;
    }else{
        $error = "No maxwell FIRE window found";
        firePBrefreshUI;
    }
    return "";
}
global proc firePlayblastUI(){
    global int $frameN;
    int $e = `playbackOptions -query -maxTime`;
    int $s = `playbackOptions -query -minTime`;
    $frameN = $s;
    if (`window -exists playblastFireWindow`) deleteUI playblastFireWindow;
    if (`windowPref -exists playblastFireWindow`) windowPref -remove playblastFireWindow;
    string $window = `window -menuBar true -title "Playblast Fire" playblastFireWindow`;
    string $vp = findLayout("MaxwellFIRE","maxwellViewport" );
    paneLayout -vis ($vp!="0");
    columnLayout -adjustableColumn true;
    progressBar -maxValue 100 -width 300 -vis 1 -en 0 UI_progress;
    textField -text  "'Seconds per frame' includes voxelisation" -en 0 -editable false UI_textfield;
    separator -h 18 -en 0;
    int $timeperframe = `optionVar -q "firePB_secondsperframe"`;
    $timeperframe = ($timeperframe!=0)?$timeperframe:15;
    intFieldGrp -numberOfFields 1 -label "Seconds per frame" -cc "firePBrefreshUI" -value1 $timeperframe UI_timePerF;
    separator -h 12 -en 0;
    intFieldGrp -numberOfFields 1 -label "Start frame" -cc "firePBrefreshUI" -value1 $s UI_startF;
    intFieldGrp -numberOfFields 1 -label "End frame" -cc "firePBrefreshUI" -value1 $e UI_endF;
    intFieldGrp -numberOfFields 1 -label "Frame increment" -cc "firePBrefreshUI" -value1 1 UI_incrF;
    int $firePBlaunchfcheck = (`optionVar -q "firePB_fcheck"`=="yes")?1:0;
    checkBoxGrp -numberOfCheckBoxes 1 -cat 1 "both" 90 -label1 "Launch fcheck" -cc "firePBrefreshUI" -value1 $firePBlaunchfcheck UI_fcheck;
    separator -h 12 -en 0;
    button -label "Playblast!" -command "firePythonThread(0)"  -h 40 UI_playblast;
    separator -h 3 -en 1 -st "none";
    button -label "Explore" -command "firePBOpenSequence(0)" UI_explore;
        separator -h 16 -en 1 -st "none";
    button -label "Close" -command "firePythonThread(1);deleteUI playblastFireWindow ";
        separator -h 5 -en 1 -st "none";
    setParent..;setParent..;
    paneLayout -vis ($vp=="0");
    columnLayout -adjustableColumn true;
    button -label "Launch maxwell FIRE first" -command "firePlayblastUI";
    showWindow $window;
}
global proc firePBTic(int $incr){
	global int $tick;
	global int $frameN;
	

    firePBrefreshUI;
    if(!$incr){
        $tick++;
    }else{
		int $incrF = `intFieldGrp -q -value1 UI_incrF`;
        saveFireImage;
        currentTime -u 1 -e (`currentTime -q`+$incrF);
		if($frameN = `intFieldGrp -q -value1 UI_endF`){
			firePythonThread(1);
		}
		$frameN = `currentTime -q`;
    }
}
global proc firePythonThread(int $kill){
    global int $originalFrame;
    global int $playblastActive;
    global string $error;

     
    python( "import threadProc;from threadProc import Timer;import maya.mel as mm" );
    if(!$kill){
		int $timePerF = `intFieldGrp -q -value1 UI_timePerF`;
        $playblastActive = 1;
        currentTime -u 1 -e (`intFieldGrp -q -value1 UI_startF`);
        python( "def tic():mm.eval('firePBTic(0)')");
        python( "def toc():mm.eval('firePBTic(1)')");
        python( "timerTic = Timer(1, tic, repeat=True);timerTic.start()");
        python( "timerToc = Timer("+$timePerF+", toc, repeat=True);timerToc.start()");
    }else{
		string $vp = findLayout("MaxwellFIRE","maxwellViewport" );
		maxwellViewport -e -irPause 1 $vp;
        $playblastActive = 0;
		$error = "Playblasting stopped";
        python( "timerTic.stop();timerToc.stop()");
        currentTime -e $originalFrame;
		$launchFcheck = `checkBoxGrp -q -value1 UI_fcheck`;
		if($launchFcheck){
			firePBOpenSequence(1);
		}
firePBrefreshUI;		
    }
}
global proc firePBrefreshUI(){
    global string $error;
    global string $currentFrameFile;
    global int $playblastActive;
	global int $tick;
	
    int $startF = `intFieldGrp -q -value1 UI_startF`;
    int $endF = `intFieldGrp -q -value1 UI_endF`;
    int $incrF = `intFieldGrp -q -value1 UI_incrF`;
	int $timePerF = `intFieldGrp -q -value1 UI_timePerF`;
	
    string $textfieldText ="";
    if($playblastActive){
        $cur = `currentTime -q`;
        $progress =  (($endF-$startF)/$incrF)*$timePerF;
		
		progressBar -edit -step ($tick/$progress*100) UI_progress;
	    $textfieldText = "Playblasting ("+$cur+"/"+$endF+")";
        //textField -e -text ( $text) -en 0 -editable false UI_textfield;
        button -e -label "Stop playblast" -command "firePythonThread(1)"  -h 40 UI_playblast;
    }else{
	    button -e -label "Playblast!" -command "firePythonThread(0)"  -h 40 UI_playblast;
        $incrF = ($incrF < 1)?1:$incrF;
        
		if($timePerF<4){
			$timePerF = 4;
			$error += "WARNING: short wait time = possible crash";
		}
		intFieldGrp -e -value1 $timePerF UI_timePerF;
        optionVar -iv "firePB_secondsperframe" $timePerF;
        $launchFcheck = `checkBoxGrp -q -value1 UI_fcheck`;
        optionVar -sv "firePB_fcheck" (($launchFcheck)?"yes":"no");
        if($endF<$startF){
            intFieldGrp -e -value1 ($startF+1) UI_endF;
        }
        float $tte = (($endF-$startF)*1.0*$timePerF)/$incrF*1.0;
        string $seconds = pad(($tte%60.0));
        $textfieldText = floor($tte/60.0)+"'"+substring($seconds,3,4)+"\" necessary for playblast";

    }
    $textfieldText = ($error!="")?$error+"!":$textfieldText;
    textField -e -text ( $textfieldText) -en 0 -editable false UI_textfield;
    intFieldGrp -e -value1 ($incrF) UI_incrF;
    $error = "";
}
global proc firePBOpenSequence(int $fcheck){
    global string $currentFrameFile;
	global int $frameN;
    if($fcheck){
        int $startF = `intFieldGrp -q -value1 UI_startF`;
        int $endF = `intFieldGrp -q -value1 UI_endF`;
        int $incrF = `intFieldGrp -q -value1 UI_incrF`;
        fcheck  -F -n $startF ($frameN-1) $incrF (`substitute "[.*]([0-9]{4})[\.a-Z]" $currentFrameFile ".#."`);
    }else{
        string $dir = `match "^.*/" $currentFrameFile`;
        if(`about -win`){
            system("start explorer " + toNativePath($dir));
        }
    }
}



http://imgur.com/a/PNd7G#0

var xmlFile = new File("~/Desktop/test.xml");
xmlFile.open("r","TEXT","????");
var content = xmlFile.read();
var xml = new XML(content);
var elements = xml.elements();
alert(elements);
<?xml version="1.0"?>
<collections>
    <expression id="position">ddd</expression>
    <date>2012-10-30</date>
    <icon>thumb2032.png</icon>
</collections>

http://www.programmingforums.org/post168124.html

<html>
<head>
<style type="text/css">
body{ height:100% }
div.fullscreen{
    display:block;
    background-color: #dda;
    /*set the div in the top-left corner of the screen*/
    position:absolute;
    top:0;
    left:0;
float:left;     
    /*set the width and height to 100% of the screen*/
    /*width:100%;*/
    height:100%;
  }
#leftCol {float:left;}

#rightCol {width:200px; float:right}
/*#rightCol div {float:left; clear:left;}*/

/*table, table * {white-space: no-wrap}*/
#nav { white-space:nowrap; padding: 4px 6px; margin: 3px; border: 1px solid #ccc; text-decoration: none; background-color: #add; height: 80%;}
#nav img.a1{height: 100%;}
#nav img.b1{height: 50%;}
#nav img.c1{height: 33%;}
#plop {white-space:nowrap; float:left;height: 33%;background-color: #dad;}
</style>
</head>
<body>
<div class="fullscreen">
<div id="nav">
<div id="leftCol">
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class='a1' src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="a1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="a1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
</div>
<div id="rightCol">
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class='b1' src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="b1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="b1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
</div>
</div>
</div>
</body>
</html>