maintaining two versions of each movie file

zelo

Joined: 2004-06-22
Posts: 8
Posted: Mon, 2005-04-11 16:38

Hello,

I have many QuickTime MOV files.
Their bit ratio is around 8Mbit/s so they are unacceptable for streaming.
So I make low-quality copies (400Kbit/s) for streaming.
What I want is when showing such a MOV file
I play the low-quality copy embedded in the browser
and at the same time provide a download link for the original high-quality MOV file.

Keeping both embedded play and a donwload link (fallback) was easy.
I just needed to change the GalleryMovieItem_core::render function.
But maintaing two versions does not seem so easy.
Currently I create a MOV sub-album containing all the MOV files,
while the low-q copies are in the parent (original) album.

So what will be the easiest way to achieve this customization?

  1. Keep the current configuration (MOV sub-album) but
    insert a download link pointing to the MOV file when showing
    the low-quality version. (In this case, where should I save the connection
    between the two version?)
  2. Make a "derivative" for each MOV file.
  3. Create another "view" like 'new_module:PlayItem" for low-quality copies.
  4. Or any other standard and/or smart way ?

I'm new to the Gallery code so any advice of yours will be really invaluable to me.[/]

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-11 17:54

(b) would be cool, but requires a fair amount of work... G2 needs to be able to create derivatives, so you'd need a toolkit module that knows how to run some command line program that does the quality conversion; then you'd need an item-edit plugin that creates the derivative for a movie. with these in place you could upload the original movie and add a derivative so G2 will create the lower quality one for you. But then you'd still need to do some work with layouts to display this properly, as currently we only handle derivatives of images (ie, all the derivative display stuff is based on dimensions...)
If you want to give this a shot we can provide guidance.. maybe even get your code into the product when you're done.

i can post about alternatives after you consider this...

 
zelo

Joined: 2004-06-22
Posts: 8
Posted: Tue, 2005-04-12 01:12

Thank you for your comments.
I agree that what you said is a very general and standard way.
But as you know our time is limited. :D
For that reason, what I want is the easiest and quickest way to achieve this.
I already have a script that generates the low quality copies outside G2.
So at first I just thought "Ok, let's change the url in the <object> tag
from http://localhost/a.MOV to http://localhost/a.400.wmv".
But the url generated by G2 was far from that.
It seems to be "view" + "itemId" basically.

What about adding a new "view" which acts just like DownloadItem
but sends a.400.wmv (if it exists) instead of a.MOV ?
Will it be easy ?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-04-12 04:32

i'd probably do something like this:
upload the low quality items into albums where you want users to browse and find them. upload the high quality into a separate hidden album (the album has restricted permissions but the movies inside it have 'view original' permission). use a naming convention like you suggested; maybe a.mov -> a.big.mov or something like that.
finally, modify modules/core/classes/GalleryMovieItem.class function render(). Make it add the "download full size" link in the html output. To make the link first do $item->getPathComponent() and apply the naming convension for the full quality movie. Then call:

list($ret, $id) = GalleryCoreApi::fetchItemIdByPath('/bigmovies/' . $bigMovieName);
if ($ret->isError()) {
    return array($ret->wrap(__FILE__, __LINE__), null);
}
list ($ret, $bigMovie) = GalleryCoreApi::loadEntitiesById($id);
if ($ret->isError()) {
    return array($ret->wrap(__FILE__, __LINE__), null);
}
$bigMovieUrl = $urlGenerator->generateUrl(array('view' => 'core:DownloadItem', 'itemId' => $id, 'serialNumber' => $bigMovie->getSerialNumber()));
 
zelo

Joined: 2004-06-22
Posts: 8
Posted: Tue, 2005-04-12 13:58

Thank you very much !!
Your advice was really helpful.
When I finish my customization, I'll post the result here.