Member
Member
george2   2008-06-12, 21:18
#1

is it possible for zen photo to make thumbs from videos, flv's especially? ffmpeg springs to mind!

Member
Member
Mammlouk   2008-06-12, 21:32
#2

This question was recently addressed here:
http://www.zenphoto.org/support/topic.php?id=3187&replies=29

But since it is not clearly obvious in the post title and only shows up in the google search vs the site's search I will post the basic response.

zenphoto does not currently support automated thumb creation from any videos. You can however create your own thumbnails and put them in the directory with a specific naming image--video.jpg?? I can't remember for sure as I don't use videos.

On the topic of using ffmpeg, I know I saw it recently posted elsewhere but didn't notice it at a cursory glance. Adding server side requirements is counter-intuitive to the goals of zenphoto. I imagine you could develop a plugin for it so that it is not a core requirement, but you'd need to do it yourself or find someone willing/interested in the project.

Member
Member
george2   2008-06-12, 23:42
#3

ok, thanks for the reply.

i'd be happy to take on a plugin, but have a few questions about plugin creation...

i want to obviously add some sort of link to zp to say make thumb - i'll probably start with a random time offset for the moment which i guess should go on the content listing page for the album it's in.

am i right in assuming it wouldn't be a template plugin?

so, in that case, how do i extend the functionality of the zp core? the plugin doc doesn't really say much. i've looked at the spam filter plugin code, but just see a dir defining filters, where do i put the code to add a menu to the options/comments html?

do i have to modify core to do that?

Member
Member
sbillard   2008-06-13, 01:36
#4

I see two ways you could approach this.

  1. You could make some code that captures the thumbnail image from the video and saves as a jpeg/png image of the same name in the same gallery. Then all you need is a php script that someone could run that would scan his albums looking for videos to convert.

  2. You could make some code that captures the thumbnail and creates a thumb in the Cache folder based on the croping, etc. This latter will have to be integrated into zenphoto as currently there are no "plugins" for image handling.

If you choose to embark on #2 I would suggest the follownig:
your plugin should implement the functionality of the checkVideoThumb() function in functions.php. That is it should return a image file name for the thumb. You will have to store the thumb in the album root folder.

Test your implemetation by deleting the checkVideoThumb() code from functions.php and replace it with a require_once('SERVERPATH.'/'.ZENFOLDER.'/plugins/thumbs/'.your script name). Place your script inzp-core/plugins/thumbs/`

Once you get things working, create a ticket and attach your plugin PHP file. We will take care of integrating it as an option in zenphoto.

Member
Member
danielsbrewer   2008-06-13, 09:15
#5

Just in case it is of any help, this is the script I use to create all the thumbnails, taking a snapshot 2 seconds into the video:

`#!/bin/bash

ORIGINAL_IFS=$IFS

IFS=$'\n'

for i in find . -name "*.flv"

do

ffmpeg -y -i "$i" -f mjpeg -ss 00:00:02 -vframes 1 -an "${i%flv}jpg"

done

IFS=$ORIGINAL_IFS

`

PS There should be backticks around the find statement i.e. the black bit

Member
Member
george2   2008-06-13, 09:52
#6

ok, thanks guys, i'll sit down with this as soon as i get some time, but this is what i did for the moment, kinda what daniel put, but in php

// full path to ffmpeg
define ('FFMPEG_PATH', 'C:/bin/ffmpeg');

// full file path
$inputvideo = 'c:/xampp/htdocs/galleryscripts/zenphoto/make_thumbs/test.wmv';
$thumbfilename = 'thumb.jpg';

if (makevideothumb($inputvideo, 300, 300, 0, 0, 20, $thumbfilename)){
// just show it to show it worked!
header("Content-type: Image/png");
print file_get_contents($thumbfilename);
}
else{
die ('thumb creation failed');
}

function makevideothumb($input, $w, $h, $hour, $min, $sec, $thumbname){
if (strlen($hour) == 1){
$hour = '0' . $hour;
}
if (strlen($min) == 1){
$min = '0' . $min;
}
if (strlen($sec) == 1){
$sec = '0' . $sec;
}

system(FFMPEG_PATH . " -i $input -vcodec png -vframes 1 -an -f rawvideo -s " . $w . "x" . $h . " -ss " . $hour . ":" . $min . ":" . $sec . " -y " . $thumbname);

if (filesize($thumbname) > 0){
    return true;
}
else{
    unlink ($thumbname);
    return false;
}

}

not random yet, but i only need to grab the video length, and then make up a random time for it

?>

Administrator
Administrator
acrylian   2008-06-13, 11:08
#7

Just for info:
The video thumb "issue" is also adressed on our user guide page "Troubleshooting Zenphoto": http://www.zenphoto.org/2007/12/troubleshooting-zenphoto/#19

And we have a article about plugins, too:
http://www.zenphoto.org/2008/04/zenphoto-plugin-architecture/

Member
Member
george2   2008-06-13, 12:12
#8

ok, ticket made
http://www.zenphoto.org/trac/ticket/569

Member
Member
Mammlouk   2008-06-13, 13:15
#9

Lookin' good! I will try to test it out tonight or tomorrow when I have time.

Member
Member
slaattnes   2009-10-12, 02:06
#10

Did you ever make the plugin?:-)

Administrator
Administrator
acrylian   2009-10-12, 08:51
#11

You can download what he did on the ticket linked.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.