ranger-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ranger-users] Video files: thumbnail previews


From: niku
Subject: Re: [Ranger-users] Video files: thumbnail previews
Date: Fri, 26 Jul 2013 16:40:34 +0530
User-agent: Mutt/1.5.21 (2010-09-15)

I have attached a git patch with Germain Zouein changes. I have taken
the author and date strings for the format-patch from Germain’s latest
message to the list. (The patch contains Germain’s changes exactly, I
have made no changes. It would be useful for the list if Germain would
confirm this.)

When the patch is applied onto a pristine copy of the latest stable
code, I get video previews! To apply the patch, do 
      cat 0001-preview-Video-using-ffmpeg.patch | git apply

My comments: 
1) Nice addition to ranger, Germain!

2) A bug: If ffmpeg fails to extract an image for some reason, the
image previewer (w3mimgdisplay) should never get called. That is, we
should call the image previewer after checking that the file fhash
exists. Right now, an image preview is attempted without making any
check. So, if ffmpeg fails (because, for example, the video file is
corrupt), ranger emits an unhelpful error message:
        failed to execute w3mimgdisplay

3) On my debian system, on every run of ffmpeg I get the following
*coloured* warning in stderr:

      *** THIS PROGRAM IS DEPRECATED ***
      This program is only provided for compatibility and will be 
      removed in a future release. Please use avconv instead.

Since the topic is still fresh, wouldn’t it be best to make the necessary
switch right now?

~niku.


On Sat, Jul 20, 2013 at 03:47:42AM +0300, Germain Zouein wrote:
> Hi,
> 
> I've taken a quick shot at adding previews for video files using
> w3mimgdisplay.
> While it apparently works fine, I'm not certain if I did the right
> thing. Also, there are a few things I don't understand, and hope
> someone can clarify them for me.
> 
>  * core/actions.py (get_preview method, line 797)
>    scope.sh previews are definitely handled here, but I don't
>    understand this (lines 801-803):
>    801 >> if self.settings.preview_images and file.image:
>    802 >>     pager.set_image(path)
>    803 >>     return None
>    I originally thought this is what is called to get previews for
>    image files, but I tried modifying it and it had no effects, then
>    checked out the gui folder and found what I wanted there.
> 
> 
> What I did was the following:
> 
>  * container/file.py:
>    To has_preview (line 64), I added this (lines 76-77) (using an
>    existing option rather than creating a new one):
>    75 >> if self.image and self.fm.settings.preview_images:
>    75 >>     return True
>    76 >> if self.video and self.fm.settings.preview_images:
>    77 >>     return True
>  * gui/widgets/browsercolumn.py:
>    Modified the _draw_file method (line 170) to this (changes: lines
>    185-196):
>    182 >> if self.fm.settings.preview_images and self.target.image:
>    183 >>    self.set_image(self.target.realpath)
>    184 >>    Pager.draw(self)
>    185 >> elif self.fm.settings.preview_image and self.target.video:
>    186 >>     cmd = CommandLoader(["ffmpeg", "-itsoffset", "-10",
>    187 >>                          "-i", self.target.realpath,
>    188 >>                          "-vframes", "1", "-y",
>    "/tmp/thumb.png"],
>    189 >>                          descr="loading preview image",
>    190 >>                          silent=True, kill_on_pause=True)
>    191 >>     def on_after(signal):
>    192 >>         self.set_image('/tmp/thumb.png')
>    193 >>         Pager.draw(self)
>    194 >>     cmd.signal_bind('after', on_after)
>    195 >>     self.fm.loader.add(cmd)
>    196 >>     Pager.draw(self)
>    197 >> else:
>    198 >> ...
> 
> While this approach does works (each preview takes a bit less than
> 1s on my machine), I'm not sure if this is actually the right
> approach to do it, and seeing the preview being set from two places
> still confuses me.
> Also, I'm not sure about caching the result, like it's done for
> normal image/text previews - the thumbnail is currently regenerated
> every time.
> 
> Thanks!
> 

Attachment: 0001-preview-Video-using-ffmpeg.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]