Your Digital Media Has Never Looked So Good

 
ulluTV
Topic Author
Posts: 1
Joined: Wed Aug 26, 2009 4:52 pm
Contact:

what is the exact syntax for BIFTool..

Thu Oct 29, 2009 10:34 pm

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 ?
 
User avatar
RokuKevin
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Using BIFTool

Mon Nov 30, 2009 5:58 pm

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
 
User avatar
RokuAaron
Roku Engineering
Posts: 8
Joined: Wed Aug 26, 2009 3:30 pm

Further clarification and caveats

Wed Dec 02, 2009 12:11 pm

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.
 
bbefilms
Posts: 126
Joined: Mon Dec 21, 2009 9:16 pm
Location: San Diego, California
Contact:

Sat Dec 26, 2009 3:09 pm

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::Path;

#################################################################
# 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"]);
   }
 
Banta67
Posts: 18
Joined: Mon Aug 18, 2008 12:00 pm

Re: what is the exact syntax for BIFTool..

Thu Mar 11, 2010 11:31 am

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
 
bbefilms
Posts: 126
Joined: Mon Dec 21, 2009 9:16 pm
Location: San Diego, California
Contact:

Re: what is the exact syntax for BIFTool..

Sat Mar 13, 2010 10:28 am

(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.
 
jgravert
Posts: 9
Joined: Mon Jan 12, 2009 8:47 am

Re: what is the exact syntax for BIFTool..

Mon Jan 03, 2011 2:00 pm

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.
 
titohammer69
Posts: 8
Joined: Sun Jul 24, 2011 8:28 pm

Re: what is the exact syntax for BIFTool..

Thu Oct 20, 2011 12:12 am

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.
 
User avatar
speechles
Posts: 169
Joined: Thu Aug 06, 2015 11:15 pm

Re: what is the exact syntax for BIFTool..

Sat Dec 17, 2016 2:22 pm

$ 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. :)
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: what is the exact syntax for BIFTool..

Sat Dec 17, 2016 2:46 pm

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.
 
User avatar
speechles
Posts: 169
Joined: Thu Aug 06, 2015 11:15 pm

Re: what is the exact syntax for BIFTool..

Sat Dec 17, 2016 2:54 pm

@Enterr I can do that, sure. The strange thing is, the same appears on the sdkdocs url. That isn't saying much though, as I have seen errors in those documents before too. Where far too little information was given to make full use of the feature it was documenting. In this case, since FHD is in "something new" stage I am hoping both these docs can be updated, and the answer given, at the same time. Killing three birds with one stone.

...unless...the missing information is a ploy to get users to register on these forums to post issues? I doubt that is the case here though. :)
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: what is the exact syntax for BIFTool..

Sat Dec 17, 2016 6:55 pm

speechles wrote:
The strange thing is, the same appears on the sdkdocs url. That isn't saying much though, as I have seen errors in those documents before too. Where far too little information was given to make full use of the feature it was documenting. In this case, since FHD is in "something new" stage I am hoping both these docs can be updated, and the answer given, at the same time. Killing three birds with one stone.

That's because the GitHub page is a partial copy&paste from the wiki documentation. I have no idea why this github re-write was started this past summer but it seems the effort has been largely abandoned since mid-October.

The Roku SDK docs history goes like this - at first they were releasing it as PDF sets, then moved to Confluence wiki (a much welcome move because of instant updates) and this year... i don't know what happened, since i haven't heard anybody calling for the docs to be moved to GitHub - and i fail to see advantage in the attempted move. I can only hypothesize (i.e. speculation) that this ought to be legacy from the now-former chief evangelist of the Co. Bless his legacy, for he did some great things - the main one being reviving in 2016 the Roku's dev.program from a slumber it fell in 2012 (when the previous principal moved on) - like a regular Rip van Winkle. But he also had some strange ideas, like Roku's salvation being in "hackathons" - or one imagines, "let's move the docs to github because... that's where we had them in the previous company"?! IDK, i am stumped at the attempted move, which would be a titanic undertaking if ever to be finished.

So what we have now is 2 locations - one at http://sdkdocs.roku.com that everyone knows and uses - and another partial copy on GH. 
Confusing? I know i am. 
Hard to maintain both? You bet Jurassic!

...unless ...the missing information is a ploy to get users to register on these forums to post issues? I doubt that is the case here though. :)

That's the spirit! Every cloud has a silver lining.  :mrgreen:
I have contemplated in the past if Roku's dev.program is some kind of a secret trial, a "maze runner" intelligently designed to ensure survival of the fittest. Eventually i realized i have been flying against the Hanlon's razor  8)

Who is online

Users browsing this forum: No registered users and 9 guests