<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.da.vidr.cc/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">

    <title>David A Roberts</title>
    
    <link href="http://da.vidr.cc/" />
    <updated>2010-07-27T17:13:27+10:00</updated>
    <id>http://da.vidr.cc/</id>
    <author>
        <name>David A Roberts</name>
        <email>d@vidr.cc</email>
    </author>

    
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.da.vidr.cc/DavidRobertsBlog" /><feedburner:info uri="davidrobertsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
        <title>Reverse Engineering the Brother MFC-7400C</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/UBrkH70LJ_k/" />
        <updated>2010-07-17T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2010/07/17/reverse-engineering-the-brother-mfc-7400c</id>
        <content type="html">&lt;p&gt;I have an old Brother MFC-7400C, which doesn't work as a printer or fax machine anymore, but the document feeder makes it useful for scanning multi-page documents. Unfortunately, it doesn't seem to be supported under Linux, so I figured I'd try writing my own implementation by reverse engineering the scanning protocol.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://pcausa.com/Utilities/UsbSnoop/"&gt;SniffUSB&lt;/a&gt; was used for analysing the USB traffic. By obtaining logs whilst various operations are performed with the scanner, it is possible to determine the characteristics of the protocol relatively easily.&lt;/p&gt;

&lt;h3&gt;Reading the SniffUSB Logs&lt;/h3&gt;

&lt;p&gt;&lt;img src="http://github.com/davidar/mfc7400c/raw/master/usb-logs/screenshot.png" alt="SniffUSB screenshot" /&gt;&lt;/p&gt;

&lt;p&gt;After installing the filter, logs were obtained for device initialisation, scanning with default settings with 0, 1, and 2 pages in the document feeder, as well as scanning with various other setting configurations with no pages in the feeder. After this, it is a matter of extracting the relevant information (the &lt;a href="http://libusb.sourceforge.net/api-1.0/"&gt;libusb Documentation&lt;/a&gt; and the &lt;a href="http://www.usb.org/developers/docs/"&gt;USB 2.0 Specification&lt;/a&gt;, particularly sections 9.3 and 9.6, come in handy here). For example, in the following snippet of a control transfer:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;[136533 ms]  &amp;gt;&amp;gt;&amp;gt;  URB 277 going down  &amp;gt;&amp;gt;&amp;gt; 
-- URB_FUNCTION_VENDOR_DEVICE:
  TransferFlags          = 00000003 (USBD_TRANSFER_DIRECTION_IN, USBD_SHORT_TRANSFER_OK)
  TransferBufferLength = 000000ff
  Request                 = 00000001
  Value                   = 00000002
  Index                   = 00000000
[136535 ms]  &amp;lt;&amp;lt;&amp;lt;  URB 277 coming back  &amp;lt;&amp;lt;&amp;lt; 
-- URB_FUNCTION_CONTROL_TRANSFER:
  TransferBufferMDL    = 81d6bc88
    00000000: 05 10 01 02 00
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;The following request characteristics can be extracted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data transfer direction = Device-to-host (IN)&lt;/li&gt;
&lt;li&gt;Type = Vendor&lt;/li&gt;
&lt;li&gt;Recipient = Device&lt;/li&gt;
&lt;li&gt;Request = 0x01&lt;/li&gt;
&lt;li&gt;Value = 0x02&lt;/li&gt;
&lt;li&gt;Index = 0x00&lt;/li&gt;
&lt;li&gt;Length = 0xff&lt;/li&gt;
&lt;li&gt;Device responds 0x05 0x10 0x01 0x02 0x00&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;With libusb, this can be performed via the following call:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="c"&gt;&lt;span class="n"&gt;NUM_BYTES_READ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;libusb_control_transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DEVICE_HANDLE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LIBUSB_ENDPOINT_IN&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="n"&gt;LIBUSB_REQUEST_TYPE_VENDOR&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="n"&gt;LIBUSB_RECIPIENT_DEVICE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="mh"&gt;0x01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BUFFER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/* BUFFER = { 0x05, 0x10, 0x01, 0x02, 0x00 } */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Similarly, the following outbound bulk transfer to endpoint number 3, with equivalent C code:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;[692026 ms]  &amp;gt;&amp;gt;&amp;gt;  URB 3034 going down  &amp;gt;&amp;gt;&amp;gt; 
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
  PipeHandle           = 81d0d24c [endpoint 0x00000003]
  TransferFlags        = 00000002 (USBD_TRANSFER_DIRECTION_OUT, USBD_SHORT_TRANSFER_OK)
  TransferBufferLength = 00000004
  TransferBuffer       = 00000000
  TransferBufferMDL    = 81e773b8
    00000000: 1b 58 0a 80
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="c"&gt;&lt;span class="n"&gt;BUFFER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mh"&gt;0x1b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x58&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x80&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="n"&gt;libusb_bulk_transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DEVICE_HANDLE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LIBUSB_ENDPOINT_OUT&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x03&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;BUFFER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x04&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;NUM_BYTES_SENT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;And an inbound bulk transfer on endpoint number 4:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;[137544 ms]  &amp;gt;&amp;gt;&amp;gt;  URB 284 going down  &amp;gt;&amp;gt;&amp;gt; 
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
  PipeHandle           = 81d0d26c [endpoint 0x00000084]
  TransferFlags        = 00000003 (USBD_TRANSFER_DIRECTION_IN, USBD_SHORT_TRANSFER_OK)
  TransferBufferLength = 00001000
[137545 ms]  &amp;lt;&amp;lt;&amp;lt;  URB 284 coming back  &amp;lt;&amp;lt;&amp;lt; 
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
  TransferBufferLength = 00000002
  TransferBufferMDL    = 81cf9dd0
    00000000: c2 00
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="c"&gt;&lt;span class="n"&gt;libusb_bulk_transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DEVICE_HANDLE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LIBUSB_ENDPOINT_IN&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x04&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;BUFFER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;NUM_BYTES_READ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/* BUFFER = { 0xc2, 0x00 } */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;From this, the following protocol characteristics can be determined:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;While idling a control transfer is sent every 500ms (type=3,value=0,index=0,length=255), to which the device responds 0x04100300&lt;/li&gt;
&lt;li&gt;Scanning is initiated with control transfer (type=1,value=2,index=0,length=255), device responds 0x0510010200&lt;/li&gt;
&lt;li&gt;Configuration data sent to scanner with outbound bulk transfer (endpoint=3)&lt;/li&gt;
&lt;li&gt;Image data is read from the scanner with inbound bulk transfer (endpoint=4,length=0x1000)&lt;/li&gt;
&lt;li&gt;Scanning is ended with control transfer (type=2,value=2,index=0,length=255), device responds 0x0510020200&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;Configuration Data&lt;/h3&gt;

&lt;p&gt;The configuration data is an ASCII key=value string, which can be decoded with a few lines of Python:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="python"&gt;&lt;span class="c"&gt;# set dump to hexdump of configuration data&lt;/span&gt;
&lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dump&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;: &amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;byte&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;chr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="nb"&gt;repr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Correlating various configurations with their respective configuration strings yields the following pattern: the string always begins with "\x1bX\n", followed by 7 key=value pairs each terminated by "\n", followed by "\x80". The following key=value combinations are available:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;R=X_RESOLUTION,Y_RESOLUTION (where both resolutions must be a multiple of 100, with the x- and y-resolutions capped at 300 and 600 respectively)&lt;/li&gt;
&lt;li&gt;M=CGRAY (color mode), M=GRAY64 (grey-scale mode), M=TEXT (text mode)&lt;/li&gt;
&lt;li&gt;C=RLENGTH (run-length encoding?), C=NONE (uncompressed)&lt;/li&gt;
&lt;li&gt;B=100&lt;/li&gt;
&lt;li&gt;N=100&lt;/li&gt;
&lt;li&gt;U=OFF&lt;/li&gt;
&lt;li&gt;A=0,0,WIDTH,HEIGHT&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Raw Image Data&lt;/h3&gt;

&lt;p&gt;Inbound bulk transfers usually contain a payload of raw image data, but the following message can also be received:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;empty payload: wait 200ms and try again&lt;/li&gt;
&lt;li&gt;0xc200: there is nothing to scan&lt;/li&gt;
&lt;li&gt;0x80: finished scanning the page, no more pages&lt;/li&gt;
&lt;li&gt;0x81: finished scanning the page, another page ready (in which case an empty configuration string is sent ("\x1bX\n\x80"), and the next page is scanned)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The uncompressed raw image data is relatively easy to decode. The following snippet shows a color scan of an 816 (0x330) pixel wide plain white image.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;00000000: 44 30 03 fd fd fd fd fd fd fd fd fd fd fd fd fd
00000010: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
...
00000320: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
00000330: fd fd fd 48 30 03 fd fd fd fd fd fd fd fd fd fd
00000340: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
...
00000650: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
00000660: fd fd fd fd fd fd 4c 30 03 fc fc fc fc fc fc fc
00000670: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
...
00000980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
00000990: fc fc fc fc fc fc fc fc fc 44 30 03 fd fd fd fd
000009a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
...
00000cb0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
00000cc0: fd fd fd fd fd fd fd fd fd fd fd fd 48 30 03 fd
00000cd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;It can be seen that the data consists of a series of 816-byte rows each prefixed with a 3 byte header. The first byte of the header describes the type of the row (0x40=gray, 0x44=red, 0x48=green, 0x4c=blue), and the following two bytes describe the length of the row in little-endian format.&lt;/p&gt;

&lt;h3&gt;Protocol Implementation&lt;/h3&gt;

&lt;p&gt;Having gathered the necessary information, two C programs were written for communicating with the device and converting the raw image data to PNM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://github.com/davidar/mfc7400c/blob/master/scan.c"&gt;scan.c&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://github.com/davidar/mfc7400c/blob/master/raw2pnm.c"&gt;raw2pnm.c&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
    <feedburner:origLink>http://da.vidr.cc/2010/07/17/reverse-engineering-the-brother-mfc-7400c/</feedburner:origLink></entry>
    
    <entry>
        <title>LLJVM 0.2: C to JVM Bytecode Compiler</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/YhT-WcJpRTM/" />
        <updated>2009-12-31T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2009/12/31/lljvm-02-c-to-jvm-bytecode-compiler</id>
        <content type="html">&lt;p&gt;LLJVM 0.2 has been released. Currently, there are 6 software packages known to work with LLJVM (7 including &lt;a href="http://sourceware.org/newlib/"&gt;newlib&lt;/a&gt;): &lt;a href="http://ijg.org/"&gt;libjpeg&lt;/a&gt;, &lt;a href="http://zlib.net/"&gt;zlib&lt;/a&gt;, &lt;a href="http://libpng.org/"&gt;libpng&lt;/a&gt;, &lt;a href="http://www.lua.org/"&gt;lua&lt;/a&gt;, &lt;a href="http://www.ccs.neu.edu/home/ramsdell/tools/datalog/"&gt;datalog&lt;/a&gt;, and several utilities (banner, morse, number, pig) from &lt;a href="http://wiki.linuxquestions.org/wiki/BSD_games"&gt;bsd-games&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For further information, including a pre-compiled demonstration of the above packages, see the &lt;a href="http://da.vidr.cc/projects/lljvm/"&gt;project page&lt;/a&gt;.&lt;/p&gt;
</content>
    <feedburner:origLink>http://da.vidr.cc/2009/12/31/lljvm-02-c-to-jvm-bytecode-compiler/</feedburner:origLink></entry>
    
    <entry>
        <title>Open source Photosynth: PixelStruct 0.2 released</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/pG7-xLPz-aQ/" />
        <updated>2009-09-18T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2009/09/18/open-source-photosynth-pixelstruct-02-released</id>
        <content type="html">&lt;p&gt;PixelStruct 0.2 has been released. This version has two main changes from the previous version. Firstly, several new transition modes are available, allowing near seamless transition between photos. Secondly, various bugs have been fixed, allowing larger image sets to be viewed, such as the following 715-image reconstruction of Notre Dame.&lt;/p&gt;

&lt;p&gt;For more information, including download links, please see the &lt;a href="http://da.vidr.cc/projects/pixelstruct/"&gt;project homepage&lt;/a&gt;.&lt;/p&gt;

&lt;div class="align-center prepend-top append-bottom"&gt;
&lt;object type="application/x-shockwave-flash" class="youtube-video" data="http://www.youtube.com/v/VFdNQc3gVkM"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/VFdNQc3gVkM" /&gt;
&lt;/object&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2009/09/18/open-source-photosynth-pixelstruct-02-released/</feedburner:origLink></entry>
    
    <entry>
        <title>Converting videos to 3GP in Ubuntu Intrepid 8.10 with FFmpeg</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/djq8NVml2Yw/" />
        <updated>2009-02-28T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2009/02/28/converting-videos-to-3gp-in-ubuntu-intrepid-810-with-ffmpeg</id>
        <content type="html">&lt;p&gt;The default installation of FFmpeg in Ubuntu Intrepid 8.10 doesn't support conversion to 3GP. According to &lt;a href="https://bugs.launchpad.net/medibuntu/+bug/291011/comments/1"&gt;this&lt;/a&gt;, installing ubuntu-restricted-extras should fix this, but that didn't work in my case. So, you may need to manually install the required packages:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;sudo aptitude install &lt;span class="se"&gt;\&lt;/span&gt;
libavcodec-unstripped-51 &lt;span class="se"&gt;\&lt;/span&gt;
libavdevice-unstripped-52 &lt;span class="se"&gt;\&lt;/span&gt;
libavformat-unstripped-52 &lt;span class="se"&gt;\&lt;/span&gt;
libavutil-unstripped-49 &lt;span class="se"&gt;\&lt;/span&gt;
libpostproc-unstripped-51 &lt;span class="se"&gt;\&lt;/span&gt;
libswscale-unstripped-0
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Then, to convert a video, you can either go the command-line route:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;ffmpeg -i input.mpg &lt;span class="se"&gt;\&lt;/span&gt;
-vcodec h263 -s qcif -r 15 -b 100k &lt;span class="se"&gt;\&lt;/span&gt;
-acodec libfaac -ac 1 -ar 32000 -ab 64k &lt;span class="se"&gt;\&lt;/span&gt;
output.3gp
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Which will convert to input.mpg to output.3gp with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;H.263 video codec&lt;/li&gt;
&lt;li&gt;QCIF video resolution (176x144)&lt;/li&gt;
&lt;li&gt;15fps&lt;/li&gt;
&lt;li&gt;100 kb/s video bitrate&lt;/li&gt;
&lt;li&gt;AAC audio codec (through libfaac)&lt;/li&gt;
&lt;li&gt;1 audio channel&lt;/li&gt;
&lt;li&gt;32000 Hz audio sampling frequency&lt;/li&gt;
&lt;li&gt;64 kb/s audio bitrate&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Alternatively, if you prefer using a GUI, you can try &lt;a href="http://www.miksoft.net/mobileMediaConverter.htm"&gt;Mobile Media Converter&lt;/a&gt; (&lt;a href="http://www.miksoft.net/products/mmc_1.4.1_i386.deb"&gt;direct link to v.1.4.1 .deb&lt;/a&gt;), which seems to work pretty well, and also supports downloading videos directly from YouTube.&lt;/p&gt;
</content>
    <feedburner:origLink>http://da.vidr.cc/2009/02/28/converting-videos-to-3gp-in-ubuntu-intrepid-810-with-ffmpeg/</feedburner:origLink></entry>
    
    <entry>
        <title>Command-line scanning</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/VJDY6htdPsc/" />
        <updated>2008-12-07T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2008/12/07/command-line-scanning</id>
        <content type="html">&lt;p&gt;First you need to find the ID of the required device:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;scanimage -L
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Output:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;device `v4l:/dev/video0' is a Noname Acer CrystalEye webcam virtual device
device `net:linux-box.local:hpaio:/usb/Photosmart_C4100_series?serial=XXXXXXXXXXXXXX' is a Hewlett-Packard Photosmart_C4100_series all-in-one
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In this case the device ID is net:linux-box.local:hpaio:/usb/Photosmart_C4100_series?serial=XXXXXXXXXXXXXX Then, for colour scanning:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;scanimage -d &lt;span class="s2"&gt;&amp;quot;net:linux-box.local:hpaio:/usb/Photosmart_C4100_series?serial=XXXXXXXXXXXXXX&amp;quot;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
--mode Color --resolution 300dpi | pnmtopng - &amp;gt; image.png
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Or for greyscale scanning:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;scanimage -d &lt;span class="s2"&gt;&amp;quot;net:linux-box.local:hpaio:/usb/Photosmart_C4100_series?serial=XXXXXXXXXXXXXX&amp;quot;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
--mode Gray --resolution 300dpi | pnmtopng - &amp;gt; image.png
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2008/12/07/command-line-scanning/</feedburner:origLink></entry>
    
    <entry>
        <title>Spellchecking LaTeX documents</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/r_TsQT80knI/" />
        <updated>2008-09-29T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2008/09/29/spellchecking-latex-documents</id>
        <content type="html">&lt;p&gt;To spellcheck a LaTeX document, run the following command (replacing 'file.tex' with the name of your document):&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;aspell -a -t &amp;lt; &lt;span class="s1"&gt;&amp;#39;file.tex&amp;#39;&lt;/span&gt; | grep &lt;span class="s2"&gt;&amp;quot;&amp;amp;&amp;quot;&lt;/span&gt; | sort -u
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2008/09/29/spellchecking-latex-documents/</feedburner:origLink></entry>
    
    <entry>
        <title>Setting paper size and margins in LaTeX</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/sOIKZJG4qhU/" />
        <updated>2008-09-29T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2008/09/29/setting-paper-size-and-margins-in-latex</id>
        <content type="html">&lt;p&gt;Personally I dislike the large margins LaTeX defaults to. Adding the following line to the preamble allows you to adjust these (as well as setting the paper size):&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="latex"&gt;&lt;span class="k"&gt;\usepackage&lt;/span&gt;&lt;span class="na"&gt;[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm]&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;geometry&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2008/09/29/setting-paper-size-and-margins-in-latex/</feedburner:origLink></entry>
    
    <entry>
        <title>Removing borders around links when using hyperref</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/SGf9ykRG-uw/" />
        <updated>2008-09-29T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2008/09/29/removing-borders-around-links-when-using-hyperref</id>
        <content type="html">&lt;p&gt;By default, the hyperref package adds borders around links in the document. Adding the following lines to your preamble fixes this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="latex"&gt;&lt;span class="k"&gt;\hypersetup&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;colorlinks,
 linkcolor=black,
 filecolor=black,
 urlcolor=black,
 citecolor=black
&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2008/09/29/removing-borders-around-links-when-using-hyperref/</feedburner:origLink></entry>
    
    <entry>
        <title>Printing the 'therefore' symbol in LaTeX</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/-6Nc-6HHvC4/" />
        <updated>2008-09-29T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2008/09/29/printing-the-therefore-symbol-in-latex</id>
        <content type="html">&lt;p&gt;The &lt;a href="http://www.ams.org/tex/amslatex.html"&gt;AMS&lt;/a&gt; packages provide this functionality (as well as many other things). Add the following lines to the preamble:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="latex"&gt;&lt;span class="k"&gt;\usepackage&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;amsmath&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\usepackage&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;amsfonts&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\usepackage&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;amssymb&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Then the therefore symbol can be used:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="latex"&gt;&lt;span class="s"&gt;$&lt;/span&gt;&lt;span class="nb"&gt; ... &lt;/span&gt;&lt;span class="nv"&gt;\therefore&lt;/span&gt;&lt;span class="nb"&gt; ... &lt;/span&gt;&lt;span class="s"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2008/09/29/printing-the-therefore-symbol-in-latex/</feedburner:origLink></entry>
    
    <entry>
        <title>Indenting only subsequent lines in paragraphs in LaTeX</title>
        <link href="http://feeds.da.vidr.cc/~r/DavidRobertsBlog/~3/mKj922Zv6RA/" />
        <updated>2008-09-29T00:00:00+10:00</updated>
        <id>http://da.vidr.cc/2008/09/29/indenting-only-subsequent-lines-in-paragraphs-in-latex</id>
        <content type="html">&lt;p&gt;In order to remove the indent at the beginning of paragraphs, and indent subsequent lines if present, add the following to your preamble:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="latex"&gt;&lt;span class="k"&gt;\newcommand&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\hangpara&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;
 &lt;span class="k"&gt;\setlength&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\parindent&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;0cm&lt;span class="nb"&gt;}&lt;/span&gt; &lt;span class="c"&gt;% don&amp;#39;t indent new paragraphs&lt;/span&gt;
 &lt;span class="k"&gt;\hangindent&lt;/span&gt;=0.7cm &lt;span class="c"&gt;% indent all subsequent lines&lt;/span&gt;
&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Then add \hangpara before each new paragraph, for example:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="latex"&gt;&lt;span class="k"&gt;\hangpara&lt;/span&gt;
The quick brown fox jumps over the lazy dog.

&lt;span class="k"&gt;\hangpara&lt;/span&gt;
The quick brown fox jumps over the lazy dog again.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
    <feedburner:origLink>http://da.vidr.cc/2008/09/29/indenting-only-subsequent-lines-in-paragraphs-in-latex/</feedburner:origLink></entry>
    

</feed>
