Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
ulluTV
Level 7

what is the exact syntax for BIFTool..

I tried several ways to run BIFTool, it just does not work..can someone give an example of command line

I have a file abc.mp4 file in c:\temp. How can I create a bif for this ?
0 Kudos
11 Replies
RokuKevin
Level 9

Using BIFTool

BIFTool can generate a bif file from a directory of jpg images that correspond to frames in the stream seperated by the specified time interval. It does not generate the directory of images, but other tools can.

Here is an example using ffmpeg to create a jpg every 10 seconds, and then creating an abc.bif file from those images that corresponds to the abc.mp4 stream:

% mkdir abc
% cd abc
% ffmpeg -i ../abc.mp4 -r .1 -f image2 %010.jpg
% cd ..
% biftool -t 10000 abc
0 Kudos
Highlighted
RokuAaron
Level 7

Further clarification and caveats

You'll likely want to generate two .bif archives for each piece of content. One for SD and one for HD. Which archive is used depends not on the resolution of the content, but on the resolution of the user's UI. That's why it's important to generate HD .bif archives even if the content is SD. However, if there is no HD .bif available, the player will fallback to using the SD .bif.

So here's one way to generate them:
% mkdir abc-sd abc-hd
% ffmpeg -i abc.mp4 -r .1 -s 240x180 abc-sd/%08d.jpg
% ffmpeg -i abc.mp4 -r .1 -s 320x240 abc-hd/%08d.jpg
% biftool -t 10000 abc-sd
% biftool -t 10000 abc-hd
This will result in two new files: abc-sd.bif and abc-hd.bif

There are two caveats here:
1) ffmpeg generates the .jpg files starting with index 1. This means that all the timestamps will be off by 10 seconds.
2) The SD frames should have a width of 240 and the HD frames should have a width of 320. Their height should be specified to coincide with their aspect ratio. The commands above assume a 4x3 aspect ratio. Unfortunately, ffmpeg doesn't let you specify only a width, keeping the original aspect ratio.

You will need to write code/scripts to overcome these caveats.
0 Kudos
bbefilms
Level 7

Re: what is the exact syntax for BIFTool..

In case it's of any use to others, a Perl script below to run ffmeg, reindex files and then run biftool for a directory of mov files (don't use it unless you know what you are doing; use it at your own risk!). In Windows, ffmpeg seems to generate an extra blank frame at index #1. I must be missing something because whatever I do the frames are exactly 20 seconds behind where they should be when testing on the Roku player. Any ideas? Really wish you guys would compile biftool for Mac (or release source code to do same) since I'm currently using VMWare to host Windows just for the biftool. Is biftool working properly on Windows?
Greg


############################################
#!/bin/perl

use File::Basename;
use File::Copy;
use File:Smiley Tongueath;

#################################################################
# bif_maker.pl - a script to generate bif files from video file images
# Greg Quinn, December 2009
####################################################################################
#
# PLEASE NOTE:
# This script may be freely used, distributed, and modified.
# It's intended for use by an experienced programmer/developer
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE and it is used at the user's own risk. The user
# assumes all liability for its use and the author assumes no liability for
# its use
#
#####################################################################################
#
# Script to find quicktime files in a directory (.mov) files and
# create the HD and SD bif files required for scene tricking support in the Roku
# Player. Requires PERL (free frrom ActiveState for Windows, already installed on
# most other operating systems) the free ffmpeg and Roku's biftool to be in the path
#
# USAGE: drop script in the directory with .mov video files and run script. Assumes
# that base file names for movie files (appended with "_hd" and "_sd") don't clash
# with any pre-existing dir's in that directory otherwise it will nuke them
#
#####################################################################################

# create a list of all *.mov files in
# the current directory - change to desired file type
# if different

opendir(DIR, ".");
@files = grep(/\.mov$/,readdir(DIR));
closedir(DIR);

# Process each of the file names
foreach $file (@files) {

# grab the base name of the .mov file
($basename,undef,$ext) = fileparse($file,qr{\..*});

# create the directories that we'll put the sequential images
mkdir $basename."_sd";
mkdir $basename."_hd";

# now create the sequential images at 10 sec intervals - assumes 16:9 format
system ("ffmpeg -i ".$file." -r .1 -s 320x180 ".$basename."_hd/%08d.jpg");
system ("ffmpeg -i ".$file." -r .1 -s 240x136 ".$basename."_sd/%08d.jpg");

# for 4:3 format, comment above and uncomment below
#system ("ffmpeg -i ".$file." -r .1 -s 320x240 ".$basename."_hd/%08d.jpg");
#system ("ffmpeg -i ".$file." -r .1 -s 240x180 ".$basename."_sd/%08d.jpg");

# 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, $basename."_hd");
@hd_bifs = grep(/\.jpg$/,readdir(DIR));
closedir(DIR);

# Number of created frames to drop
$dropnum = 0;
for ($image_num = 0; $image_num < ($#hd_bifs + 1) - $dropnum; $image_num++) {
$oldnum = sprintf("%08d",($image_num+1) + $dropnum);
$newnum = sprintf("%08d",$image_num);
move($basename."_hd/".$oldnum.".jpg",$basename."_hd/".$newnum.".jpg");
move($basename."_sd/".$oldnum.".jpg",$basename."_sd/".$newnum.".jpg");
}

# now use biftool to create the bif files
system("biftool -t 10000 ".$basename."_hd");
system("biftool -t 10000 ".$basename."_sd");

# delete the directories and the files in them
rmtree([$basename."_hd",$basename."_sd"]);
}
0 Kudos
Banta67
Level 7

Re: what is the exact syntax for BIFTool..

Greg,
This works and you rock!

Just one question. If the file as a space in the name, say The Hangover.mov, then the script fails.

Can this be fixed that without having to rename files?

Thanks, this has saved some headaches in creating these BIF files.
Banta
0 Kudos
bbefilms
Level 7

Re: what is the exact syntax for BIFTool..

(Sorry for the delayed reply, I missed this one)
Would strongly suggest naming movie files with no spaces - use underscores instead to represent a space if needed. Also BCL (or someone else, not sure who) wrote a Python script that creates BIF files from scratch which I'd probably recommend using instead. Yet another also: I pulled the image dimensions from another post here and I'm not 100% sure they're correct.
0 Kudos
jgravert
Level 7

Re: what is the exact syntax for BIFTool..

The script needs to pass " " Around the folders and filenames that have spaces. The command line cannot tell it's one string and will throw an error.

I don't know Perl well enough to tell you how to do this but it may be this ""folder name"" or possibly qq/folder name/.

What you want on the command line is something like this: -> C:\>biftool -t 10000 "folder name"

Or you can download a BIF creator from www.burningbushsoft.com

Good luck.
0 Kudos
titohammer69
Level 7

Re: what is the exact syntax for BIFTool..

"jgravert" wrote:
The script needs to pass " " Around the folders and filenames that have spaces. The command line cannot tell it's one string and will throw an error.

I don't know Perl well enough to tell you how to do this but it may be this ""folder name"" or possibly qq/folder name/.

What you want on the command line is something like this: -> C:\>biftool -t 10000 "folder name"

Or you can download a BIF creator from http://www.burningbushsoft.com

Good luck.



I gotta say that the BIF Creator app worked well and fixed the indexing issue.
0 Kudos
speechles
Level 9

Re: what is the exact syntax for BIFTool..


$ path/to/biftool ~/public_html/Movies/HarryPotter/HLS/600000/*.ts
Finding candidate frames in 917 files
Detected stream PTS offset of 10033ms
Captured 2368 candidate frames in 79s
Selected 915 BIFs
Success: ./fileSequence0000-fhd.bif (size=14.096MiB, numImages=915, avgSize=15.767KiB)
Success: ./fileSequence0000-hd.bif (size=8.528MiB, numImages=915, avgSize=9.535KiB)
Success: ./fileSequence0000-sd.bif (size=3.920MiB, numImages=915, avgSize=4.378KiB)


https://github.com/rokudev/docs/blob/ma ... ck-play.md

If you peruse the document above, it appears FHD is an option. What isn't clear, the documentation makes no mention on the width these BIF should be when trying to build them as FHD. If I were a betting man I would think this would be 480, since SD is 240, and HD is 320. Is there anyone who knows how to build FHD BIF files and cares to share the answer? Sharing is caring. Thanks and Merry Christmas, HO, HO, HO! and all that other stuff. Smiley Happy
0 Kudos
EnTerr
Level 9

Re: what is the exact syntax for BIFTool..

"speechles" wrote:
Is there anyone who knows how to build FHD BIF files and cares to share the answer?

Open a ticket at https://github.com/rokudev/docs/issues on this.
Because of some peculiarity(?), DannyKNg - recently knighted Manager of the Developer Experience - does not participate in this forum; he'll see it there though.
0 Kudos