Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

4/16/2015

pip.exe runtime error : Python

# Introduction : Fatal error in launcher, Unable to create process using 'C:\Python27\python.exe'   'C:\Python27\Scripts\pip.exe'
This error is because of change in Python environment, to fix it, all you have to do is, tell every program which is not running about this new python environment.

like LINUX command line applications, first line is for program selection, for example,
=> If you are writing a bash script, first line of script will be,
#!/usr/bin/env bash
OR
#!/bin/bash

=> If you are writing a python executable script, first line of script will be,
#!/usr/bin/env python2.7
OR
#!/usr/opt/python27/python2.7
OR
#!/usr/local/bin/python2.7

So, this first line is about, how and using which program, you want to execute it, and where is that program , which you installed.
If you had changed path of this program executable, you also have to tell all your scripts about it, If path to this program is absolute.

#!/usr/bin/env python
This line of code is going to ask  env  program, about absolute location of python executable, if python executable is inside System PATH environment variable (Directories).

# General Solution:-
=> If your python script (like, pip.exe, pip2.exe, easy_install.exe, ipython.exe) do not know about, new location of python interpreter,
then you are going to tell it about python, either by embedding new location of python interpreter or invoking that script with python interpreter.



# Method 1:-
=> Using Python Interpreter (invoke python script with python script executable )
(After adding, python.exe into System PATH environment variable)
You can invoke any python module, using python interpreter, like this

python -m pip install ipython

(select python module named, pip and pass two command line arguments, install, and ipython)

# Method 2:-
=> Using Hex Editor to update new location/path for Python Interpreter.
If all you have is pip.exe (, pip2.exe, easy_install.exe, ipython.exe) instaed of pip.py
then, How your python script knows about python interpreter location/path.
Well, location/path of python interpreter is embeded into it, and you are going to edit it using Hex editor,
A good Hex Editor is Neo Hex Editor, that is Free for personal/limited use.

=> Open  pip.exe using Hex Editor of your choice.
Look for  Python  string inside pip.exe
Program will locate something like this,
#!C:\Python27\python.exe

<Image>
__python_error_before_hex_editing



All you have to do is,
Either change this path to new absolute path to python interpreter.
OR
Edit it like so, (You are telling this script to look for a program name python.exe, which is inside system path environment variable Directories)
#!python.exe


<Image>
__python_error_after_hex_editing


# Method 3:-
=> Using 7zip program to extract __main__.py script from pip.exe (or other similar program, which is showing this runtime error)
=> type __main__.py

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

=> save as this file to pip.py in Script Directory.
=> If you want to invoke this program, use python interpreter.
python pip.py install ipython

=> If you like then you can also create a Batch file ( pip.bat )
@echo off
python %~dp0pip.py %*

# Remember,
%cd%    => expands to current working directory
after expanf   =>  example ,    ( D:\cmder\bin )
%~dp0   => expands to script directory ( where script file in resides on file-system )
after expand   =>  example ,   ( D:\cmder\bin\ )



1/21/2015

Custom Build System for Python : Sublime-Text-3


# Result ( For Linux ):- 
    # Allow you to run Python Script Directly, Just hit CTRL+B
    # Debug your Python script easily using IPython Terminal/Console.
        # So, You have a Python Script and there is something that you want to check out after completion of Python Script. then you need to Hit SHIFT+CTRL+B keys.
        # So that Sublime runs build+run command, So far we have defined that first we want to execute our script using IPython interactive environment and then we want to take a look at Objects/Variables/results/output generated by our Python script.



# Sublime 3: Custom Build System Script for Python :-


{
    "shell_cmd": "xterm -hold -e python \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python, source.py",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "xterm -fg green -hold -e ipython -i \"${file}\""
        }
    ]
}

9/09/2014

fileLocator : A Simple tool to search for your files faster than ever



# fileLocator is a simple tool BUILD using Python and PyQt4, 
and I have Build two simple version for this tool : ==
# Download :

    http://filelocatorforwin.sourceforge.net

#1. fileLocator console application, for those who love command line applications.
#2. fileLocator-GUI application, that is very easy to use and another advantage of this application is that, This is a Portable application, means you can just download and put it anywhere and use it, No need to download and Install and install other dependencies. This will work just fine even if you use this on any computer from USB drive/Memory card.

  
# How you can look for files faster than ever
 # In this application I have made two new changes, if you made use them properly then you can think that it has amazing speed.
 # first you should use Disk Index file and by default I have turned off this option, Because you better know that when you should use this option.
 # If you are going to use Disk Index file for your defined path then You should keep one thing in mind, that when you think that disk index files are old or Out-dated than you should update disk index file.
 # Other thing is define depth for Directory tree carefully because 0 means Infinite depth for Directory tree, and This will take more time if you use a particular depth other than ZERO but In case if you are Using Disk Index file, than this will take few seconds to look for files and folders even if you are using a 2TB HARD DRIVE Index file.




6/10/2014

First Step with Python ..-->> 001






# What is Python :-                                                                                                                                   
>> General Purpose Language and full object Oriented Programming Language
>> Portable, runs on almost every Operating System available Today
>> High Quality Apps can be rapidly developed and Maintained Easily

<Source:  https://en.wikipedia.org/wiki/Python_(programming_language) >

# Programmer aspects from a Language : -                                                                                            
>> Dynamic and general Purpose
>> Easy to learn and remember
>> Readability and easier to maintain codes
>> High level Interpreted Language
>> Built-in documentation
>> high Quality modules
>> Easier to make your own modules
>> object oriented Programming Language
>> large set of Python Modules or Libraries
>>

# Why you should learn Python :-                                                                                                        


# Primary Resource to learn about python :-                                                                                      
1.> https://wiki.python.org/moin/BeginnersGuide  # Beginners guide

2.> https://www.python.org/about/apps                  # choose popular python module according to your Interest.

3.> http://pypi.python.org/pypi                               # Python module index

# Getting started Python : -                                                                                                                       


## Installing on linux :-
sudo apt-get install python
sudo apt-get install python3
sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install python-numpy
sudo apt-get install python-matplotlib
sudo apt-get install python-scipy
sudo apt-get install python-pillow
sudo apt-get install python-pygame
sudo apt-get install python-django

and so on..

## Installing on Windows :-
### Download and Install Python from https://www.python.org/downloads/


### Use Portable Python :- ( BEST )
http://portablepython.com/wiki/Download/
>>> Personally, I like this Project Because of Large set of third party python libraries -
 NumPy, SciPy, Matplotlib, PyWin32, Django, PIL, wxPython, PyQt, PyGame, etc. code editors
- PyScripter and IDLE all packaged in a single installer.
- NumPy == Numerical python
- SciPy   == for scientific calculations
- Matplotlib == for graph plotting and many more cool stuff
- PyWin32  == Python script to exe
- Django    == Python based popular Web FrameWork
- PIL           == Python imaging Library
- wxPython  == GUI apps development using python
- PyGame  == Rapid Game Developement using python
- IDLE  == Interactive IDE for Python
- PyQt == GUI Framework for Python based UPON Qt
- Tkinter == GUI Framework







>>> So you do not need to Install Python Again and Again, Install Python to USB drive and take it anywhere you want.




## Installing Python Modules :-                                                                                                                
### For Windows :-
>>> Unofficial Windows Binaries for Python Extension Packages
http://www.lfd.uci.edu/~gohlke/pythonlibs/

### For Linux :-
>>> You can use PIP or easy_install
for example :-
sudo pip install numpy
sudo pip install pandas

>>> OR use your system package manager
for example for Ubuntu( Debian based)
sudo apt-get install python-numpy
sudo apt-get install python-mmtk


## Interactive Python :-

    IPython
    IDLE
    WinPython

## IDE for Python :-
    PyDev for eclipse
    Spider
    Eric
    IDLE

or You can use:
    NotePad++
    gEdit
    kWrite
    Notepad itself.

# Online Python Interpreters :-                                                                                                                  
1.> http://www.compileonline.com/execute_python_online.php
2.> https://www.learnstreet.com/lessons/study/python
3.> http://www.pythonanywhere.com/
4.> http://repl.it/languages/Python    

## Books You Must read, and Recommended Books for Python:-                                                          
1:: A Byte of Python ( C. Swaroop )
2:: Learn Python the hard way ( Zad A. Shaw)
3:: Building Skills in Python ( Steven F. Lott )
4:: Beginning Game Development with Python and Pygame  ( Will McGugan )
5:: Making use of Python ( R. gupta )
6:: The Definitive Guide to Jython - Python for the Java Platform 
( Josh Juneau, Jim Baker, Victor Ng, Leo Soto, Frank Wierzbicki )
7:: Programming Computer vision with Python :: ( Jan Erik Solem )
8::  Mysql for Python ( Albert Lukaszewski )
9:: Python Pocket Refrence ( Mark Lutz )
10:: Natural Language Processing with Python
( Steven Bird, Ewan Klein, and Edward Loper ) 
11:: Begining Python ( James Payne )
12:: A Primer on Scientific Programming with Python
( Hans Petter Langtangen ) 
13:: Rapid GUI Programming with Python and Qt
( Mark Summerfield )
14:: Python Web Development with Django®
( Jeff Forcier, Paul Bissex, Wesley Chun )
15:: Matplotlib for Python Developers
( Sandro Tosi )
16:: Head First Python  ( Paul Barry )
17:: Tkinter Refrence :: A GUI for Python ( John W. Shipman )
18:: Gray hat Python ( Justin Seitz )
19:: Core Python Programming ( y Wesley J. Chun )
20:: Fundamentals of Python 
( MartinKenneth A. LambertOsborne )



##


5/17/2014

My Python Project :: FFplayer a Fastest Video Player Using FFMPEG Library..

Go To https://sourceforge.net/projects/ffplayer-and-converter/
           ## For Binary Download
           ## fastest Video player Build Using Python and Tkinter and FFMPEG + FFPLAY

#FFplayer Python code
###@ http://pastebin.com/RGqeup3A
    #!/usr/bin/env python
    # file name = ffplayer ( build using ffmpeg multimedia library )
    # developer :: Shishtpal
    import os, glob, shutil, sys, tempfile, subprocess, ctypes, time
    import Tkinter as tk
    import tkFileDialog
    vlist = set()
    index_no = 0
    # < Program Code #10001@ >
    # Code Block used to add files to vlist, that we use as an argument with this script.
    try:
            if len(sys.argv) == 1:
                    cwd = ''
            else:
                    cwd = sys.argv[1:]
            for i in cwd:
                    print i
                    vlist.add(i)
            print "\n\n"
    except:
            print "Error in Program Code #10001@"
    def tk_gui():
            global root, cwd
            global  index_no
           
            root = tk.Tk()
            root.wm_geometry(newGeometry='250x0+10+10')  
            root.wm_title("Ffplayer ( Video Player )")
            menubar = tk.Menu(root)
            root.config(menu=menubar)
            # Creating a menu button
            filemenu1 = tk.Menu(menubar)
            filemenu2 = tk.Menu(menubar)
            filemenu3 = tk.Menu(menubar)
            menubar.add_cascade(label='Player', menu=filemenu1)
            menubar.add_cascade(label='Control', menu=filemenu2)
            menubar.add_cascade(label='Help', menu=filemenu3)
           
            def button1Click():    
                    """
                    this code block is used to play a single video file,
                    this video file will be added to vlist playlist
                    """
                    global cwd, vlist
                    print "Opening Video File :-)\n\n"
                    openfilename = tkFileDialog.askopenfilename(title="Select Video/Mp3 File..", initialdir="C:\\")
                    cwd = openfilename
                    vlist.add(cwd)
                    vid_player(cwd)
            def button2Click():
                    """
                    this code block is used to open a window dialog box asked you to select
                    a folder and filter all video files in your defined location,
                    and add all of them to your vlist
                    """
                    global cwd
                    print "Open a folder with Video File :-)\n\n"
                    openfoldername = tkFileDialog.askdirectory()
                   
                    b = openfoldername.split("/")
                    cwd = ''
                    for i in range(len(b)):
                            cwd = cwd + "\\" + b[i]
                    cwd = cwd[1:]
                    print cwd
                    vid_player(cwd)
                    play_video()
                   
            """                    
            def button3Click():
                    print "Open Settings Panel :-)\n\n\n"
                    #p1 = subproecess.call([])
            """
           
            def button4Click():
                    print "Bye Bye!!"
                    sys.exit()
            # create action for button 'Quit'
            filemenu1.add_command(label='Open File (o)', command=button1Click)
            filemenu1.add_command(label='Open Folder (f)', command=button2Click)
            #filemenu1.add_command(label='Settings', command=button3Click) 
            filemenu1.add_separator()
            filemenu1.add_command(label='Quit (q)', command=button4Click) # bind a event using command method
           
            #
            root.bind("<o>", lambda e: button1Click()) # bind a shortcut using lambda method
            root.bind("<O>", lambda e: button1Click())
           
            root.bind("<f>", lambda e: button2Click())
            root.bind("<F>", lambda e: button2Click())
           
            root.bind("<Q>", lambda e: button4Click())
            root.bind("<q>", lambda e: button4Click())
            #
            def next_video():
                    global p1
                    try:
                            p1.kill()
                    except:
                            print "\n\nThere is NO ffplay.exe subprocess Exists!!\n\n"
                    play_video()
                   
            def play_video():
                    global index_no, p1
                    print "\n", "##"*35
                    print "vlist contents :: ", len(vlist)
                    print "    # Current Video file Index Number Is :: ", index_no, "\n"
                    if len(vlist) > 0:
                            try:
                                    print "##"*35, "\n\n"
                                    p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no]])
                            except:
                                    pass
                    else:
                            print "\n\nHello, There is no Video File in your PlayList !!!\n\n\n"
                    if index_no <= len(vlist):
                           
                            index_no += 1
            def read_manual():
                    try:
                            subprocess.call(["notepad.exe", "source\\ffplay.help.txt"])
                    except:
                            print "Manual for ffplay Not Exists!!!"
                           
            def start_ffmpeg_web():
                    root1 = tk.Tk()
                    myContainer2 = tk.Frame(root1)
                    myContainer2.pack()
                    myLabel1 = tk.Label(myContainer2)
                    myLabel1.configure(text="Go to http://trac.ffmpeg.org", background="yellow")
                    myLabel1.pack()
                    button1 = tk.Button(myContainer2)
                    button1.configure(text="OK", background="green")
                    button1.pack()
                    root1.update()
                    time.sleep(2)
                    root1.destroy()
           
            def about_ffplayer():
                    print "\n  FFPLAYER is a video player build using ffmpeg library..\n\t Build By ( Shishtpal )"
                    root1 = tk.Tk()
                    myContainer2 = tk.Frame(root1)
                    myContainer2.pack()
                    myLabel1 = tk.Label(myContainer2)
                    myLabel1.configure(text="\n  FFPLAYER is a video player build using ffmpeg library..\n\t Build By ( Shishtpal )", background="cyan")
                    myLabel1.pack()
                    button1 = tk.Button(myContainer2)
                    button1.configure(text="OK", background="green")
                    button1.pack()
                    root1.update()
                    time.sleep(4)
                    root1.destroy()
                   
            def explore_video_folder():
                    loop_player()
                    global index_no, vlist, cwd, p1
                    print "\n##"*10
                    print "\n    ## After Exploring Video Folder I Found", len(vlist), "Files.."
                    print "    # Current Video file Index Number Is :: ", index_no
                    print "    # Your Working Directory is ::", cwd, "\n\n"
                   
                    if len(vlist) > 0:
                            index_no = 0
                            if p1.poll() == None:
                                    p1.kill()
                            if True:
                                    for i in range(len(vlist)):
                                            print "\n", "##"*35
                                            print "\n   #Playing Video File :: ", list(vlist)[index_no], "\n"
                                            p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no]])
                                            print "\n    # Current Video file Index Number Is :: ", index_no, "\n"
                                            print "\n", "##"*35
                                            index_no += 1
                                            p1.wait()
                            else:
                                    pass
                                   
            def loop_video():
                    global index_no, p1, vlist
                    try:
                           
                            if p1.poll() == None:
                                    p1.kill()
                                    print "\n", "##"*35
                                    print "\n    # Current Video file Index Number Is :: ", index_no-1, "\n\n"
                                    p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no-1]])
                            elif len(vlist) == 1:
                                    print "\n", "##"*35
                                    print "\n    # Current Video file Index Number Is :: ", index_no, "\n\n"
                                    p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no]])
                            else:
                                    print "\n", "##"*35
                                    print "\n    # Current Video file Index Number Is :: ", index_no-1, "\n\n"
                                    p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no-1]])
                           
                    except:
                            print "  # Error in loop_video Function. #"
           
            def previous_video():
                    global index_no, p1, vlist
                    if index_no > 1:
                            try:
                                    if p1.poll() == None:
                                            p1.kill()
                                            p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no-2]])
                                           
                                    else:
                                            p1 = subprocess.Popen(["ffplay.exe", "-autoexit", list(vlist)[index_no-2]])
                                    print "\n    # Current Video file Index Number Is :: ", index_no-2, "\n"
                                    print "##"*35, "\n"
                                   
                                    if index_no != 0:
                                            index_no -= 1
                            except:
                                    print "Error While playing Previous Video File.."
                    else:
                            print "There is No Previous Video File Exists..."
                            index_no = 0
                   
            root.bind("<m>", lambda e: play_video())
            root.bind("<M>", lambda e: play_video())
           
            root.bind("<n>", lambda e: next_video())
            root.bind("<N>", lambda e: next_video())
           
            root.bind("<k>", lambda e: previous_video())
            root.bind("<K>", lambda e: previous_video())
           
            root.bind("<l>", lambda e: loop_video())
            root.bind("<L>", lambda e: loop_video())
           
            filemenu2.add_command(label='Play Video (m)', command=play_video)
            filemenu2.add_command(label='Next Video (n)', command=next_video)
            filemenu2.add_command(label='Previous Video (k)', command=previous_video)
            filemenu2.add_command(label='Loop Video (l)', command=loop_video)
            filemenu2.add_separator()
           
            def print_playlist():
                    print "\n", "@#"*30
                    print "Play-list Contents :: ", "\n"
                    for i, j  in enumerate(vlist, 1):
                            print i, j
                    print "@#"*30, "\n"
            filemenu2.add_command(label='Print Playlist', command=print_playlist)
           
            def open_playlist_file():
                    global vlist, index_no, p1
                    print "Opening Play-list File :: "
                    try:
                            openfilename = tkFileDialog.askopenfilename(filetypes=[("PLT", "*.plt" )], title="Select Your Playlist File..", initialdir="C:\\")
                            print "\n", "@#"*30
                            print "You Select :: \n(", openfilename, ") \n\tPlay-list File..", "\n"
                            y = open(openfilename)
                            while True:
                                    a = y.readline()[:-1]
                                    if len(a) == 0:
                                            break
                                    else:
                                            vlist.add(a)
                            y.close()
                            print "\n", "@#"*30, "\n"
                    except:
                            print "No Play-List has been Selected..\n"
            filemenu2.add_command(label='Open Playlist File', command=open_playlist_file)
           
            def write_playlist_file():
                    global vlist
                    print "\n", "**"*30
                    print "We have Write your Current Play-List File To Disk.."
                    print "ffplayer_current_playlist.plt", "\n"
                    x = open("ffplayer_current_playlist.plt", "w")
                    for i in vlist:
                            w = i+"\n"
                            x.write(w)
                    x.close()
                    print "**"*30, "\n"
            filemenu2.add_command(label='Write Playlist File', command=write_playlist_file)
           
            def custom_playlist():
                    print "Customizing Play-list Contents :: "
                   
            #filemenu2.add_command(label='Custom Playlist', command=custom_playlist)
            filemenu2.add_separator()
            filemenu2.add_command(label='Explore Video Folder', command=explore_video_folder)
           
            filemenu3.add_command(label='Manual', command=read_manual)
            filemenu3.add_command(label='About FFMPEG', command=start_ffmpeg_web)
           
            def ffmpeg_howto():
                    try:
                            subprocess.Popen(["notepad.exe", "source\\ffmpeg.howto.txt"])
                    except:
                            print "FFMPEG How To Documentation File Not Exists.."
            filemenu3.add_command(label='FFMPEG How TO ', command=ffmpeg_howto)    
            filemenu3.add_command(label='About ffplayer', command=about_ffplayer)
    def screen_resolution():
            """
            this code block is used to get Screen resolution of your desktop Screen.       
            """
            global screensize
            user32 = ctypes.windll.user32
            screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
            print "Screen Resolution is :: ", screensize, "\n\n"
    screen_resolution()
    def vid_filter(filename):
            if os.path.isdir(filename) | filename.endswith(".jpg") | \
                    filename.endswith(".png") | filename.endswith(".jpeg") | \
                    filename.endswith(".JPG") | filename.endswith(".PNG") | \
                    filename.endswith(".JPEG") | filename.endswith(".txt") | \
                    filename.endswith(".tar.gz") | filename.endswith(".zip") | \
                    filename.endswith(".7z") | filename.endswith(".exe") | \
                    filename.endswith(".pdf") | filename.endswith(".htm") | \
                    filename.endswith(".html") | filename.endswith(".mhtm") | \
                    filename.endswith(".mhtml") | filename.endswith(".lnk") | \
                    filename.endswith(".mht") | filename.endswith(".ini") | \
                    filename.endswith(".db") | filename.endswith(".img") | \
                    filename.endswith(".iso") | filename.endswith(".pkg") | \
                    filename.endswith(".sh") | filename.endswith(".tgz") | \
                    filename.endswith(".css") | filename.endswith(".gif") | \
                    filename.endswith(".c4d") | filename.endswith(".xml") | \
                    filename.endswith(".apk") | filename.endswith(".dat") | \
                    filename.endswith(".doc") | filename.endswith(".docx") | \
                    filename.endswith(".ppt") | filename.endswith(".pptx") | \
                    filename.endswith(".xls") | filename.endswith(".xlsx") | \
                    filename.endswith(".py") | filename.endswith(".pyw") | \
                    filename.endswith(".pyc") | filename.endswith(".pyo") | \
                    filename.endswith(".chm") | filename.endswith(".js")  | \
                    filename.endswith(".gz") | filename.endswith(".cfg")  | \
                    filename.endswith(".inf") | filename.endswith(".sys")  | \
                    filename.endswith(".dll"):
                    return True
    def vid_player(cwd):
            global p1, vlist
            if os.path.isfile(cwd):
                    vlist.add(cwd)
                    p1 = subprocess.Popen(["ffplay.exe", "-autoexit", cwd])
                   
            elif os.path.isdir(cwd):
                    for i in os.listdir(cwd):
                            try:
                                    filename = os.path.join(cwd, i)
                                    if vid_filter(filename):
                                            pass
                                    else:
                                            vlist.add(filename)
                            except:
                                    print "Error While Filtering File Formats..\n\t In vid_player Function..\n"
                                    pass
                                   
            else:
                    print "Hi, I Do not Know, what you Defined !!\n\t as a video file or a folder which contains video files..\n"
    def loop_player():
            """
            This code Block create a list of each and every file recursively,
            But we have used a filter So that wrong File Formats will not be used with
            ffplayer, because this just gives you an error,
            we can also use ffrpobe to know if supplied file is a video file, but this is just
            time consuming process, this would be great if you just use a filter.
            """
            global files, vlist, index_no, cwd
            files = []  
            for i in zip(os.walk(cwd)):
                    files.append(i)
            for i in range(len(files)):
                    for j in files[i][0][2]:
                            try:
                                    filename = os.path.join(files[i][0][0], str(j))
                                    if vid_filter(filename):
                                            pass
                                    else:
                                            vlist.add(filename)
                            except:
                                    print "Error While Filtering File Formats !! In explore video folder Function !!"
                                    pass
    #
    tk_gui()
    root.mainloop()

## FFconverter Python Code
    ##@ http://pastebin.com/gixzxeuj

    #!/usr/bin/env python
    # filename :: video converter using Python ( Based Upon FFMPEG Library )
    print "##"*35
    print "Video Converter Build using Python and FFMPEG library.."
    import os
    import sys
    import tempfile
    import glob
    import subprocess
    import Tkinter as tk
    cwd = ''                # Input file to convert
    cwd21a = ''             # Output file to Convert
    vlist = set()   # Used to create a playlist for converting multiple files simultaneously
    format = ''             # file format or extension to which you want to convert
    duration = ''
    size_of_video = ''
    frame_per_sec = ''
    z = 0
    ffmpeg_command = ''
    def tk_gui():
            root = tk.Tk()
            #root.wm_geometry(newGeometry='250x250+10+10')  
            root.wm_title("Ffconverter ( Video Converter )")
           
            # Container Number 1
            myContainer1 = tk.Frame(root)
            myContainer1.pack()
           
            myLabel1 = tk.Label(myContainer1)
            myLabel1.configure(text="  Select File To Convert  ::   ", background="yellow")
            myLabel1.pack(side=tk.LEFT)
           
            entry1 = tk.Entry(myContainer1)
            entry1.configure(width=100)
            entry1.pack(side=tk.LEFT)
           
            def select_file():
                    """
                    this code block is used to play a single video file,
                    this video file will be added to vlist playlist
                    """
                    global cwd, vlist
                    print "Opening Video File :-)\n\n"
                    openfilename = tkFileDialog.askopenfilename()
                    cwd = openfilename
                    print "You Have Select :: ", cwd
                    entry1.insert(0, cwd)
                    root.update()
            button1 = tk.Button(myContainer1)
            button1.configure(text="Select", background="green", command=select_file)
            button1.pack(side=tk.LEFT)
           
            ## Container Number 3
            myContainer3 = tk.Frame(root)
            myContainer3.pack()
           
            myLabel3 = tk.Label(myContainer3)
            myLabel3.configure(text="Enter Format Name to Convert ::", background="yellow")
           
            myLabel3.pack(side=tk.LEFT)
            entry3 = tk.Entry(myContainer3)
            entry3.configure(width=20)
            entry3.pack(side=tk.LEFT)
           
            def get_format():
                    global format
                    format = tk.StringVar()
                    print "Retrieving File Format.."
                    entry3.index(0)
                    format = entry3.get()
                    print "You want to Convert to :: ", format
                    print "##"*40, "\n"
                   
            button3 = tk.Button(myContainer3)
            button3.configure(text="OK  ", background="cyan", command=get_format)
            button3.pack(side=tk.LEFT)
            ##
            myLabel5 = tk.Label(myContainer3)
            myLabel5.configure(text="Duration, Frame Size, Frame Rate ", background="yellow")
            myLabel5.pack(side=tk.LEFT)
            entry4 = tk.Entry(myContainer3)
            entry4.configure(width=50)
            entry4.pack(side=tk.LEFT)
            def get_size():
                    global cwd, duration, size_of_video, frame_per_sec
                    print "Checking for Oroginal Size of Video File.."
                    filename = cwd
                    result = subprocess.Popen(["ffprobe.exe", filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
                    duration0 = [x for x in result.stdout.readlines() if "Duration" in x]
                    duration = duration0[0].split()[1]
                    result = subprocess.Popen(["ffprobe.exe", filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
                    size_of_video0 = [x for x in result.stdout.readlines() if "Video:" in x]
                    size_of_video1 = size_of_video0[0].split()
                    for i in size_of_video1:
                            if "x" in i:
                                    size_of_video = i
                    frame_per_sec0 = size_of_video0[0].split()
                    print frame_per_sec0
                    frame_per_sec1 = frame_per_sec0.index("fps,")
                    frame_per_sec = frame_per_sec0[frame_per_sec1 - 1]
                   
                    print "\n", "##"*35
                    print "Duration of Video File :: ", duration
                    print "Size of Video Frame :: ", size_of_video
                    print "Frame Rate of Video :: ", frame_per_sec
                    print "\n", "##"*35, "\n"
                    contents = duration + " " + size_of_video + " " +frame_per_sec
                    entry4.insert(0, contents)
                   
            button5 = tk.Button(myContainer3)
            button5.configure(text="OK  ", background="cyan", command=get_size)
            button5.pack(side=tk.LEFT)
           
            ## Conatiner Number 2
            myContainer2 = tk.Frame(root)
            myContainer2.pack()
            myLabel2 = tk.Label(myContainer2)
            myLabel2.configure(text=" File Converted to     ::      ", background="yellow")
            myLabel2.pack(side=tk.LEFT)
           
           
            entry2 = tk.Entry(myContainer2)
            entry2.configure(width=100)
            entry2.pack(side=tk.LEFT)
           
            def Converted_file():
                    global cwd, vlist, format, cwd21a
                    cwd1 = os.path.split(cwd)[0]
                    cwd2 = os.path.split(cwd)[1]
                    cwd21 = cwd2[:-4]
                    cwd21a = cwd1 + cwd21 + "__converted__." + str(format)
                    print "File will be Converted to :: ", cwd21a
                    entry2.index(0)
                    entry2.insert(0, cwd21a)
                   
                    text1.index(1.0)
                    ffmpeg_command_1 = "ffmpeg.exe" + " -i" + " \""+str(cwd)+"\"" + " \""+str(cwd21a)+"\""+"\n"
                    text1.insert(1.0, ffmpeg_command_1)
                   
                   
            button2 = tk.Button(myContainer2)
            button2.configure(text="Save  ", background="green", command=Converted_file)
            button2.pack(side=tk.LEFT)
           
            button7 = tk.Button(myContainer2)
            def clear_entry():
                    entry1.delete(0, tk.END)
                    entry2.delete(0, tk.END)
                    entry3.delete(0, tk.END)
                    entry4.delete(0, tk.END)
                   
            button7.configure(text="Clear ", background="red", command=clear_entry)
            button7.pack(side=tk.LEFT)
           
            ## Container Number 4
            myContainer4 = tk.Frame(root)
            myContainer4.pack()
           
            #myLabel4 = tk.Label(myContainer4)
            #myLabel4.configure(text="Run Custom FFMPEG Commands", background="red")
            #myLabel4.pack(side=tk.LEFT)
            text1 = tk.Text(myContainer4)
            text1.configure(width=100)
            text1.pack(side=tk.LEFT)
           
            def get_ffmpeg_command():
                    global format, cwd, cwd21a, z, ffmpeg_command
                    format = tk.StringVar()
                    print "Retrieving File Format.."
                    text1.index(1.0)
                    #z = 0
                   
                    try:
                            start = str(z+1)+"."+str(0)
                            end = str(z+1)+"."+str("end")
                            try:
                                    if len(text1.get(start, end)) == 0:
                                            #break
                                            print "There is No Custom FFMPEG Commands Exists in This Line..!!"
                                            print "Value of video Index Number z == ", z
                                            pass
                                    else:
                                            z += 1
                                            ffmpeg_command = text1.get(start, end) # one FFMPEG command must be without a new line character
                                            print "\n", "@#"*35
                                            print "You want to run This FFMPEG Command >> \n", ffmpeg_command
                                            print "\n", "@#"*35
                                            print "\n\n"
                                            os.system(ffmpeg_command)
                                            #p1 = subprocess.Popen([ffmpeg_command])
                            except:
                                    print "No More FFMPEG Custom Commands Found In Text Box.."
                                    pass
                    except:
                            print "Error While Running Custom FFMPEG codes.."
                            z += 1
                            pass
                   
            button4 = tk.Button(myContainer4)
            button4.configure(text="Run Custom FFMPEG Command", background="cyan", command=get_ffmpeg_command)
            button4.pack()
           
            button5 = tk.Button(myContainer4)
            def ffmpeg_manual():
                    print "Opening FFMPEG Manual .."
                    try:
                            subprocess.Popen(["notepad.exe", "source\\ffmpeg.help.txt"])
                    except:
                            print "FFMPEG Manual Not Exists.."
                            pass
            button5.configure(text="  Help?  ", background="green", command=ffmpeg_manual)
            button5.pack()
           
            button6 = tk.Button(myContainer4)
            def ffmpeg_examples():
                    print "Opening FFMPEG Examples .."
                    try:
                            subprocess.Popen(["notepad.exe", "source\\ffmpeg.examples.txt"])
                    except:
                            print "FFMPEG Manual Not Exists.."
                            pass
            button6.configure(text="Examples", background="green", command=ffmpeg_examples)
            button6.pack()
           
            ##
           
    tk_gui()
    while True:
            try:
                    exec(raw_input(":: "))
            except:
                    pass