1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

perl script: ffmpeg watermark ripped youtube videos

Discussion in 'Black Hat SEO Tools' started by neehaf, May 27, 2009.

  1. neehaf

    neehaf Newbie

    Joined:
    May 9, 2009
    Messages:
    9
    Likes Received:
    6
    Converts all the mp4 files in a directory to a watermarked mpg.

    I built this perl script for some of my youtube attempts at getting traffic. Hopefully it will be helpful to someone else.

    [read!] Give me a shoutout any of you can help me make a few bucks off youtube or online please. Man's gotta eat and the bank is knocking at my door asking for it's $ and I am just getting into the blackhat game. I am an experienced web developer (10+ years), my normal whitehat work has dried up with the economy recently.

    save this file as a .pl
     
    • Thanks Thanks x 1
    Last edited: May 27, 2009
  2. neehaf

    neehaf Newbie

    Joined:
    May 9, 2009
    Messages:
    9
    Likes Received:
    6
    #!/usr/bin/perl
    ## Disclaimer: this might not work for everyone, it was built for my system for me.
    ## Author info: BHW userid - neehaf
    ## I cobbled together this script from various examples dealing with ffmpeg and video conversion with watermarks. Feel free to bastardize this script.
    ## Description: Batch converts directories containing media files to watermarked versions
    ## Requirements: perl, file::find::rule perl lib, ffmpeg, libmp3lame, watermark.so
    ## Usage: 1) You must have a watermark image / transparent gif setup.place perl script in directory containing mp4 files.
    ## perl perl-ffmpeg-watermark.pl
    ##
    ##

    use File::Find::Rule;

    ## set sourcetree to the location of your *.mp4 files ripped from youtube.
    my $sourcetree = '/home/user/Desktop/videos/videos_convert/';
    my $ffmpeg_flags = "-ab 57 -ar 22050 -b 500 -s 480x320 -acodec libmp3lame";
    my $watermark_image ='/home/user/Desktop/videos/videos_convert/download-transparent.gif';
    my $vhook_lib_command = "/ffmpeg/vhook/watermark.so -m 1 -t 222222 -f";

    print "Starting to process the sourcetree\n";


    ## Set files array
    my @files = File::Find::Rule->file()
    ->name('*.mp4')
    ->in($sourcetree);
    ## Loop each file.
    foreach my $file (@files) {
    ## File to watermark
    my $dest = $file;

    ## GETS EXTENSION OF FILE.
    @infile = split(/\./, $dest);
    ## LENGTH OF FILE
    $len = @infile;
    ## EXT FORMAT FILE TO GRAB JUST LAST EXTENSION OF FILE TO SEE IF IT'S MP4 LATER.
    $ext = $infile[$len-1];

    # SETUP NEW FILE NAME AFTER PROCESSED WITH DIFFERENT EXTENSION.
    $new = join('.' , @infile[0..$len-2]);
    ## RENAME FILE
    $newmpg = join('.', $new,"wm.mpg");

    ## MAKE ALL THE FILE NAMES NICE AND NEAT FOR OUR IF STATEMENT - ESCAPE SPACES, QUOTES ETC WITH quotemeta
    $clean_file_dest = quotemeta($dest);
    $clean_new_file_name = quotemeta($newmpg);

    # if extension is an mp4, continue
    if ($ext eq "mp4" ) {
    #system executes and waits for ffmpeg to finish each watermark conversion, then continues.
    system("ffmpeg -i $clean_file_dest $ffmpeg_flags -vhook '$vhook_lib_command $watermark_image' $clean_new_file_name");
    print "Converted and all is well.\n";
    } else {
    ## SHITS BOKRED.
    print $dest , " is not an mp4 file.\n" ;
    }
    }
     
    • Thanks Thanks x 4
  3. 4alllifestyles

    4alllifestyles Junior Member

    Joined:
    Dec 3, 2008
    Messages:
    170
    Likes Received:
    98
    Not a bad piece of code and all the modules are in YUM (if your using Centos Fedora or RH)...

    I can use it...

    Good code...
     
  4. neehaf

    neehaf Newbie

    Joined:
    May 9, 2009
    Messages:
    9
    Likes Received:
    6
    I commented the code so it made things easier for people to understand.

    btw, I am getting ticked I can't paste more code, says I need 15 posts to upload URLS.

    I have a perl script that downloads a youtube video to flv I'll post when I have 15+ posts.
     
  5. carlouche

    carlouche Regular Member

    Joined:
    Jul 13, 2008
    Messages:
    246
    Likes Received:
    39
    Occupation:
    seller
    Location:
    france
    Home Page:
    great
     
  6. thegodyouthank

    thegodyouthank Newbie

    Joined:
    Nov 8, 2008
    Messages:
    44
    Likes Received:
    75
    Hi! I would like to say first, thank you for your share of that perl script!

    I understand if you don't have the time to answer the following question, but I would like thank you in advance for your time if you do.

    I have no real experience with perl. I have been trying to figure out exactly how to use this script.

    I have installed both ActiveState Perl and Strawberry Perl. I have sought out the necessary modules...learned about both CPAN and PPM. You get the point.

    I am still getting errors when I try to run this script. In fact...I am still getting errors when I try to install some of the modules necessary to run this script. Every time I download one and try to install one it will state that I am missing some other necessary module needed in order to install the one that I am currently trying to install. I'm not quite sure what I'm doing wrong here, and it's a little frustrating. :(

    Like I said, I understand if you don't have the time to respond, but thank you in advance if you do.
     
  7. 4alllifestyles

    4alllifestyles Junior Member

    Joined:
    Dec 3, 2008
    Messages:
    170
    Likes Received:
    98
    That's normal for something like this.

    It takes a TON of modules (programming objects) to allow that little code to do what it's doing.

    When you get the mods from CPAN do it from the cpan shell! Dunno how it is on your windows box but in all the IX Os's it's something like

    perl -MCPAN -e shell

    install MODULENAME

    And it'll ask you for every install prereq for that module.

    Makes it easier. Not totally "blow and go" but easier.
     
    • Thanks Thanks x 1
  8. thegodyouthank

    thegodyouthank Newbie

    Joined:
    Nov 8, 2008
    Messages:
    44
    Likes Received:
    75
    Ah, thanks! :)

    It's just such a tedious task...worth it, though. I just wasn't sure if it was just me. I guess it was just a little strange to me that I was basically installing something in reverse and one piece at a time, but it does make sense once I actually stop to think about it.
     
  9. Deprecated

    Deprecated Registered Member

    Joined:
    May 19, 2009
    Messages:
    78
    Likes Received:
    25
    Assuming your server is a *nix variant, you'll just need to upload the script to your cgi-bin directory, chmod the script to 0755 and run it from SSH. The script will error out from the browser since it's not returning a header.
     
  10. sikx

    sikx Registered Member

    Joined:
    Jan 4, 2009
    Messages:
    65
    Likes Received:
    166
    Location:
    Germany
    Home Page:
    Ohhh why so complicated? :)
    Just make a short bash-script, check out my (old) blog entry for exactly this: http://nytemarez.com/watermarked-videos/

    P.s.: More comments than code most of the time means redundancy in commenting. Well written code should be able to be read like the english language.
     
    Last edited: May 30, 2009
  11. neehaf

    neehaf Newbie

    Joined:
    May 9, 2009
    Messages:
    9
    Likes Received:
    6
    Thanks for the smackdown sikx :p

    When I was building that script I stumbled upon your page and used it as reference, good stuff.

    The comments are not there for me, they are for other users on this forum who may have some questions and ultimately might end up modifying the code.

    From a perl n00b perspective, I think this helps others. Peace!
     
    • Thanks Thanks x 1