Showing posts with label ffconverter. Show all posts
Showing posts with label ffconverter. Show all posts

12/31/2016

Copy all Streams of Media using ffmpeg



FAQ

  • How to copy all streams of some media using ffmpeg
  • Preserve all streams of some media, while spliting media
  • Copy selected streams of media using ffmpeg

Generally media files has two streams, one for video and other one for audio, but when your media file has multiple streams, and you want to copy all those streams to some other media file when you trying to cut or split specific parts from media file.

Example 1

I have recorded some video using TechSmith CamTasia Studio, and it has more than two streams, and i wanna split this into multiple parts, so that i can easily edit in CamTasia Video Editor, and i am using ffmpeg for this.

Case 1 [ Let me show you details of this Media File ]

C:\Users\someone\Camtasia Studio )
=$ ffprobe.exe "Rec 12-30-16.trec"
ffprobe version N-82759-g1f5630a Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --ena
ble-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-
libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enab
le-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-li
bopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspe
ex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzi
mg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 41.101 / 55. 41.101
  libavcodec     57. 66.109 / 57. 66.109
  libavformat    57. 58.101 / 57. 58.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Rec 12-30-16.trec':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2016-12-30T03:58:26.000000Z
  Duration: 00:21:29.64, start: 0.000000, bitrate: 3103 kb/s
    Stream #0:0(und): Video: tscc2 (tsc2 / 0x32637374), yuv444p, 1364x768, 2585 kb/s, 26.25 fps, 30 tbr, 30 tbn, 30 tbc
(default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 253 kb/s (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 253 kb/s (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z

Case 2 [ Cut Marked portion from this Media File ]

C:\Users\someone\Camtasia Studio )
=$ ffmpeg.exe -i "Rec 12-30-16.trec" -ss 150 -t 200 -map 0 -codec copy "Rec 12-30-16
.trec.0.avi"
ffmpeg version N-82759-g1f5630a Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --ena
ble-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-
libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enab
le-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-li
bopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspe
ex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzi
mg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 41.101 / 55. 41.101
  libavcodec     57. 66.109 / 57. 66.109
  libavformat    57. 58.101 / 57. 58.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Rec 12-30-16.trec':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2016-12-30T03:58:26.000000Z
  Duration: 00:21:29.64, start: 0.000000, bitrate: 3103 kb/s
    Stream #0:0(und): Video: tscc2 (tsc2 / 0x32637374), yuv444p, 1364x768, 2585 kb/s, 26.25 fps, 30 tbr, 30 tbn, 30 tbc
(default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 253 kb/s (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 253 kb/s (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
Output #0, avi, to 'Rec 12-30-16.trec.0.avi':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    ISFT            : Lavf57.58.101
    Stream #0:0(und): Video: tscc2 (tsc2 / 0x32637374), yuv444p, 1364x768, q=2-31, 2585 kb/s, 26.25 fps, 30 tbr, 30 tbn,
 30 tbc (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
    Stream #0:1(und): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 253 kb/s (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
    Stream #0:2(und): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 253 kb/s (default)
    Metadata:
      creation_time   : 2016-12-30T03:58:26.000000Z
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame= 5365 fps=1520 q=-1.0 Lsize=   58364kB time=00:03:20.00 bitrate=2390.6kbits/s speed=56.7x
video:45405kB audio:12387kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.989971%

Case 3 [ Take a look at streams inside Splited Media file ]

C:\Users\someone\Camtasia Studio )
=$ ffprobe.exe "Rec 12-30-16.trec.0.avi"
ffprobe version N-82759-g1f5630a Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --ena
ble-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-
libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enab
le-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-li
bopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspe
ex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzi
mg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 41.101 / 55. 41.101
  libavcodec     57. 66.109 / 57. 66.109
  libavformat    57. 58.101 / 57. 58.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, avi, from 'Rec 12-30-16.trec.0.avi':
  Metadata:
    encoder         : Lavf57.58.101
  Duration: 00:03:20.02, start: 0.000000, bitrate: 2390 kb/s
    Stream #0:0: Video: tscc2 (tsc2 / 0x32637374), yuv444p, 1364x768, 1860 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 253 kb/s
    Stream #0:2: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 253 kb/s

Result

  • Now I can use this splited media file in CamTasia Video Editor
  • ffmpeg is OpenSource and Free to use.
  • You can download ffmpeg for Windows from https://ffmpeg.zeranoe.com/builds/
  • -map 0 parameter force ffmpeg to select all streams inside media file
  • -codec copy parameter is used to copy selected streams from media file
  • -ss time parameter is used to specify, starting marker, its value can be either in seconds or hh:mm:ss.ssss format.
  • -t time parameter is used to specify, ending marked, its value type is same as -ss parameter value.

OK friends, If anything left unexplained, you can comment below in comment box, Thanks


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