Help for Module-Develpoment: Choose Videothumb

mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Tue, 2011-11-29 22:20

I missed a module, where one can choose the video-thumb manually. In G2 there was such a thing.

So far it works (see attachment), but when recalling the form after submit, it shows an urlencoded string instead of the form:

%3Cdiv%20style%3D%22width%3A%20600px%3B%20height%3A%20300px%3B%22%20class%3D%22g-videothumb-dialog%22%3E%0A%0A%3Cform%20action%3D%22/gallery3/index.php/videothumb/dialog/5234%22%20method%3D%22post%22%20id%3D%22videothumb_form%22%3E%0A%20%20%20%20Sekunde%3Cinput%20type%3D%22text%22%20name%3D%22second%22%20size%3D%223%22/%3E%0A%20%20%20%20%3Cinput%20type%3D%22submit%22%20value%3D%22OK%22%20id%3D%22videothumb_submit%22%3E%0A%20%20%20%20%3Cinput%20type%3D%22hidden%22%20value%3D%22/srv/www/htdocs/gallery3/var/albums/Testgalerie/Videovorbereitung/Maepo_V1.flv%22%20name%3D%22file_path%22%3E%0A%20%20%20%20%3Cinput%20type%3D%22hidden%22%20value%3D%22/srv/www/htdocs/gallery3/var/thumbs/Testgalerie/Videovorbereitung/Maepo_V1.jpg%22%20name%3D%22thumb_path%22%3E%20%20%0A%20%20%20%20%3Cinput%20type%3D%22hidden%22%20value%3D%221%22%20name%3D%22sent%22%3E%20%20%20%20%20%20%20%0A%3C/form%3E%0A%0A%3Cimg%20src%3D%22/gallery3/var/thumbs/Testgalerie/Videovorbereitung/Maepo_V1.jpg%3Fm%3D1322604814%22%20alt%3D%22%22%20width%3D%22200%22%3E%0A%20%0A%3C/div%3E%0A

Not php urldecode nor javascript unescape could change this.

Hope someone can help me out here :-)

AttachmentSize
videothumb.zip8.74 KB
 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 14:23

I'm having no such problem.
Are you using firebug or similar to view the response?

Besides a bit of dialog polishing and a refresh after the response this looks great.
Good job.
Maybe add an additional option to upload a custom thumb for those without ffmpeg.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2011-11-30 14:43

Nice, and works, but I'm getting the same response as mr.xy.

I agree it needs polishing and german->english conversion, but well done and a very nice start.

Thanks!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 15:35

I thought maybe the html purifier module would cause your issue, but I cannot reproduce the issue.
But I'm still on 3.0.1

here is my cleaned up videothumb_dialog.html.php

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2011-11-30 16:37

nice work suprsidr, however, gibberish still occurring after thumb selection.

3.0.2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 16:46
 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 16:57

Confirmed, can reproduce on 3.0.2
BTW, the G3 I updated was vanilla 3.0.0 and the module performed as well as on 3.0.1

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 17:29

try this:
/controllers/videothumb.php line~24

  function dialog($item_id) {
    $item = ORM::factory("item", $item_id);
    access::required("view", $item);
    access::required("edit", $item);
    $v = new View("videothumb_dialog.html");

    $v->item = $item;
    if($_POST['sent']) {
        $this->extract_frame_manual($item_id);
    }
    print json::reply(array("html" => (string)$v ));
  }

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2011-11-30 17:35

Well done! Works a charm now.

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2011-11-30 17:37

Only thing I see that would 'clean' it up a bit is:

- to remove it from the top menu selection (only show on context menu)
- don't show option if not a video

Other than those two nitpicking ideas, awesome.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 18:22
Quote:
Only thing I see that would 'clean' it up a bit is:

- to remove it from the top menu selection (only show on context menu)
- don't show option if not a video

helpers/videothumb_event.php

  static function context_menu($menu, $context_menu, $item, $thumbnail_css_selector) {
      if($item->type == 'movie')
        $menu->get("options_menu")
          ->append(Menu::factory("dialog")
                   ->id("videothumb")
                   ->label(t("Video Thumbnail"))
                   ->css_class("ui-icon-folder-open g-videothumb-link")
                   ->url(url::site("videothumb/dialog/{$item->id}")));       
  }

I left movie_menu as is except translation and removed it completely from site_menu

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2011-11-30 18:31

What more can I say... perfect module!

I was doing this by hand, and it was a pain in the @&&.

Many thanks to you folks.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 18:34

oops, edit site_menu to:

  static function site_menu($menu, $theme) {
      $item = $theme->item();
      if($item->type == 'movie')
          $menu->get("options_menu")
              ->append(Menu::factory("dialog")
                       ->id("videothumb")
                       ->label(t("Video Thumbnail"))
                       ->css_class("ui-icon-folder-open g-videothumb-link")
                       ->url(url::site("videothumb/dialog/{$item->id}")));
  }

Not sure where movie_menu appears

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-11-30 18:48

updated the above site_menu function to actually work this time ;)

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2011-11-30 18:58

Yep, cool, I caught that one earlier :) Forgot to mention it.

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Wed, 2011-11-30 23:37

Ahhmm this is stunning. What happend in this thread while I was away coding?

Now one can choose which version to prefer ;-)

I added the possibility to define thumb-dimensions. They are set on the basis of defined width in theme and assumes 4:3 aspect ratio. Also I included a field for minute.

Have a look. May be we can combine our work.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2011-12-01 01:57

Keep up the great work!
What I would like to see is two things:
1. On the modal window I think it would be nice to see the total time of the video.
2. I think the modal window needs 3 buttons. Commit, Preview, Cancel. The preview would function as the commit does now and the Commit would save the thumb and close the dialog.

Just enhancements and usability that popped into my head at first glance.
I will help with some docs unless somebody else would like to contribute :-)

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Thu, 2011-12-01 12:41

@floridave:
I had the same two points on my whishlist. Total-time is now added. (see attachement)

Point 2:
Since it immediately changes the thumb "Preview" is mistakeble. I thought of a "Ready" button, but every Submitbutton in the proper style leads to a Cancelbutton beside it. If someone can help me out with this javascript-thing ... to have a single "Ready"-Submitbutton.

Next question would be where to place the "Ready"? The right place would be between the "Send" an "Cancel". But that could be difficult since they come automatically together.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-12-01 12:49

If you looked at my dialog update, I have the only necessary buttons: "Ok" and "Done" along w/ some css to fix form element layout.
The "Done" button forces a refresh of the page to update the new thumb.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-12-01 15:50

@mr.xy
Dealing with video duration in total seconds would probably be more fitting as some video formats set duration in total seconds not min:sec.
Not one of my videos showed a duration of more than 0:0 with your query. Here is my solution:

  static function get_duration_manual($item) {
    $ffmpeg = movie::find_ffmpeg();
    if (empty($ffmpeg)) {
      throw new Exception("@todo MISSING_FFMPEG");
    }
    
    $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($item->file_path()) . " 2>&1";
    $result = `$cmd`;
    if (preg_match("/Duration: (\d+):(\d+):(\d+\.\d+)/", $result, $regs)) {
      return 3600 * $regs[1] + 60 * $regs[2] + $regs[3];
    } else if (preg_match("/duration.*?:.*?(\d+)/", $result, $regs)) {
      return $regs[1];
    } else {
      return '00';
    }
  }

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Thu, 2011-12-01 16:07

So, have all the corrections/modifications/etc (suprsidr's changes - excluding last one above) rolled in to the last zip posted?

This is becoming a very nice module indeed.

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Thu, 2011-12-01 22:03

Thanks suprsidr for your duration-function. Had to change it a bit, cause it didnt work in my environment. Could you please test whether it still works with your videos. Can't test ist, cause mine all deliver hour:minute:second.

I added the "Done" button and it does makes better usability, I think.

On Thing remains: Translation in Dialog. Does this work. I didn't succeed :-(

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Thu, 2011-12-01 22:27

Little Bug fixed.

Sitemenu entry made search-site chrash, cause there is no $item.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-12-01 22:29

here is my working copy.
I have not adopted 4:3 thumbs as I believe that is a step backwards. Videos are predominately captured in widescreen formats these days and I'm not going to force 4:3 on my users.

As stated above I'm only dealing w/ seconds for the time.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-12-01 22:34
Quote:
Sitemenu entry made search-site chrash, cause there is no $item.

I fixed that yesterday http://gallery.menalto.com/node/104422#comment-384650

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-12-02 01:08

Great collaboration guys. Keep up the great work.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Fri, 2011-12-02 03:03

should put a check for if user is admin before displaying option in menus...

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-12-02 03:25

Actually it should not be just for admins but if the user can edit the item:
access::can("edit", $item)

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-12-02 12:40
floridave wrote:
Actually it should not be just for admins but if the user can edit the item:
access::can("edit", $item)

Thanks Dave, updated my above archive.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-12-02 14:06

I added a "working.gif" so you don't wonder what's going on while the thumb is being produced.
And now the thumb is being produced the same dimensions as the original thumb so if your theme is making odd size thumbs, this will keep the aspect - which should solve mr.xy's concerns.
And now vastly faster thumb creation.
Again updated my above archive.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Fri, 2011-12-02 19:39

suprsidr: You forgot the can edit item check in the site menu.

Nice changes!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-12-02 20:11
Quote:
suprsidr: You forgot the can edit item check in the site menu.

fixed!

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Fri, 2011-12-02 20:51

sweet

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Fri, 2011-12-02 22:20

@suprsidr: Still can't say "Good bye" to my minutes and seconds, because players show it that way, when I look through the video for a good thumb.

Thats why I post another separate version that combines yours (suprsidr's) and my work.

We still have 4:3 videos beside 16:9. Thats why I added an option to choose ratio or freely custom the thumb measures.

The module is tested with admin, registered user and guest.

It shows total video-length (min:sec) and offers the possibility to enter time in min:sec.

Thanks suprsidr's small but very effective ffmpeg-call-modification thumb-generation is much more quick and a working.gif is shown in the short time to spend waiting because of that quick thumb-generation :-)

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-12-02 23:30

The reason I had the working.gif set once as display:none was to preload the gif for instant display when it was needed.
This can also be achieved in css as say a background-image for a non-display element or something.

mr.xy wrote:
We still have 4:3 videos beside 16:9. Thats why I added an option to choose ratio or freely custom the thumb measures.

If your videos are 4:3 the thumbs will be also, no need to specify.

mr.xy wrote:
Thanks suprsidr's small but very effective ffmpeg-call-modification...

yes, moving the "seek" to before the input is much faster

http://ffmpeg.org/ffmpeg.html wrote:
‘-ss position (input/output)’

When used as an input option (before -i), seeks in this input file to position. When used as an output option (before an output filename), decodes but discards input until the timestamps reach position. This is slower, but more accurate.

position may be either in seconds or in hh:mm:ss[.xxx] form.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Mon, 2011-12-05 22:53

working.gif and display:none = Cool! Nice little trick - thanks.

Quote:
If your videos are 4:3 the thumbs will be also, no need to specify.

We are using module "Rectangle Thumbnails" with defined 4:3 ratio to standardize the look of the photo- and video- gallery-overviews. Videothumbs at 16:9 are therefore croped and thumbs unfortunately don't tell the original ratio.

I've build in detection of whether the "rectangle thumbs" module is active. If so: thumbs are croped to desired ratio and a info is displayed:
"Module "RectangleThumbs" active - Thumbs may be croped to defined aspect ratio."

This seemed to be usefull to me. We may be not the only G3 using uniformation of thumbs.

Beside this I've integrated a detection of the aspect-ratio of the video, to take this information from the uploaded stuff.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2011-12-05 23:59
Quote:
I've build in detection of whether the "rectangle thumbs" module is active. If so: thumbs are croped to desired ratio and a info is displayed:
"Module "RectangleThumbs" active - Thumbs may be croped to defined aspect ratio."

Again, my version keeps the dimensions of the existing thumb. If the RectangleThumbs modules is active doesn't gallery respect this when the original thumb is created?
If so, then your thumb dimensions are already set and will be kept w/ my version. No need to create extra work.

I'm working on testing the returned duration format to display min:sec or just sec depending on what's returned.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
mr.xy

Joined: 2011-09-20
Posts: 67
Posted: Fri, 2011-12-09 22:51

Existing thumb unfortunatley don't tell the right dimensions for sure, because via rectangle_thumbs they may be cropped. If you upload an 16:9 video and have defined a 4:3 rectangle_thumb, it will be cropped. This is our situation.

A Colleague here told me, that the usability of the module is better than the preceding in G2, cause he don't have to calculate min:sec (showed by player) to sec any more ;-)

Would like to put our work together and start a codex page to finish this project. What do you think (suprsidr)?

Already working on the next module: http://gallery.menalto.com/node/104516

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2012-02-29 17:22

Found an issue with this module and an interference with the 'latestupdates' module.

in the site_menu function of helpers/videothumb_event.php, sometimes (particularly with the latestupdates module) $theme->$item() is not defined, causing an error and the page to fail out (not display)

I fixed by adding in the following (in bold/italic) check, this may not be the most appropriate fix (IANAPC = I am not a php coder)

  static function site_menu($menu, $theme) {
      $item = $theme->item();
      if($item){
        if(access::can("edit", $item) && $item->type == 'movie')
             $menu->get("options_menu")
                ->append(Menu::factory("dialog")
                         ->id("videothumb")
                         ->label(t("Video Thumbnail"))
                         ->css_class("ui-icon-folder-open g-videothumb-link")
                         ->url(url::site("videothumb/dialog/{$item->id}")));
      }
  }
 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2013-01-05 22:06

Comments are now permitted for this topic.

 
syscologne

Joined: 2003-05-20
Posts: 37
Posted: Sun, 2013-01-06 03:52

Hi,

When I switch on the latest Videothumb module, I get an empty login page - only the gallery icon and top bar is shown, without a login link or anything else.
Not sure whether I should post this under modules or here...

Log file not mentioning any issue for this.

Error is 100% reproducable for me - tried 2 servers with two versions of Ubuntu LTS (8,10) and stock apache/php/mysql versions.
Switch on: login page not shown / switch off: all fine

Would this be fixed by jnash's change? Will this fix find its way into a new version of the module so that other new users do not need to find this thread and then fix it themselves?

Thanks

 
syscologne

Joined: 2003-05-20
Posts: 37
Posted: Sun, 2013-01-06 05:53

Solution of jnash seems to fix my issue.

However, I have another issue - Videothumb does not work for me. I type in the seconds and the little picture does not change but still shows me the same thumb as before...
Log file is empty.

Any ideas?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2013-01-06 13:48

Do you have a valid ffmpeg binary on your server?
if so what version?

in a shell type:
ffmpeg -version

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
syscologne

Joined: 2003-05-20
Posts: 37
Posted: Sun, 2013-01-13 20:17

I have the standard Ubuntu lucid version of it - video transcode module works fine without error
(please see my other post though - thumbnails of avi clips are not found by kohana proxy, others work fine...)

Quote:
# ffmpeg -version
FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.2, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --extra-version=4:0.5.9-0ubuntu0.10.04.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Dec 18 2012 18:08:11, gcc: 4.4.3
FFmpeg SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.2
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2013-01-13 20:23
Quote:
thumbnails of avi clips are not found

avi is not supported by G3

Looks like you have an old version of ffmpeg please update to one from this decade

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
syscologne

Joined: 2003-05-20
Posts: 37
Posted: Sat, 2013-01-19 02:33

That any better?

Quote:
ffmpeg version git-2013-01-19-2dc2e4f
built on Jan 19 2013 03:18:37 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3
libavutil 52. 15.100 / 52. 15.100
libavcodec 54. 89.100 / 54. 89.100
libavformat 54. 61.101 / 54. 61.101
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 32.101 / 3. 32.101
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2013-01-19 02:42

The ffmpeg command to produce a thumbnail changed in ffmpeg version ~0.6 or 0.7 I cannot remember. So yes it should work now.

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
syscologne

Joined: 2003-05-20
Posts: 37
Posted: Sat, 2013-01-19 02:54

Now seems to work. For anybody experiencing the same issue:

I used this great tutorial:

https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuideLucid

Worked like a charm. Please note that I tried the some under Ubuntu version 8 instead of 10 - and it did not work. Under Lucid though everything works fine.