Sunday, December 2, 2012

Canon CanoScan 9000F in Debian Linux

I purchased a Canon CanoScan 9000F scanner, to use with my Debian system. To ensure I would have a smooth time, I went to the Sane project website (http://www.sane-project.org/sane-mfgs.html#Z-CANON) and confirmed that it was fully supported.

Debian version of my system:


lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.6 (squeeze)
Release: 6.0.6
Codename: squeeze

Got the scanner plugged it in, powered it on. dmesg showed it.


[755012.680139] usb 1-8.1.3: new high speed USB device using ehci_hcd and address 96
[755017.773253] usb 1-8.1.3: New USB device found, idVendor=04a9, idProduct=1908
[755017.773260] usb 1-8.1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[755017.773264] usb 1-8.1.3: Product: CanoScan
[755017.773268] usb 1-8.1.3: Manufacturer: Canon
[755017.773411] usb 1-8.1.3: configuration #1 chosen from 1 choice

Good. Tried:

scanimage -L


No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).


which found no scanner, bummer.

Googling around a bit, it turns out the pixma-backend included with Squeeze, doesn't have the required support. So based on this post -> http://permalink.gmane.org/gmane.comp.graphics.scanning.sane.devel/20896, decided to get the backend from the git repository and compile. Needed to get a few packages:



apt-get install git

apt-get install autoconf
apt-get install gcc
apt-get install libusb-dev
apt-get install make

Before, I could do:


cd code/
git clone git://git.debian.org/sane/sane-backends.git
cd sane-backends/
autoconf ( Squeeze has a older version, then what the git repository used, but it worked)
automake
BACKENDS="pixma" ./configure
make
su ( need to be root, for make install and to run ldconfig)
make install

ldconfig -v ( -v is verbose. From man page: will set up the correct links for the shared binaries and rebuild the cache.)

Success. The old version was:


scanimage -V
scanimage (sane-backends) 1.0.21; backend version 1.0.21

After running ldconfig.

scanimage -V
scanimage (sane-backends) 1.0.21; backend version 1.0.24



Now scanimage can detect the scanner.

scanimage -L
device `pixma:04A91908' is a CANON Canoscan 9000F multi-function peripheral

However the xsane front-end has trouble getting access to the scanner, the reason being, udev has the old libsane rules and not the ones we just built. The old rules are in:

/lib/udev/rules.d/60-libsane.rules

The one we just built are ( relative to where git placed them):

sane-backends/tools/udev/libsane.rules

We could either manually copy the lines we care about:

diff -u /lib/udev/rules.d/60-libsane.rules tools/udev/libsane.rules | grep -C 2 9000
+# Canon CanoScan 700F
+ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1907", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
+# Canon CanoScan 9000F
+ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1908", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
+# Canon CanoScan LiDE 110

or as I prefer, replace the old one with the new one.


Now the scanner is usable.



Thursday, May 17, 2012

Video conversion in Linux

My Nikon COOLPIX P300 camera generates h264, 1920x1080 videos in a .mov container. So a 17 second video is over 40 Megabytes. I decided to convert this to a different format, with the aim of reducing the file size.

A quick search led me to ffmpeg. Running that dispalyed a message to use avconv instead.

So on to avconv.

To do a basic conversion, the command is:

avconv -i in_movie.mov out_movie.avi

This however failed with:

[ac3 @ 0x875efa0] invalid bit rate

Turns out, the default bitrate used by avconv is not supported by the default audio codec ( ac3 ) it selected. Sigh.


Solution,  modify the command to use 192k audio bitrate which it support.

avconv -i in_movie.mov -b:a 192k out_movie.avi

This worked. It generated a 3 Megabyte file, which seemed impressive, but the quality sucked since it reduced the video bit rate dramatically.

I decided to move the video bit rate closer to the original video. So the command with video bitrate set to 19000 kbps is

avconv -i in_movie.mov -b 19000k -b:a 192k -out_movie.avi

This got me good video quality but it only reduced the file size by a few Megabytes.

I decided the best reduce the resolution by 1/2 to get a lower file size with good quality video.  That command is

avconv -i in_movie.mov -b 19000k -b:a 192k -s 960x540 out_movie.avi

This reduced the 40+ Megabyte file to a 12 Megabyte file.  Success.