ranger-users
[Top][All Lists]
Advanced

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

[Ranger-users] Video files: thumbnail previews


From: Germain Zouein
Subject: [Ranger-users] Video files: thumbnail previews
Date: Sat, 20 Jul 2013 03:47:42 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

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!


reply via email to

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