head	1.19;
access;
symbols
	start:1.1.1.1 salsaman:1.1.1;
locks; strict;
comment	@# @;


1.19
date	2009.07.05.06.49.20;	author gfinch;	state Exp;
branches;
next	1.18;

1.18
date	2009.06.15.15.51.27;	author gfinch;	state Exp;
branches;
next	1.17;

1.17
date	2009.06.05.22.44.50;	author gfinch;	state Exp;
branches;
next	1.16;

1.16
date	2008.12.01.10.00.28;	author gfinch;	state Exp;
branches;
next	1.15;

1.15
date	2008.12.01.00.43.43;	author gfinch;	state Exp;
branches;
next	1.14;

1.14
date	2007.07.08.17.09.23;	author gfinch;	state Exp;
branches;
next	1.13;

1.13
date	2006.08.22.04.46.59;	author gfinch;	state Exp;
branches;
next	1.12;

1.12
date	2006.03.15.15.53.42;	author gfinch;	state Exp;
branches;
next	1.11;

1.11
date	2005.08.31.19.46.51;	author gfinch;	state Exp;
branches;
next	1.10;

1.10
date	2005.04.01.12.20.59;	author gfinch;	state Exp;
branches;
next	1.9;

1.9
date	2005.02.25.00.37.30;	author gfinch;	state Exp;
branches;
next	1.8;

1.8
date	2005.01.05.11.40.54;	author gfinch;	state Exp;
branches;
next	1.7;

1.7
date	2005.01.04.02.09.25;	author gfinch;	state Exp;
branches;
next	1.6;

1.6
date	2004.12.06.20.15.51;	author gfinch;	state Exp;
branches;
next	1.5;

1.5
date	2004.12.05.22.10.40;	author gfinch;	state Exp;
branches;
next	1.4;

1.4
date	2004.12.04.16.43.33;	author gfinch;	state Exp;
branches;
next	1.3;

1.3
date	2004.12.01.04.37.01;	author gfinch;	state Exp;
branches;
next	1.2;

1.2
date	2004.11.30.04.07.33;	author gfinch;	state Exp;
branches;
next	1.1;

1.1
date	2004.11.22.15.47.41;	author gfinch;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2004.11.22.15.47.41;	author gfinch;	state Exp;
branches;
next	;


desc
@@


1.19
log
@complete fix for non-C locale encoding
@
text
@#!/usr/bin/env python


import locale
locale.setlocale(locale.LC_NUMERIC,"")


"""
multi_encoder

LiVES plugin which uses the following encoding programs:

mpeg_encoder.py
ogm_encoder.py
mkv_encoder.py
avi_encoder.py
dirac_encoder.py
theora_encoder.py
mng_encoder.py
gif_encoder.py

See each *.py encoder for complete list of requirements
(you can type e.g. mpeg_encoder.py -C)

Copyright (C) 2004-2006 Marco De la Cruz (marco@@reimeika.ca)
It's a trivial program, but might as well GPL it, so see:
http://www.gnu.org/copyleft/gpl.html for license.

See my vids at http://amv.reimeika.ca !
"""

version = '0.2.11'
mpeg = 'mpeg_encoder.py'
ogm = 'ogm_encoder.py'
mkv = 'mkv_encoder.py'
ogg = 'theora_encoder.py'
avi = 'avi_encoder.py'
drc = 'dirac_encoder.py'
mng = 'mng_encoder.py'
gif = 'gif_encoder.py'

usage = \
      """
multi_encoder -h
multi_encoder [directive [args]]
      """

help = \
     """
SUMMARY (ver. %s):

LiVES plugin which calls one of the following programs:

mpeg_encoder.py
ogm_encoder.py
mkv_encoder.py
theora_encoder.py
avi_encoder.py
dirac_encoder.py
mng_encoder.py
gif_encoder.py

in order to generate movies in one of the following formats:

MPEG-1/MP2/MPG (various aspect ratios/frame rates)
DIVX 4:5/VORBIS/OGM (various aspect ratios/frame rates)
XVID/VORBIS/OGM (various aspect ratios/frame rates)
DIVX 4:5/VORBIS/MKV (various aspect ratios/frame rates)
H.264/VORBIS/MKV (various aspect ratios/frame rates)
XVID/VORBIS/MKV (various aspect ratios/frame rates)
THEORA/VORBIS/OGG (various aspect ratios/frame rates)
XVID/MP3/AVI (various aspect ratios/frame rates)
SNOW/MP3/AVI (various aspect ratios/frame rates)
H.264/MP3/AVI (various aspect ratios/frame rates)
DIRAC/---/DRC (various aspect ratios/frame rates, no sound)
VCD/SVCD/DVD (NTSC and PAL video)
MNG (no sound)
Animated GIF (no sound)

The *.py encoder programs are either part of your LiVES
ditribution and/or available from:

http://lives.reimeika.ca/lives_guide.html

OPTIONS:

-h          for help.

-v          be verbose.

-V          shows the version number.

directive   one of the following LiVES directives:

            version
            init
            get_capabilities
            get_formats
            finalise
            get_format_request
            encode
            clear

            See the LiVES documentation for details:
            http://www.xs4all.nl/~salsaman/lives/docs.html
     """ % version

# This is the directory where all temp files will be stored.
# It will reside within the LiVES temp directory (where the
# images and the audio files are located), so it's up to
# LiVES to make sure it always calls this plugin in the right
# location! I use this short name because mp2enc corrupts the
# filename if the length of the "/path/file.mp2" string is over
# 80 characters long. This should be fixed in a future version
# of MJPEGtools (> 1.6.2).
TEMPDIR = './metd'

def run(command):
    """
    Run a shell command
    """

    if verbose:
        print 'Running: \n' + command + '\n=== ... ==='
    os.system(command)


def which(command):
    """
    Finds (or not) a command a la "which"
    """

    command_found = False

    if command[0] == '/':
        if os.path.isfile(command) and \
               os.access(command, os.X_OK):
            command_found = True
            abs_command = command
    else:
        path = os.environ.get('PATH', '').split(os.pathsep)
        for dir in path:
            abs_command = os.path.join(dir, command)
            if os.path.isfile(abs_command) and \
               os.access(abs_command, os.X_OK):
                command_found = True
                break

    if not command_found:
        abs_command = ''

    return abs_command


def is_installed(prog):
    """
    See whether "prog" is installed with all dependencies
    """

    wprog = which(prog)

    if wprog == '':
        if verbose:
            print prog + ': command not found'
        found = 0
    else:
        if verbose:
            print wprog + ': found'
        found  = 1

    if found:
	if hassubproc:	
		p = subprocess.Popen([prog, '-C'],stdout=subprocess.PIPE)
		std_out_err=p.stdout

	else:
        	(std_in, std_out_err) = os.popen4(prog  + ' -C')
        	std_in.close()
	

        if 'command not found' in std_out_err.read():
            if verbose:
                print prog + ': missing dependencies'
            found = 0

    return found

def clear():
    """
    Clean up temp dirs and files.
    """

    if verbose: print 'Deleting ' + tempdir

    shutil.rmtree(tempdir, True)

    for link in glob.glob('./temporary_symlink*'):
        try:
            if verbose: print 'Deleting ' + link
            os.remove(link)
        except:
            if verbose: print 'Tried deleting ' + link
            pass
    for bmp in glob.glob('./TMPBMP*.bmp'):
        try:
            if verbose: print 'Deleting ' + bmp
            os.remove(link)
        except:
            if verbose: print 'Tried deleting ' + bmp
            pass
    if os.path.exists('./divx2pass.log'):
        os.remove('./divx2pass.log')
    if os.path.exists('./xvid-twopass.stats'):
        os.remove('./xvid-twopass.stats')
    if os.path.exists('./TMP_x264pass.log'):
        os.remove('./TMP_x264pass.log')
    if os.path.exists('./TMP_YUVstream.yuv'):
        os.remove('./TMP_YUVstream.yuv')

if __name__ == '__main__':

    import os
    import sys
    import getopt
    import shutil
    import glob

    hassubproc = False
    try:
    	import subprocess
    	hassubproc = True
    except ImportError:
    	pass

    tempdir = os.path.abspath(TEMPDIR)

    try:
        if sys.version_info[0:3] < (2, 3, 0):
            raise SystemExit
    except:
        print 'You need Python 2.3.0 or greater to run me!'
        raise SystemExit

    try:
        (opts, args) = getopt.getopt(sys.argv[1:], \
                                         'hvV')
    except:
        print "Something's wrong. Try the '-h' flag."
        raise SystemExit

    opts = dict(opts)

    if not opts and not args:
        print usage
        raise SystemExit

    if '-h' in opts:
        print usage + help
        raise SystemExit

    if '-V' in opts:
        print 'multi_encoder version ' + version
        raise SystemExit

    if '-v' in opts:
        verbose = True
    else:
        verbose = False

    if len(args) < 1:
        print 'You must specify a directive.'
        raise SystemExit

    dir = args[0]

    if dir not in ['version', 'init', \
                   'get_capabilities', 'get_formats', 'finalise', \
                   'get_format_request', 'encode', 'clear']:
        print 'Directive "' + dir + '" not recognized.'
        raise SystemExit
    elif verbose:
        print 'Directive "' + dir + '" chosen.'


    if dir == 'version':
        print version
        raise SystemExit

    if dir == 'init':
        installed = is_installed(mpeg) + is_installed(ogm) + \
                    is_installed(mkv) + is_installed(ogg) + \
                    is_installed(drc) + is_installed(gif) + \
                    is_installed(mng) + is_installed(avi)
        if installed < 1:
            print 'No encoders found!'
            raise SystemExit, 1
        print 'initialised'
        raise SystemExit

    if dir == 'get_capabilities':
       # Can encode png (4) + not pure perl (8)
       print '12'
       raise SystemExit

    if dir == 'get_formats':

       # define AUDIO_CODEC_MP3 0
       # define AUDIO_CODEC_PCM 1
       # define AUDIO_CODEC_MP2 2
       # define AUDIO_CODEC_VORBIS 3
       # define AUDIO_CODEC_AC3 4
       # define AUDIO_CODEC_MAX 31

       fps = 'fps=24000:1001;24;25;30000:1001;30;50;60000:1001;60'
       ntscfps = 'fps=30000:1001'
       palfps = 'fps=25'
       ar = 'aspect=1:1;4:3;16:9;2.21:1'
       hb = 'hblock=16'
       vb = 'vblock=16'
       sr = 'arate=32000;44100;48000'
       if is_installed(mpeg):
           specs = '|4|%s,%s,%s,%s,%s|mpg|' % (fps, ar, hb, vb, sr)
           print 'qlo-mpeg|Fast, very low Quality MPG (MPEG-1/MP2)' + specs
           print 'lo-mpeg|Low Quality MPG (MPEG-1/MP2)' + specs
           print 'ml-mpeg|Medium-Low Quality MPG (MPEG-1/MP2)' + specs
           print 'mh-mpeg|Medium-High Quality MPG (MPEG-1/MP2)'+ specs
           print 'hi-mpeg|High Quality MPG (MPEG-1/MP2)' + specs
           specs = '|4|%s,%s,%s,%s,%s|mpg|' % (ntscfps, ar, hb, vb, sr)
           print 'vcd-mpeg|VCD-compatible MPG (NTSC)' + specs
           print 'svcd-mpeg|SVCD-compatible MPG (NTSC)' + specs
           # For DVD the encoder will resample the sound rate to 48000
           print 'dvd-mpeg|DVD-compatible MPG (NTSC)' + specs
           specs = '|2|%s,%s,%s,%s,%s|mpg|' % (ntscfps, ar, hb, vb, sr)
           print 'sdvd-mpeg|Strictly DVD-compatible MPG (NTSC)' + specs
           specs = '|4|%s,%s,%s,%s,%s|mpg|' % (palfps, ar, hb, vb, sr)
           print 'pvcd-mpeg|VCD-compatible MPG (PAL)' + specs
           specs = '|2|%s,%s,%s,%s,%s|mpg|' % (palfps, ar, hb, vb, sr)
           print 'psvcd-mpeg|SVCD-compatible MPG (PAL)' + specs
           # For DVD the encoder will resample the sound rate to 48000
           print 'pdvd-mpeg|DVD-compatible MPG (PAL)' + specs
           print 'spdvd-mpeg|Strictly DVD-compatible MPG (PAL)' + specs
       sr = 'arate=8000;11025;12000;16000;22050;24000;32000;44100;48000'
       if is_installed(ogm):
           specs = '|8|%s,%s,%s,%s|ogm|' % (ar, hb, vb, sr)
           print 'lo_d-ogm|Low Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'ml_d-ogm|Medium-Low Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'mh_d-ogm|Medium-High Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'hi_d-ogm|High Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'lo_x-ogm|Low Quality OGM (XVID/VORBIS)' + specs
           print 'ml_x-ogm|Medium-Low Quality OGM (XVID/VORBIS)' + specs
           print 'mh_x-ogm|Medium-High Quality OGM (XVID/VORBIS)' + specs
           print 'hi_x-ogm|High Quality OGM (XVID/VORBIS)' + specs
       if is_installed(mkv):
           specs = '|8|%s,%s,%s,%s|mkv|' % (ar, hb, vb, sr)
           print 'lo_d-mkv|Low Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'ml_d-mkv|Medium-Low Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'mh_d-mkv|Medium-High Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'hi_d-mkv|High Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'lo_x-mkv|Low Quality MKV (XVID/VORBIS)' + specs
           print 'ml_x-mkv|Medium-Low Quality MKV (XVID/VORBIS)' + specs
           print 'mh_x-mkv|Medium-High Quality MKV (XVID/VORBIS)' + specs
           print 'hi_x-mkv|High Quality MKV (XVID/VORBIS)' + specs
           print 'lo_h-mkv|Low Quality MKV (H.264/VORBIS)' + specs
           print 'ml_h-mkv|Medium-Low Quality MKV (H.264/VORBIS)' + specs
           print 'mh_h-mkv|Medium-High Quality MKV (H.264/VORBIS)' + specs
           print 'hi_h-mkv|High Quality MKV (H.264/VORBIS)' + specs
       if is_installed(avi):
           specs = '|1|%s,%s,%s,%s|avi|' % (ar, hb, vb, sr)
           print 'lo_s-avi|EXP Low Quality AVI (SNOW/MP3)' + specs
           print 'ml_s-avi|EXP Medium-Low Quality AVI (SNOW/MP3)' + specs
           print 'mh_s-avi|EXP Medium-High Quality AVI (SNOW/MP3)' + specs
           print 'hi_s-avi|EXP High Quality AVI (SNOW/MP3)' + specs
           print 'lo_h-avi|EXP Low Quality AVI (H.264/MP3)' + specs
           print 'ml_h-avi|EXP Medium-Low Quality AVI (H.264/MP3)' + specs
           print 'mh_h-avi|EXP Medium-High Quality AVI (H.264/MP3)' + specs
           print 'hi_h-avi|EXP High Quality AVI (H.264/MP3)' + specs
           print 'lo_x-avi|Low Quality AVI (XVID/MP3)' + specs
           print 'ml_x-avi|Medium-Low Quality AVI (XVID/MP3)' + specs
           print 'mh_x-avi|Medium-High Quality AVI (XVID/MP3)' + specs
           print 'hi_x-avi|High Quality AVI (XVID/MP3)' + specs
       if is_installed(ogg):
           specs = '|8|%s,%s,%s,%s|ogg|' % (ar, hb, vb, sr)
           print 'lo-theora|Low Quality OGG (THEORA/VORBIS)' + specs
           print 'ml-theora|Medium-Low Quality OGG (THEORA/VORBIS)' + specs
           print 'mh-theora|Medium-High Quality OGG (THEORA/VORBIS)' + specs
           print 'hi-theora|High Quality OGG (THEORA/VORBIS)' + specs
       # EXPERIMENTAL. Also, drc doesn't support sound yet (needs wrapper).
       if is_installed(drc):
           specs = '|0|%s,%s,%s,%s|drc|' % (ar, hb, vb, sr)
           print 'lo-dirac|EXP Low Quality DRC (DIRAC/NONE)' + specs
           print 'ml-dirac|EXP Medium-Low Quality DRC (DIRAC/NONE)' + specs
           print 'mh-dirac|EXP Medium-High Quality DRC (DIRAC/NONE)' + specs
           print 'hi-dirac|EXP High Quality DRC (DIRAC/NONE)' + specs
       if is_installed(mng):
           specs = '|0|none|mng|'
           print 'hi-mng|MNG (MNG/NONE) format' + specs
       if is_installed(gif):
           specs = '|0|none|gif|'
           print 'hi-gif|Animated GIF (GIF/NONE) format' + specs
       raise SystemExit

    if dir == 'get_format_request':
       # wav (1) + clipped audio (2) + selected frames (4)
       print '7'
       raise SystemExit

    if dir == 'encode':

        fps = args[1]
        outfile = args[2]
        outfile = '"' + outfile + '"'
        start = args[3]
        end = args[4]
        ext = args[5]
        vformat = args[6]
        aformat = args[7]
        hsize = args[8]
        vsize = args[9]
        debug = args[10]

        if debug == '1':
            verbose = True
        
        fpst = 0.0005
        if abs(24000.0/1001.0 - locale.atof(fps)) < fpst: fpsc = '1'
        elif abs(24 - locale.atof(fps)) < fpst: fpsc = '2'
        elif abs(25 - locale.atof(fps)) < fpst: fpsc = '3'
        elif abs(30000.0/1001.0 - locale.atof(fps)) < fpst: fpsc = '4'
        elif abs(30 - locale.atof(fps)) < fpst: fpsc = '5'
        elif abs(50 - locale.atof(fps)) < fpst: fpsc = '6'
        elif abs(60000.0/1001.0 - locale.atof(fps)) < fpst: fpsc = '7'
        elif abs(60 - locale.atof(fps)) < fpst: fpsc = '8'
        else: fpsc = fps

        aspect = locale.atof(hsize)/locale.atof(vsize)
        if 0 <= aspect <= 1.16:
            # 1:1 = 1
            arc = '1'
        elif 1.16 < aspect <= 1.55:
            # 4:3 ~ 1.33
            arc = '2'
        elif 1.55 < aspect <= 1.99:
            # 16:9 ~ 1.77
            arc = '3'
        elif 1.99 < aspect:
            # 2.21:1
            arc = '4'
        else:
            print 'Unable to determine the aspect ratio, got: %s' % aspect
            raise SystemExit

        (type, prog) = vformat.split('-')

        if verbose:
            quiet = '-v'
            tonull = ''
        else:
            quiet = '-q'
            tonull = '2> /dev/null'

        encode_command = ' '.join([prog + '_encoder.py', '-o', \
                                   outfile, '-w', tempdir, '-a', arc, \
                                   '-f', fpsc, quiet, '-t', \
                                   type, '-s ./audiodump.wav', \
                                   start, end, tonull])

        message = """
        I got the following arguments:

        multi_encoder version = %s
        fps = %s
        outfile = %s
        start = %s
        end = %s
        ext = %s
        vformat = %s
        aformat = %s
        hsize = %s
        vsize = %s

        I will use the following:

        fpsc = %s
        aspect = %s
        arc = %s
        type = %s
        prog = %s
        tempdir = %s

        I will run the following command:
        %s

        """ % (version, fps, outfile, start, end, ext, vformat, aformat, hsize, vsize, \
               fpsc, aspect, arc, type, prog, tempdir, encode_command)

        if verbose:
            print message

        # Uncomment to debug
        # output = open('/tmp/multi_encoder_debug.log', 'w')
        # output.write(message)
        # output.close()
        
        os.system(encode_command)
        clear()
        raise SystemExit

    if dir == 'clear':
        clear()
        raise SystemExit

    if dir == 'finalise':
        print 'finalised'
        raise SystemExit

"""
CHANGELOG:

21 Jul 2004 : 0.0.3 : added more directives.
                      redefined on fps values.
                      added this changelog :).
28 Jul 2004 : 0.0.4 : implemented 'encode' and 'clear' directives.
29 Jul 2004 : 0.0.5 : remove 'divx2pass.log' if present.
                      dies quietly now when cancelled from LiVES.
02 Aug 2004 : 0.0.6 : added default extension to 'get_formats'.
                      changed 'format' to 'vformat' for clarity.
                      added support for 'debug' argument.
27 Sep 2004 : 0.0.7 : added 'theora_encoder' and 'dirac_encoder'
                      (the latter HIGHLY EXPERIMENTAL).
                      no longer needs all encoders to work, it
                      will look for and offer the available
                      formats.
04 Oct 2004 : 0.0.8 : uses the frame dimensions to guess aspect
                      ratio.
13 Oct 2004 : 0.0.9 : fix naming of Ogg Theora (j@@v2v.cc).
                      Ogg Theora file extension is now .ogg.
                      made vblock=16 (may need to be tweaked).
26 Oct 2004 : 0.1.0 : can use arbitrary frame rate for Ogg Theora.
28 Oct 2004 : 0.1.1 : added support for mng_encoder.py.
                      can use arbitrary frame rate for ogm/mkv/dirac.
28 Oct 2004 : 0.1.2 : added PAL support.
29 Oct 2004 : 0.1.3 : added support for gif_encoder.py.
02 Nov 2004 : 0.1.4 : added xvid.
                      made descriptions clearer.
08 Nov 2004 : 0.1.5 : rm xvid-twopass.stats if present.
                      check if gif/mng encoders are installed.
21 Nov 2004 : 0.1.6 : check encoder dependencies.
26 Nov 2004 : 0.1.7 : set audio code to '0' and sr to 'none'
                      if the format does not support sound
                      (needs LiVES 0.9.1 or greater).
29 Nov 2004 : 0.1.8 : set the right encoding flags to drc/gif/mng.
                      GIF -> Animated GIF for clarity.
02 Dec 2004 : 0.1.9 : eliminated "anyfps = 'none'", I don't think
                      it's needed.
                      fps now checked to 8 decimal places.
                      eliminated some redundancy in the docs.
05 Dec 2004 : 0.2.0 : remove unnecessary audio sampling restrictions.
                      fps difference threshold can be controlled
                      through "fpst" variable.
06 Dec 2004 : 0.2.1 : set fpst to 0.0005.
03 Jan 2005 : 0.2.2 : added avi_encoder.py.
04 Jan 2005 : 0.2.3 : added h.264 options.
24 Feb 2005 : 0.2.4 : expanded allowed audio sample rates.
21 Mar 2005 : 0.2.5 : use env python (hopefully >= 2.3)
26 Mar 2005 : 0.2.6 : added support for qlo-mpeg.
28 Jun 2005 : 0.2.7 : added CHANGELOG entry for 0.2.6.
                      added support for sdvd-mpeg and spdvd-mpeg.
13 Mar 2006 : 0.2.8 : added h.264/vorbis/mkv.
                      fixed URL.
02 Jul 2007 : 0.2.9 : make sure that file names have quotes around them.


Nov 2008 : 0.2.10 : salsaman - add locale support (fixes radix problem)

Jun 2009 : 0.2.11 : salsaman - replace deprecated os.popen

"""
@


1.18
log
@updates
@
text
@d425 8
a432 8
        if abs(24000.0/1001.0 - float(fps)) < fpst: fpsc = '1'
        elif abs(24 - float(fps)) < fpst: fpsc = '2'
        elif abs(25 - float(fps)) < fpst: fpsc = '3'
        elif abs(30000.0/1001.0 - float(fps)) < fpst: fpsc = '4'
        elif abs(30 - float(fps)) < fpst: fpsc = '5'
        elif abs(50 - float(fps)) < fpst: fpsc = '6'
        elif abs(60000.0/1001.0 - float(fps)) < fpst: fpsc = '7'
        elif abs(60 - float(fps)) < fpst: fpsc = '8'
d435 1
a435 1
        aspect = float(hsize)/float(vsize)
@


1.17
log
@splashscreen pt 1
@
text
@d172 7
a178 2
#        (std_in, std_out_err) = os.popen4(prog  + ' -C')
#        std_in.close()
a179 5
	p = subprocess.Popen([prog, '-C'],stdout=subprocess.PIPE)
	std_out_err=p.stdout
	std_in=p.stdin

#	std_in.close()
d227 8
a234 2
    import subprocess
	
@


1.16
log
@exp. locale fix
@
text
@d32 1
a32 1
version = '0.2.10'
d172 9
a180 2
        (std_in, std_out_err) = os.popen4(prog  + ' -C')
        std_in.close()
d227 2
a228 1

d565 6
@


1.15
log
@auto-deinterlace, other updates
@
text
@d5 1
a5 1
locale.setlocale(locale.LC_ALL,"C")
@


1.14
log
@updates
@
text
@d3 5
d32 1
a32 1
version = '0.2.9'
@


1.13
log
@fix mono mpeg encoding
@
text
@d392 1
a400 1
        achans = args[12]
d442 1
a442 6
        if prog == 'mpeg' and achans == '1':
            mono = '-m'
        else:
            mono = ''
            
        encode_command = ' '.join([prog + '_encoder.py', mono, '-o', \
d451 1
a460 1
        achans = %s
d474 1
a474 1
        """ % (fps, outfile, start, end, ext, vformat, aformat, hsize, vsize, achans,\
d551 1
a551 1
22 Aug 2006 : 0.2.9 : Add support for mono mpeg encoding (salsaman)
@


1.12
log
@multi_encoder updates
@
text
@d27 1
a27 1
version = '0.2.8'
d400 1
d442 6
a447 1
        encode_command = ' '.join([prog + '_encoder.py', '-o', \
d465 1
d479 1
a479 1
        """ % (fps, outfile, start, end, ext, vformat, aformat, hsize, vsize, \
d556 1
@


1.11
log
@multi encoder/subencoder updates
@
text
@d20 1
a20 1
Copyright (C) 2004 Marco De la Cruz (marco@@reimeika.ca)
d27 1
a27 1
version = '0.2.7'
d64 1
d78 1
a78 1
http://www.reimeika.ca/amv/lives/lives_guide.html
d203 4
a206 1

d344 4
d547 2
@


1.10
log
@add noisify effect; update multi_encoder
@
text
@d27 1
a27 1
version = '0.2.6'
d283 8
a290 2
       # Vorbis = 8 (bit 3), MP2 = 4 (bit 2), MP3 = 1 (bit 0)
       # EXP means "experimental"!
d310 2
d314 1
d318 1
d536 3
@


1.9
log
@allow more audio rates in the multi_encoder (thanks Marco)
@
text
@d1 1
a1 1
#!/usr/bin/python2.3
d27 1
a27 1
version = '0.2.4'
d294 1
d525 1
@


1.8
log
@add h264 support
@
text
@d27 1
a27 1
version = '0.2.3'
d291 1
a291 1
       sr = 'arate=44100'
d308 1
d310 1
a310 1
           specs = '|8|%s,%s,%s|ogm|' % (ar, hb, vb)
d320 1
a320 1
           specs = '|8|%s,%s,%s|mkv|' % (ar, hb, vb)
d330 1
a330 1
           specs = '|1|%s,%s,%s|avi|' % (ar, hb, vb)
d344 1
a344 1
           specs = '|8|%s,%s,%s|ogg|' % (ar, hb, vb)
d351 1
a351 1
           specs = '|0|%s,%s,%s|drc|' % (ar, hb, vb)
d523 1
@


1.7
log
@encoder updates (thanks marco)
@
text
@d11 1
d15 1
a15 9

in order to generate movies in the following formats:

MPEG-1/MP2/MPG (various aspect ratios/frame rates)
MPEG-4/OGG/OGM (various aspect ratios/frame rates)
MPEG-4/OGG/MKV (various aspect ratios/frame rates)
Ogg Theora (various aspect ratios/frame rates)
DIRAC/---/DRC (various aspect ratios/frame rates, no sound)
VCD/SVCD/DVD (NTSC video)
a19 5
You can download the *.py encoders (and detailed instructions
on how they work) from:

http://www.reimeika.ca/amv/lives/lives_guide.html

d27 1
a27 1
version = '0.1.2'
d32 1
d35 1
d53 1
d56 1
d61 8
a68 3
MPEG-4/OGG/OGM (various aspect ratios/frame rates)
MPEG-4/OGG/MKV (various aspect ratios/frame rates)
Ogg Theora     (various aspect ratios/frame rates)
d70 3
a72 2
MNG/---/MNG (various frame rates, no sound)
VCD/SVCD/DVD (NTSC video)
d107 1
a107 1
# filename is the length of the "/path/file.mp2" string is over
d151 1
a151 1
    See whether "prog" is installed
d165 8
d200 2
d269 2
a270 1
                    is_installed(drc)
d283 5
a287 5
       # Vorbis = 8 (bit 3), MP2 = 4 (bit 2)
       fps = 'fps=23.976;24.000;25.000;29.970;30.000;50.000;59.940;60.000'
       ntscfps = 'fps=29.970'
       palfps = 'fps=25.0'
       anyfps = 'none'
d294 4
a297 4
           print 'lo_mpeg|Low Quality MPEG-1/MP2/MPG' + specs
           print 'ml_mpeg|Medium-Low Quality MPEG-1/MP2/MPG' + specs
           print 'mh_mpeg|Medium-High Quality MPEG-1/MP2/MPG'+ specs
           print 'hi_mpeg|High Quality MPEG-1/MP2/MPG' + specs
d299 2
a300 2
           print 'vcd_mpeg|VCD-compatible MPEG (NTSC)' + specs
           print 'svcd_mpeg|SVCD-compatible MPEG (NTSC)' + specs
d302 1
a302 1
           print 'dvd_mpeg|DVD-compatible MPEG (NTSC)' + specs
d304 2
a305 2
           print 'pvcd_mpeg|VCD-compatible MPEG (PAL)' + specs
           print 'psvcd_mpeg|SVCD-compatible MPEG (PAL)' + specs
d307 1
a307 1
           print 'pdvd_mpeg|DVD-compatible MPEG (PAL)' + specs
d309 9
a317 5
           specs = '|8|%s,%s,%s,%s,%s|ogm|' % (anyfps, ar, hb, vb, sr)
           print 'lo_ogm|Low Quality MPEG-4/OGG/OGM' + specs
           print 'ml_ogm|Medium-Low Quality MPEG-4/OGG/OGM' + specs
           print 'mh_ogm|Medium-High Quality MPEG-4/OGG/OGM' + specs
           print 'hi_ogm|High Quality MPEG-4/OGG/OGM' + specs
d319 23
a341 5
           specs = '|8|%s,%s,%s,%s,%s|mkv|' % (anyfps, ar, hb, vb, sr)
           print 'lo_mkv|Low Quality MPEG-4/OGG/MKV' + specs
           print 'ml_mkv|Medium-Low Quality MPEG-4/OGG/MKV' + specs
           print 'mh_mkv|Medium-High Quality MPEG-4/OGG/MKV' + specs
           print 'hi_mkv|High Quality MPEG-4/OGG/MKV' + specs
d343 12
a354 7
           specs = '|8|%s,%s,%s,%s,%s|ogg|' % (anyfps, ar, hb, vb, sr)
           print 'lo_theora|Low Quality Ogg Theora/OGG' + specs
           print 'ml_theora|Medium-Low Quality Ogg Theora/OGG' + specs
           print 'mh_theora|Medium-High Quality Ogg Theora/OGG' + specs
           print 'hi_theora|High Quality Ogg Theora/OGG' + specs
       # TODO: set audio code to '0' and sr to 'none' when LiVES is
       # fixed
d356 5
a360 8
           specs = '|8|%s,%s,%s,%s,%s|mng|' % (anyfps, ar, hb, vb, sr)
           print 'hi_mng|MNG format' + specs
       if is_installed(drc):
           specs = '|8|%s,%s,%s,%s,%s|drc|' % (anyfps, ar, hb, vb, sr)
           print 'lo_dirac|EXP Low Quality DIRAC/DRC' + specs
           print 'ml_dirac|EXP Medium-Low Quality DIRAC/DRC' + specs
           print 'mh_dirac|EXP Medium-High Quality DIRAC/DRC' + specs
           print 'hi_dirac|EXP High Quality DIRAC/DRC' + specs
d381 1
a381 1
	if debug == '1':
d384 9
a392 8
        if fps == '23.976': fpsc = '1'
        elif fps == '24.000': fpsc = '2'
        elif fps == '25.000': fpsc = '3'
        elif fps == '29.970': fpsc = '4'
        elif fps == '30.000': fpsc = '5'
        elif fps == '50.000': fpsc = '6'
        elif fps == '59.940': fpsc = '7'
        elif fps == '60.000': fpsc = '8'
d412 1
a412 1
        (type, prog) = vformat.split('_')
d415 1
a415 1
            quiet = ''
d495 1
a495 1
		      Ogg Theora file extension is now .ogg.
d501 21
@


1.6
log
@new encoders (thanks Marco )
@
text
@d14 9
a22 1
gif_encoder.py
d27 5
d39 1
a39 1
version = '0.2.1'
a45 1
gif = 'gif_encoder.py'
a64 1
gif_encoder.py
d69 3
a71 5
DIVX 4:5/OGG/OGM (various aspect ratios/frame rates)
XVID/OGG/OGM (various aspect ratios/frame rates)
DIVX 4:5/OGG/MKV (various aspect ratios/frame rates)
XVID/OGG/MKV (various aspect ratios/frame rates)
THEORA/VORBIS/OGG (various aspect ratios/frame rates)
d73 2
a74 3
VCD/SVCD/DVD (NTSC and PAL video)
MNG (no sound)
Animated GIF (no sound)
d109 1
a109 1
# filename if the length of the "/path/file.mp2" string is over
d153 1
a153 1
    See whether "prog" is installed with all dependencies
a166 8
    if found:
        (std_in, std_out_err) = os.popen4(prog  + ' -C')
        std_in.close()
        if 'command not found' in std_out_err.read():
            if verbose:
                print prog + ': missing dependencies'
            found = 0

a193 2
    if os.path.exists('./xvid-twopass.stats'):
        os.remove('./xvid-twopass.stats')
d261 1
a261 2
                    is_installed(drc) + is_installed(gif) + \
                    is_installed(mng)
d275 4
a278 3
       fps = 'fps=24000:1001;24;25;30000:1001;30;50;60000:1001;60'
       ntscfps = 'fps=30000:1001'
       palfps = 'fps=25'
d285 4
a288 4
           print 'lo-mpeg|Low Quality MPG (MPEG-1/MP2)' + specs
           print 'ml-mpeg|Medium-Low Quality MPG (MPEG-1/MP2)' + specs
           print 'mh-mpeg|Medium-High Quality MPG (MPEG-1/MP2)'+ specs
           print 'hi-mpeg|High Quality MPG (MPEG-1/MP2)' + specs
d290 2
a291 2
           print 'vcd-mpeg|VCD-compatible MPG (NTSC)' + specs
           print 'svcd-mpeg|SVCD-compatible MPG (NTSC)' + specs
d293 1
a293 1
           print 'dvd-mpeg|DVD-compatible MPG (NTSC)' + specs
d295 2
a296 2
           print 'pvcd-mpeg|VCD-compatible MPG (PAL)' + specs
           print 'psvcd-mpeg|SVCD-compatible MPG (PAL)' + specs
d298 1
a298 1
           print 'pdvd-mpeg|DVD-compatible MPG (PAL)' + specs
d300 5
a304 9
           specs = '|8|%s,%s,%s|ogm|' % (ar, hb, vb)
           print 'lo_d-ogm|Low Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'ml_d-ogm|Medium-Low Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'mh_d-ogm|Medium-High Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'hi_d-ogm|High Quality OGM (DIVX 4:5/VORBIS)' + specs
           print 'lo_x-ogm|Low Quality OGM (XVID/VORBIS)' + specs
           print 'ml_x-ogm|Medium-Low Quality OGM (XVID/VORBIS)' + specs
           print 'mh_x-ogm|Medium-High Quality OGM (XVID/VORBIS)' + specs
           print 'hi_x-ogm|High Quality OGM (XVID/VORBIS)' + specs
d306 5
a310 9
           specs = '|8|%s,%s,%s|mkv|' % (ar, hb, vb)
           print 'lo_d-mkv|Low Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'ml_d-mkv|Medium-Low Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'mh_d-mkv|Medium-High Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'hi_d-mkv|High Quality MKV (DIVX 4:5/VORBIS)' + specs
           print 'lo_x-mkv|Low Quality MKV (XVID/VORBIS)' + specs
           print 'ml_x-mkv|Medium-Low Quality MKV (XVID/VORBIS)' + specs
           print 'mh_x-mkv|Medium-High Quality MKV (XVID/VORBIS)' + specs
           print 'hi_x-mkv|High Quality MKV (XVID/VORBIS)' + specs
d312 10
a321 6
           specs = '|8|%s,%s,%s|ogg|' % (ar, hb, vb)
           print 'lo-theora|Low Quality OGG (THEORA/VORBIS)' + specs
           print 'ml-theora|Medium-Low Quality OGG (THEORA/VORBIS)' + specs
           print 'mh-theora|Medium-High Quality OGG (THEORA/VORBIS)' + specs
           print 'hi-theora|High Quality OGG (THEORA/VORBIS)' + specs
       # EXPERIMENTAL. Also, drc doesn't support sound yet (needs wrapper).
d323 5
a327 11
           specs = '|0|%s,%s,%s|drc|' % (ar, hb, vb)
           print 'lo-dirac|EXP Low Quality DRC (DIRAC/NONE)' + specs
           print 'ml-dirac|EXP Medium-Low Quality DRC (DIRAC/NONE)' + specs
           print 'mh-dirac|EXP Medium-High Quality DRC (DIRAC/NONE)' + specs
           print 'hi-dirac|EXP High Quality DRC (DIRAC/NONE)' + specs
       if is_installed(mng):
           specs = '|0|none|mng|'
           print 'hi-mng|MNG (MNG/NONE) format' + specs
       if is_installed(gif):
           specs = '|0|none|gif|'
           print 'hi-gif|Animated GIF (GIF/NONE) format' + specs
d348 1
a348 1
        if debug == '1':
d351 8
a358 9
        fpst = 0.0005
        if abs(24000.0/1001.0 - float(fps)) < fpst: fpsc = '1'
        elif abs(24 - float(fps)) < fpst: fpsc = '2'
        elif abs(25 - float(fps)) < fpst: fpsc = '3'
        elif abs(30000.0/1001.0 - float(fps)) < fpst: fpsc = '4'
        elif abs(30 - float(fps)) < fpst: fpsc = '5'
        elif abs(50 - float(fps)) < fpst: fpsc = '6'
        elif abs(60000.0/1001.0 - float(fps)) < fpst: fpsc = '7'
        elif abs(60 - float(fps)) < fpst: fpsc = '8'
d378 1
a378 1
        (type, prog) = vformat.split('-')
d381 1
a381 1
            quiet = '-v'
d461 1
a461 1
                      Ogg Theora file extension is now .ogg.
a466 19
29 Oct 2004 : 0.1.3 : added support for gif_encoder.py.
02 Nov 2004 : 0.1.4 : added xvid.
                      made descriptions clearer.
08 Nov 2004 : 0.1.5 : rm xvid-twopass.stats if present.
                      check if gif/mng encoders are installed.
21 Nov 2004 : 0.1.6 : check encoder dependencies.
26 Nov 2004 : 0.1.7 : set audio code to '0' and sr to 'none'
                      if the format does not support sound
                      (needs LiVES 0.9.1 or greater).
29 Nov 2004 : 0.1.8 : set the right encoding flags to drc/gif/mng.
                      GIF -> Animated GIF for clarity.
02 Dec 2004 : 0.1.9 : eliminated "anyfps = 'none'", I don't think
                      it's needed.
                      fps now checked to 8 decimal places.
                      eliminated some redundancy in the docs.
05 Dec 2004 : 0.2.0 : remove unnecessary audio sampling restrictions.
                      fps difference threshold can be controlled
                      through "fpst" variable.
06 Dec 2004 : 0.2.1 : set fpst to 0.0005.
@


1.5
log
@new multi_encoder
@
text
@d26 1
a26 1
version = '0.2.0'
d363 1
a363 2
        fpst = 0.00000001
#       fpst = 0.001
d498 1
@


1.4
log
@fps accuracy fixes
@
text
@d26 1
a26 1
version = '0.1.9'
d302 1
a302 1
           specs = '|8|%s,%s,%s,%s|ogm|' % (ar, hb, vb, sr)
d312 1
a312 1
           specs = '|8|%s,%s,%s,%s|mkv|' % (ar, hb, vb, sr)
d322 1
a322 1
           specs = '|8|%s,%s,%s,%s|ogg|' % (ar, hb, vb, sr)
d360 1
a360 1
	if debug == '1':
d363 10
a372 8
	if abs(24000.0/1001.0 - float(fps)) < .00000001: fpsc = '1'
        elif abs(24 - float(fps)) < .00000001: fpsc = '2'
        elif abs(25 - float(fps)) < .00000001: fpsc = '3'
        elif abs(30000.0/1001.0 - float(fps)) < .00000001: fpsc = '4'
        elif abs(30 - float(fps)) < .00000001: fpsc = '5'
        elif abs(50 - float(fps)) < .00000001: fpsc = '6'
        elif abs(60000.0/1001.0 - float(fps)) < .00000001: fpsc = '7'
        elif abs(60 - float(fps)) < .00000001: fpsc = '8'
d475 1
a475 1
		      Ogg Theora file extension is now .ogg.
d496 3
@


1.3
log
@new multi_encoder
@
text
@a15 13
in order to generate movies in the following formats:

MPEG-1/MP2/MPG (various aspect ratios/frame rates)
DIVX 4:5/OGG/OGM (various aspect ratios/frame rates)
XVID/OGG/OGM (various aspect ratios/frame rates)
DIVX 4:5/OGG/MKV (various aspect ratios/frame rates)
XVID/OGG/MKV (various aspect ratios/frame rates)
THEORA/VORBIS/OGG (various aspect ratios/frame rates)
DIRAC/---/DRC (various aspect ratios/frame rates, no sound)
VCD/SVCD/DVD (NTSC and PAL video)
MNG (no sound)
Animated GIF (no sound)

a18 5
You can download the *.py encoders (and detailed instructions
on how they work) from:

http://www.reimeika.ca/amv/lives/lives_guide.html

d26 1
a26 1
version = '0.1.8'
d278 3
a280 4
       fps = 'fps=23.976;24.000;25.000;29.970;30.000;50.000;59.940;60.000'
       ntscfps = 'fps=29.970'
       palfps = 'fps=25.0'
       anyfps = 'none'
d302 1
a302 1
           specs = '|8|%s,%s,%s,%s,%s|ogm|' % (anyfps, ar, hb, vb, sr)
d312 1
a312 1
           specs = '|8|%s,%s,%s,%s,%s|mkv|' % (anyfps, ar, hb, vb, sr)
d322 1
a322 1
           specs = '|8|%s,%s,%s,%s,%s|ogg|' % (anyfps, ar, hb, vb, sr)
d329 1
a329 1
           specs = '|0|%s,%s,%s,%s|drc|' % (anyfps, ar, hb, vb)
d363 8
a370 8
        if fps == '23.976': fpsc = '1'
        elif fps == '24.000': fpsc = '2'
        elif fps == '25.000': fpsc = '3'
        elif fps == '29.970': fpsc = '4'
        elif fps == '30.000': fpsc = '5'
        elif fps == '50.000': fpsc = '6'
        elif fps == '59.940': fpsc = '7'
        elif fps == '60.000': fpsc = '8'
d490 4
@


1.2
log
@update multi_encoder
@
text
@d44 1
a44 1
version = '0.1.5'
d119 1
a119 1
# filename is the length of the "/path/file.mp2" string is over
d163 1
a163 1
    See whether "prog" is installed
d177 8
d346 1
a346 8
       # TODO: set audio code to '0' and sr to 'none' when LiVES is
       # fixed
       if is_installed(mng):
           specs = '|0|%s,%s,%s,%s,%s|mng|' % (anyfps, ar, hb, vb, sr)
           print 'hi-mng|MNG (MNG/NONE) format' + specs
       if is_installed(gif):
           specs = '|0|%s,%s,%s,%s,%s|gif|' % (anyfps, ar, hb, vb, sr)
           print 'hi-gif|GIF (GIF/NONE) format' + specs
d348 1
a348 1
           specs = '|0|%s,%s,%s,%s,%s|drc|' % (anyfps, ar, hb, vb, sr)
d353 6
d503 6
@


1.1
log
@Initial revision
@
text
@d341 1
a341 1
           specs = '|8|%s,%s,%s,%s,%s|mng|' % (anyfps, ar, hb, vb, sr)
d344 1
a344 1
           specs = '|8|%s,%s,%s,%s,%s|gif|' % (anyfps, ar, hb, vb, sr)
d347 1
a347 1
           specs = '|8|%s,%s,%s,%s,%s|drc|' % (anyfps, ar, hb, vb, sr)
@


1.1.1.1
log
@initial
@
text
@@
