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


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

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

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

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

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

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

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

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

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

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

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


desc
@@


1.10
log
@resample virtual files, code cleanup
@
text
@#!/usr/bin/perl

# (c) G. Finch (salsaman)

# released under the GNU GPL 3 or later
# see file COPYING or www.gnu.org for details





#######################################################################
# LiVES encodedv plugin v2.1

# version 1.0 original - salsaman
# version 2.0 fix it so it works again ! - salsaman.
# version 2.1 increase quality settings, restrict audio rates.
# version 2.11 add package name libdv-bin

#######################################################################

if (!defined($standalone)) {
    my $smogrify=`which smogrify`;
    chomp($smogrify);
    require $smogrify;
}
else {
    $command=$ARGV[0];
}


#######################################################################


if ($command eq "version") {
    print "encodedv encoder plugin v2.11\n";
    exit 0;
}


if ($command eq "init") {
    # perform any initialisation needed
    # On error, print error message and exit 1
    # otherwise exit 0

    if (&location("encodedv") eq "") {
	print "Encodedv was not found. Please install libdv2-apps or libdv-bin and try again.";
	exit 1;
    }
    
    # end init code
    print "initialised\n";
    exit 0;
}



if ($command eq "get_capabilities") {
    # return capabilities - this is a bitmap field
    # bit 0 - takes extra parameters (using RFX request)
    # bit 1 - unused
    # bit 2 - can encode png
    # bit 3 - not pure perl
    print "0\n";
    exit 0;
}



if ($command eq "get_formats") {
   # for each format: -
   # return format_name|display_name|audio_types|restrictions|extension|

   # audio types are: 0 - cannot encode audio, 1 - can encode using
    #  mp3, 2 - can encode using pcm, 3 - can encode using pcm and mp3
    
    print "dv_ntsc_med|dv (NTSC) medium quality|2|size=720x480,fps=30000:1001,arate=48000;44100|dv|\n"; # NTSC
    print "dv_pal_med|dv (PAL) medium quality|2|size=720x576,fps=25.000,arate=48000;44100|dv|\n"; # PAL
    print "dv_ntsc_medhi|dv (NTSC) medium/high quality|2|size=720x480,fps=30000:1001,arate=48000;44100|dv|\n"; # NTSC
    print "dv_pal_medhi|dv (PAL) medium/high quality|2|size=720x576,fps=25.000,arate=48000;44100|dv|\n"; # PAL
    print "dv_ntsc_hi|dv (NTSC) high quality|2|size=720x480,fps=30000:1001,arate=48000;44100|dv|\n"; # NTSC
    print "dv_pal_hi|dv (PAL) high quality|2|size=720x576,fps=25.000,arate=48000;44100|dv|\n"; # PAL

    exit 0;
}



if ($command eq "encode") {
    # encode 
    $encoder_command="encodedv";

    chdir $curtmpdir;

    $to_ext=".ppm";

    $passes=1;

    if ($otype eq "dv_ntsc_medhi"||$otype eq "dv_pal_medhi") {
	$passes=2;
    }
    elsif ($otype eq "dv_ntsc_hi"||$otype eq "dv_pal_hi") {
	$passes=3;
    }


    for ($i=$start;$i<=$end;$i++) {
	$name=&mkname($i);
	$name2=&mkname($i-1);
	`$convert_command $name$img_ext $name2$to_ext`;
    }

    if (-f $audiofile) {
	$syscom="$encoder_command -s 0 -e ".($end-$start)." -p $passes %08d$to_ext -a wav $audiofile > \"$nfile\"";
    }
    else {
	$syscom=$encoder_command . " -s 0 -e ".($end-$start)." -p $passes %08d$to_ext > \"$nfile\"";
    }

    if (defined($DEBUG_ENCODERS)) {
	print STDERR "Debug: Encodedv command is $syscom\n";
    }

    system($syscom);

    # required
    &sig_complete;
    exit 0;
}


if ($command eq "clear") {
    # this is called after "encode"
    # note that encoding could have been stopped at any time

    $to_ext=".ppm";

    for ($i=$start;$i<=$end;$i++) {
	$name=&mkname($i-1);
	if (-f "$name$to_ext") {
	    unlink "$name$to_ext";
	}
    }
    &sig_complete;
    exit 0;
}


if ($command eq "finalise") {
    # do any finalising code

    # ...

    # end finalising code
    print "finalised\n";
    exit 0;
}


###### subroutines #######




sub get_format_request {
    # return the code for how we would like audio and video delivered
    # this is a bitmap field composed of:
    # bit 0 - unset=raw pcm audio; set=pcm audio with wav header
    # bit 1 - unset=all audio; set=clipped audio
    # bit 2 - unset=all frames; set=frames for selection only

    return 7; # clipped wav, clipped frames
}

@


1.9
log
@advanced encoders pt 1
@
text
@d18 1
d36 1
a36 1
    print "encodedv encoder plugin v2.1\n";
d47 1
a47 1
	print "Encodedv was not found. Please install libdv2-apps and try again.";
@


1.8
log
@update to gpl 3; other fixes
@
text
@d59 4
a62 2
    # 1 = can encode with frame changes (with an event.frames file)
    # 2 = can encode with fps changes (with an event.fps file)
@


1.7
log
@make sure all files have license/copyright
@
text
@d5 1
a5 1
# relesed under the GNU GPL 2
@


1.6
log
@updated encodedv_encoder
@
text
@d3 9
@


1.5
log
@new version, fix change description
@
text
@d97 2
a98 1
	`$convert_command $name$img_ext $name$to_ext`;
d102 1
a102 1
	$syscom=$encoder_command . " -s $start -e $end -p $passes %08d$to_ext -a wav $audiofile > \"$nfile\"";
d105 1
a105 1
	$syscom=$encoder_command . " -s $start -e $end -p $passes %08d$to_ext > \"$nfile\"";
d127 1
a127 1
	$name=&mkname($i);
@


1.4
log
@fix silliness in smogrify
@
text
@a5 1

@


1.3
log
@fix encodedv encoder
@
text
@d4 1
a4 1
# LiVES encodedv plugin v2.0
d9 1
d27 1
a27 1
    print "encodedv encoder plugin v2.0\n";
d66 6
a71 2
    print "dv_ntsc|dv (NTSC)|2|size=720x480,fps=30000:1001|dv|\n"; # NTSC
    print "dv_pal|dv (PAL)|2|size=720x576,fps=25.000|dv|\n"; # PAL
d86 10
d102 1
a102 1
	$syscom=$encoder_command . " -s $start -e $end %08d$to_ext -a wav $audiofile > \"$nfile\"";
d105 1
a105 1
	$syscom=$encoder_command . " -s $start -e $end %08d$to_ext > \"$nfile\"";
@


1.2
log
@fix encodedv encoder
@
text
@d4 5
a8 1
# LiVES encodedv plugin v1.2
d26 1
a26 1
    print "encodedv encoder plugin v1.2\n";
@


1.1
log
@Initial revision
@
text
@d61 2
a62 3
    # restrictions: currently the only one implemented is 'fps=xx.yy' which
    # means "can only encode at xx.yy frames per second" 
    # - otherwise set it to 'none'
a63 6
    if (&rc_get("PAL/NTSC") eq "NTSC") {
	print "dv|dv|2|size=720x480,fps=29.97|avi|\n"; # NTSC
    }
    else {
	print "dv|dv|2|size=720x576,fps=25.00|avi|\n"; # PAL
    }
d73 11
a83 2
    if (&rc_get("PAL/NTSC") eq "NTSC") {
	$to_ext=".ppm";
d86 1
a86 1
	$to_ext=".pgm";
a88 2
    $syscom=$encoder_command . " -s $start -e $end %08d$img_ext -a wav audiodump.wav > \"$nfile\" $err";

d104 2
a105 6
    if (&rc_get("PAL/NTSC") eq "NTSC") {
	$to_ext=".ppm";
    }
    else {
	$to_ext=".pgm";
    }
@


1.1.1.1
log
@initial
@
text
@@
