Tomas,

I've cc'd you directly in case the mailing list strips attachments, because I've attached a simple perl script that does as you desire. I named it smelt. You can rename it as you like.

On 10/02/2016 02:29 PM, Tomas Hlavaty wrote:
It would be nicer, if I could create a file:
example.melt:
-profile atsc_720p_25
color:black out=24
pic1.png out=115
   -mix 25 -mixer luma
vid1.mp4 in=5260 out=6775
   -mix 25 -mixer luma
vid2.mp4 in=7538 out=10210
   -mix 50 -mixer luma -mixer mix:-1
-consumer avformat:output.mp4 f=mp4 acodec=aac vcodec=mpeg4 b=6000k

and call it:
$ melt melt:example.melt

That part practically already works. If you have a file:

example.melt:
color:red out=50
color:green out=50
    -mix 10 -mixer luma
#color:blue out=50
#    -mix 10 -mixer luma
color:white out=50
    -mix 10 -mixer luma
color:black out 50
    -mix 10 -mixer luma

Just launch it like this:

melt `cat example.melt`

It works fine, except it is not recursive so you can't include stuff.

with the ability to comment out things in the melt file and include
other melt files, something like:

example.melt:
-profile atsc_720p_25
color:black out=24
pic1.png out=115
   -mix 25 -mixer luma
vid1.mp4 in=5260 out=6775
   -mix 25 -mixer luma
#vid2.mp4 in=7538 out=10210
#  -mix 50 -mixer luma -mixer mix:-1
melt:example2.melt
-consumer avformat:output.mp4 f=mp4 acodec=aac vcodec=mpeg4 b=6000k

Then cli melt would be almost perfect:-)

I have attached a perl script I threw together which should exactly match your description above.

It supports any number of command line arguments, a file to each, and it supports like a thousand depth of recursive includes, (whatever perl supports for recursively called functions and simultaneously open files. )

The multiple file argument would allow you to have your main composition exclude the final target (i.e. -consumer avformat.....)

Then you could have different files that defined the consumers, so you could easily change rendering target for a given composition by just specifying a different render target filename on the command line.

so you could do like this:

#To just play to the screen the production:
smelt intro.melt maincontent.melt credits.melt

#To render to a low quality preview video:
smelt intro.melt maincontent.melt credits.melt renderers_small_preview.melt

#Then to render it to high quality:
smelt intro.melt maincontent.melt credits.melt renderers_1080p_mpeg4.melt

The renderers files of course would just contain the melt parameters to render as desired.

Of course since it's recursive, you can also just have a file like:

main.melt:

melt:intro.melt
melt:maincontent.melt
melt:credits.melt
melt:renderers_1080p_mpeg4.melt

then invoke it like:

smelt main.melt

Let me know how it works, if you like. I can only test it with colors: because I'm still trying to get mlt to build with avformat.

Other features which I did not add but did think of include an option to specify the or other melt parameters directly on the command line, and if you think those are a good idea,
let me know the syntax you like and I'll try it.

From my programming background, "include:" or "insert:" or "read:" seem to make more sense but I understand that melt: is what melt uses so that makes perfect sense too.

And frankly, melt probably does not use the word include: or insert: so the perl script could probably treat those the same as "melt:" but anyway no need to worry about that for now.

Hmm, it looks like it's trying to compile melt from scratch probably
because it is not compiled by hydra and the binaries are not for
download in the cache.  In any case it should work.

It pulled in just under 2GB of data to /nix, and tries to build mlt, but fails while trying to fetch some perl patch off of debian's website which is 404 file not found. I've spent several hours in #nixos on irc with folks there actively trying to troubleshoot it but so far we haven't been able to figure it out.
Still trying.

So in the mean time I can play with melt, fading between different solid colors.

PS I agree that having to use backslashes at end of every line is a real pain. I forget some, or put a space after some, or whatever.

~Jesse
#!/usr/bin/perl

$ver=0.01;

if($#ARGV<0)
{
        print "\n";
        print "Smelt version $ver - recursive multiple file reader for melt.\n";
        print "Usage:\n";
        print "$0 [--showcommand] <filename1> [filename2 [filename3 [filenameN 
[...]]]]\n";
        print "inside of a file:\n";
        print " melt:<filename> to include another filename (Do not quote),\n";
        print " # for a comment at any position in a line:\n";
        print "         Everything after the # is ignored.\n";
        print " --showcommand: Show the melt command instead of running it.\n";
        print "\n";
        exit (0);
}

$deep=0;

sub readfile
{
        $deep++;
        my $filename=shift;
        my $fh;
        if (open($fh,$filename))
        {
                print '  ' x $deep;
                print "Opened file '$filename' for reading..\n";
                my $line;
                while($line=<$fh>)
                {
                        $line=~s/[\r\n]//g;     #Drop all newlines stuff from 
end of line.
                        $line=~s/#.*//g;        #Drop comment symbol and all 
following
                        $line=~s/^[ \t]*//g;    #Drop leading tabs/spaces
                        $line=~s/[ \t]*$//g;    #Drop trailing tabs/spaces
                        if($line ne "")
                        {
                        #       print "line='$line'\n";
                                if($line=~m/^melt:/i)
                                {
                                        $line=~s/^melt://gi;
                                #       print "including '$line'\n";
                                        readfile($line);
                                }else{
                                        my $word;
                                        foreach $word (split(/ /,$line))
                                        {
                                        #       print " word='$word'\n";
                                                push(@args,$word);
                                        }
                                }
                        }
                }
                close($fh);
                print '  ' x $deep;
                print "Closed file '$filename'\n";
        }else{
                print "ERROR: Unable to open '$filename' for reading!\n";
                print "Recursion level is $deep,\n";
                print "and if that is a high number, you may have an\n";
                print "include loop. (i.e. a file including itself.)\n";
        }
        $deep--;
}

foreach $filename (@ARGV)
{
        if($filename=~m/--showcommand/i)
        {
                $showcmd=1;
#       }
#       elsif($filename=~m/-h/i)        #Don't want to remap too many things, 
they might be used by melt..
#       {
#               print "For help, run $0 with no parameters.\n";
#               exit(0);
        }else{
                readfile($filename);
        }
}

$cmd="melt";
foreach $arg (@args)
{
        $cmd="$cmd '$arg'";
}

if($showcmd)
{
        print "\n\n$cmd\n\n";
}else{
        system($cmd);
}



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to