Monday, December 22, 2014

Install libva-intel-driver to get HW acceleration of VLC player enabled

Today I installed Fedora 21 and updated to latest after adding RPMFusion repo.
However when I played a HD video using VLC player, it seemed that HW acceleration in VLC didn't work.
I executed vainfo command to check the  vaapi status and got some error messages.

[root@student ~]# vainfo 
error: XDG_RUNTIME_DIR not set in the environment.
libva info: VA-API version 0.36.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

After searching google for a solution, I found that installing "libva-intel-driver" package fixes the issue.

[root@student ~]# vainfo 
error: XDG_RUNTIME_DIR not set in the environment.
libva info: VA-API version 0.36.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_36
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.36 (libva 1.4.1)
vainfo: Driver version: Intel i965 driver 
for Intel(R) Haswell Desktop - 1.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice

Now VLC player uses HW acceleration and the CPU utilization is well under 10%  when a HD video is played. 
I tried selecting "VA-API video decoder via X11" and "VA-API video decoder via DRM" options available under "Hardware-accelerated decoding" in "Input & Codecs Settings" of VLC. It seemed the CPU utilization is almost same for both the methods.

Sunday, December 7, 2014

Get information about movies using perl IMDB::Film module


I got a 3 TB hard disk with a bunch of movies and I wanted to keep all the movies where the IMDB rating is greater than 7 removing all the others. Since there were hundreds of movies, I thought of automating the task.

When I Googled to find out an easier method, I found an article (http://davide.eynard.it/2011/01/20/perl-hacks-automatically-get-info-about-a-movie-from-imdb/) that describes how useful the IMDB::Film (http://search.cpan.org/~stepanov/IMDB-Film-0.53/lib/IMDB/Film.pm) perl module is for my task.

So I wrote a simple Perl script which reads movie title (in <movie name><year><other information> format) from STDIN and prints selected information about the movie to STDOUT.

e.g.:
root@LS-VL406:~/IMDB_Reader# echo 'Star Trek Into Darkness 2013 BRRip XviD AC3-SANTi' | ./GetMovieInfo.pl                     
Star Trek Into Darkness 2013 BRRip XviD AC3-SANTi,Star Trek Into Darkness,2013,movie,7.9,When the crew of the Enterprise is called back home, they find an unstoppable force of terror from within their own organization has detonated the fleet and everything it stands for, leaving our world in a state of crisis. With a personal score to settle, Captain Kirk leads a manhunt to a war-zone world to capture a one-man weapon of mass destruction. As our heroes are propelled into an epic chess game of life and death, love will be challenged, friendships will be torn apart, and sacrifices must be made for the only family Kirk has left: his crew.


This is a very simple Perl script so anyone can modify the script to add whatever information is required for a movie. Also it reads input from STDIN and prints output to STDOUT so that the unix pipe can be used for various pre and post processing such as read a movie list from a file and pipe it to the script.

I have tested this on a system which runs Fedora 20 on it and also on Buffalo linkstation NAS.

The script can be downloaded from here, All the required perl modules are included so that the user does not need to install any additional Perl modules.

https://sites.google.com/site/blogswapoff/IMDB_Reader.tar.gz


Thursday, September 4, 2014

Mount ntfs formatted external harddisk on buffalo linkstation ls vl to read and write

When an external harddisk is connected to the usb port, the hard disk gets automatically mounted in read only mode.
When it is manually mounted, the mount options show it is mounted with rw option but actually it has no write permissions.

Solution: Install ntfs-3g.

1. Install the required package via ipkg,

root@LS-VL406:~# ipkg install ntfs-3g

Installing ntfs-3g (2009.4.4-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/ntfs-3g_2009.4.4-1_arm.ipk
ntfs-3g: unsatisfied recommendation for kernel-module-fuse
Configuring ntfs-3g
Successfully terminated.


2. Tried to mount the disk using -t option. But it didn't work. Calling ntfs-3g directly worked.

root@LS-VL406:~# mount -t ntfs-3g /dev/sdb1 /mnt/usbdisk1/
mount: mounting /dev/sdb1 on /mnt/usbdisk1/ failed: No such device

root@LS-VL406:~# ntfs-3g /dev/sdb1 /mnt/usbdisk1/

However it was observed that the above command was taking over 80% CPU when I copied files from a local disk to the usb disk.
output of the top command while copying files,

Mem: 235884K used, 12648K free, 0K shrd, 54588K buff, 143488K cached
CPU:  43% usr  53% sys   0% nice   0% idle   0% io   0% irq   3% softirq
Load average: 1.11 0.51 0.24
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
 3200     1 root     R     2484   1%  84% ntfs-3g /dev/sdb1 /mnt/usbdisk1/

Sunday, August 10, 2014

Install transmission on opened linkstation

Note: More detailed instructions are available at http://forum.nas-hilfe.de/buffalo-technology-nas-anleitungen/transmission-auf-der-linkstation-live-und-pro-ls-chlv2-ls-xhl-ls-vl-mit-rotem-webinterface-t749.html

Remove existing optware first (If there are any) and then install it,

rm -rf /mnt/disk1/.optware
rm -rf /usr/lib/ipkg
cd /tmp
wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/ls-mvkw-bootstrap_1.2-7_arm.xsh
sh ./ls-mvkw-bootstrap_1.2-7_arm.xsh
mv /etc/init.d/optware /etc/init.d/rc.optware
ipkg update

I installed an old version of transmission as I need proxy functionality. Proxy functionality has been removed in newer versions.

ipkg install /mnt/disk1/share/transmission_1.92-1_arm.ipk

Installing transmission (1.92-1) to root...
Installing openssl (0.9.8v-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/openssl_0.9.8v-2_arm.ipk
Installing libcurl (7.24.0-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/libcurl_7.24.0-1_arm.ipk
Installing zlib (1.2.5-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/zlib_1.2.5-1_arm.ipk
Installing libevent (2.0.20-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/libevent_2.0.20-1_arm.ipk
Configuring libcurl
Configuring libevent
Configuring openssl
Configuring transmission
Configuring zlib
Successfully terminated.

Create start up and kill scripts,

update: if S95transmission.sh startup script does not get executed, when the linkstation is rebooted please refer to this blog post. http://swapoff.blogspot.com/2015/02/fix-optetcinitd-scripts-not-executing.html

echo '/opt/bin/transmission-daemon -g /mnt/disk1/share/.config/transmission-daemon' >/opt/etc/init.d/S95transmission.sh
chmod 755 /opt/etc/init.d/S95transmission.sh
echo 'killall /opt/bin/transmission-daemon' >/etc/rc.d/extensions.d/K05transmission.sh
chmod 755 /etc/rc.d/extensions.d/K05transmission.sh


Create required directories for transmission,

mkdir /mnt/disk1/share/downloads
chmod -R 775 /mnt/disk1/share/downloads
mkdir /mnt/disk1/share/incomplete
chmod -R 775 /mnt/disk1/share/incomplete


Execute S95transmission.sh to start transmission,

/opt/etc/init.d/S95transmission.sh
/opt/bin/transmission-daemon: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

If transmission requires older libevent libs, install them manually,

cd /
tar -xvf /mnt/disk1/share/libevent_1.4.13-1_arm.tar.gz

Try to start transmission again.

/opt/etc/init.d/S95transmission.sh
/opt/bin/transmission-daemon: error while loading shared libraries: libssl.so.0.9.7: cannot open shared object file: No such file or directory

If transmission requires openssh 0.9.7 and if you can't find the libraries just copy 0.9.8 libraries as 0.9.7 libraries or just create symbolic links.

cd /opt/lib/

cp libssl.so.0.9.8 libssl.so.0.9.7
cp libcrypto.so.0.9.8 libcrypto.so.0.9.7

or

ln -s libssl.so /opt/lib/libssl.so.0.9.7
ln -s libcrypto.so /opt/lib/libcrypto.so.0.9.7

You should be able to start transmission now. Transmission will create it's own configuration files and folders once it is started.
Now it's time to configure settings.json file. You have to stop transmission daemon before editing this file.

kill transmission daemon

killall transmission-daemon

Edit settings.json file with your requirements. You can find more information about the parameters in this configuration file from https://trac.transmissionbt.com/wiki/EditConfigFiles link.

cd /mnt/disk1/share/.config/transmission-daemon
cp settings.json settings.json.bk

After doing the changes, here is the diff of my old and new configuration files,

diff -b  settings.json.bk settings.json  
--- settings.json.bk Sat Aug  9 18:56:00 2014
+++ settings.json Sat Aug  9 19:03:26 2014
@@ -9,11 +9,11 @@
     "bind-address-ipv4": "0.0.0.0", 
     "bind-address-ipv6": "::", 
     "blocklist-enabled": false, 
-    "dht-enabled": true, 
-    "download-dir": "\/root\/Downloads", 
+    "dht-enabled": false, 
+    "download-dir": "\/mnt\/disk1\/share\/downloads", 
     "encryption": 0, 
-    "incomplete-dir": "\/mnt\/disk1\/share\/.config\/transmission-daemon\/Incomplete", 
-    "incomplete-dir-enabled": false, 
+    "incomplete-dir": "\/mnt\/disk1\/share\/incomplete", 
+    "incomplete-dir-enabled": true, 
     "lazy-bitfield-enabled": true, 
     "message-level": 2, 
     "open-file-limit": 32, 
@@ -40,15 +40,15 @@
     "rpc-authentication-required": false, 
     "rpc-bind-address": "0.0.0.0", 
     "rpc-enabled": true, 
-    "rpc-password": "{37368ecab1a25447ef72869757670b0843a11af2ng37XPZL", 
+    "rpc-password": "password", 
     "rpc-port": 9091, 
-    "rpc-username": "", 
-    "rpc-whitelist": "127.0.0.1", 
+    "rpc-username": "admin", 
+    "rpc-whitelist": "*.*.*.*", 
     "rpc-whitelist-enabled": true, 
     "speed-limit-down": 100, 
     "speed-limit-down-enabled": false, 
     "speed-limit-up": 100, 
     "speed-limit-up-enabled": false, 
-    "umask": 18, 
+    "umask": 2, 
     "upload-slots-per-torrent": 14
 }

umask changed to 2 so that newly created files by transmission will have rw permission.

umask explanation from  https://trac.transmissionbt.com/wiki/EditConfigFiles,

umask: Number (default = 18) Sets transmission's file mode creation mask. See ​the umask(2) manpage for more information. Users who want their saved torrents to be world-writable may want to set this value to 0. Bear in mind that the json markup language only accepts numbers in base 10, so the standard umask(2) octal notation "022" is written in settings.json as 18.

below command is useful to convert octal number to base 10 number,
echo $(( 8#002 ))

Tuesday, August 5, 2014

log in to buffalo nas ls vl 1 TB as root

More detailed information can be found at http://buffalo.nas-central.org/wiki/Open_Stock_Firmware_LS-VL

If below error is shown by acp_commander, try plugging  in NAS ethernet cable to a different ethernet port in router.

A SocketTimeoutException usually indicates bad firewall settings.
Check especially for *UDP* port 22936 and make sure that the connection to your LS is working.
ERROR: Exception: SocketTimeoutException (Receive timed out) [ACP Send/Receive (Packet:8020 = ACP_Discover)]

1. Reset root password to abc123

java -jar acp_commander.jar  -t 192.168.1.3 -ip 192.168.1.3 -pw password -c "(echo abc123; echo abc123) | passwd"

2. Backup sshd_config file

java -jar acp_commander.jar  -t 192.168.1.3 -ip 192.168.1.3 -pw password -c "cp -p /etc/sshd_config /etc/sshd_config.orig"

3. Change PermitRootLogin to yes

java -jar acp_commander.jar  -t 192.168.1.3 -ip 192.168.1.3 -pw password -c "sed -i '/PermitRootLogin/s/no/yes/' /etc/sshd_config"

4. Restart sshd  service

java -jar acp_commander.jar  -t 192.168.1.3 -ip 192.168.1.3 -pw password -c "/etc/init.d/sshd.sh restart"


Information about the tested system,

from dmesg output or cat /proc/version,
Linux version 3.3.4-88f6281 (root@build2.dd-hot24.nas.buffalo.local) (gcc version 4.2.0 20070413 (prerelease)) #1 Tue Jul 9 14:48:53 JST 2013

from uname -a output,
Linux LS-VL406 3.3.4-88f6281 #1 Tue Jul 9 14:48:53 JST 2013 armv5tel unknown