Roku Biftool Perl

I don’t remember if I wrote this or snagged it off a forum post or what. It’ll create the trickmode bif file for a Roku DVP using the biftool bin in the SDK. I put biftool in /usr/local/bin/ on my system.

Contents of:
/usr/local/bin/bifencode.pl
[perl]
#!/bin/perl

use File::Basename;
use File::Copy;
use File::Path;

if ($#ARGV != 1 ) {
print "Scriptname Path File";
exit;
}

$directory=$ARGV[0];
$file=$ARGV[1];

unless (-e $directory."/".$file) {
print "File Doesn’t Exist!n";
exit;
}

# create the directories that we’ll put the sequential images
mkdir "/tmp/".$file;

# for 4:3 SD Only
system ("ffmpeg -i ".$directory."/".$file." -r .1 -s 240×180 "."/tmp/".$file."/%08d.jpg >> /tmp/".$file."-bif.log 2>&1");

# Renumber images in directories to a zero-based index, required because
# ffmpeg number starting from #1 which would put timing out by 10 secs
opendir(DIR, "/tmp/".$file);
@bifs = grep(/.jpg$/,readdir(DIR));
closedir(DIR);

# Number of created frames to drop
$dropnum = 0;
for ($image_num = 0; $image_num < ($#bifs + 1) – $dropnum; $image_num++) {
$oldnum = sprintf("%08d",($image_num+1) + $dropnum);
$newnum = sprintf("%08d",$image_num);
move("/tmp/".$file."/".$oldnum.".jpg","/tmp/".$file."/".$newnum.".jpg");
}
chdir("/tmp");

# now use biftool to create the bif files
system("biftool -t 10000 "."/tmp/".$file);

# delete the directories and the files in them
rmtree(["/tmp/".$file]);

[/perl]

One thought on “Roku Biftool Perl

  1. Could you kindly provide a syntax example? I am sadly unable to interpret “Scriptname Path File” into anything meaningful.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: