2008年9月13日 星期六

Thunar mplayer thumbnail


Thunar 原本在裝完 Thunar-thumbnailers 後就可以一定程度的預覽不少影像檔(圖片一直都不是這方面的問題),但畢竟還是無法預覽 rmvb ,所以還是靠 mplayer 實在,配置方法請參照:url ##ReadMore##

怕它被洗掉所以在這做個簡記: 建立 /usr/libexec/mplayer-thumbnailer,權限 755:

#!/bin/bash videofile=$(echo "$1" | sed -e 's/%20/ /g' | sed -e 's/%26/\&/g' | sed -e 's/%5B/\[/g' | sed -e 's/%5D/\]/g' | sed -e 's/%40/\@/g' ) # If we only have a chunk, then file will return "data", so we must exit to prevent mplayer from hanging [ "$(/usr/bin/file --brief "$videofile" | grep -e "^data$")" ] && exit thumbfile="$2" LENGTH=$(mplayer -nocache -identify -vo null -ao null -frames 0 "$videofile" | awk -F= '/ID_LENGTH/ {print $2}'| awk -F. '{print $1}') RANDOM=$(date %+s) START=$(((LENGTH / 100) * 15)) ; END=$(((LENGTH / 100) * 70)); LENGTH=$(($END - $START)) ; SHOT=$((($RANDOM % $LENGTH) + $START)) /usr/bin/mplayer -nojoystick -nolirc -nocache -noautosub -nosound -vf scale -vo jpeg:outdir=/tmp:quality=100 -ao null -ss "$SHOT" -frames 3 -zoom -xy 128 -slave "$videofile" mv /tmp/00000002.jpg "$thumbfile" || rm -f /tmp/00000002.jpg rm -f /tmp/00000001.jpg /tmp/00000003.jpg
以及 /usr/share/thumbnailers/video-thumbs.desktop,權限 644:
[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=X-Thumbnailer Name=VIDEO Thumbnailer MimeType=video/x-ms-wmv;video/mpeg;video/x-msvideo;video/quicktime;video/x-ms-asf;application/vnd.rn-realmedia;application/x-flash-video;video/x-matroska;video/mp4 X-Thumbnailer-Exec=/usr/libexec/mplayer-thumbnailer %i %o
然後執行
[user]$ /usr/lib/thunar/thunar-vfs-update-thumbnailers-cache-1 #default [user]$ /usr/lib/xfce4/thunar-vfs-update-thumbnailers-cache-1 #Archlinux
大功告成

沒有留言:

張貼留言