Random notes & other stuff…

…about Linux, electronics, digital photography, whatever…
Icône RSS Icône Accueil
  • File copy snippets

    Posté le 27th septembre 2008 leucos Pas de commentaires

    Useful file copy snippets collection for systems administration. scp is not here : syntax is trivial, and scp is really slow. The snippets below are supposed to be much faster, especially when dealing with many small files.

    netcat style

    • On sender :

    cd to the top dir to be copied recursively, and :

    tar cv . | nc -vq 10 -l -p 1234
    • On receiver :

    cd to the dir where the content has to be copied, and :

    nc -v sender 1234 | tar xf -

    ssh style

    • Data is remote, copy to where I am now :
    ssh user@source "cd /source/dir; tar cv ." | tar x
    • Data is in current directory, copy to remote server :
    tar cv . | ssh user@destination "cd /dest/dir; tar x"

    rsync+ssh style

    • Data is in current directory, copy to remote server :
    rsync -ve ssh -ar . user@destination:/dest/dir/

    Note : add ‘z’ to tar options if link is slow

  • Calculate internal battery resistance

    Posté le 27th septembre 2008 leucos Pas de commentaires

    Battery internal resistance forms a divider with external load.
    So to calculate internal resistance, take those steps :

    • measure the battery voltage without load (Vnoload)
    • measure again with a resistor of RloadΩ attached (the lower ohm value, the better, but watch outfor power ratings !), you have a difference with previous measurement (Vdrop)

    The battery internal resistance is then :

    Rbattery = Vdrop*Rload/(Vdrop+Vnoload)

    Real world example on AA :

    Vnoload = 1.421v
    Rload = 460Ω
    Vdrop = 0.002v

    Thus :

    Rbattery = (0.002 x 460)/(0.002 + 1.421) = 0.65Ω

    Since my metter has a milliVolts resolution, we just have a range between 0.001 and 0.003 for Vdrop.
    So Rbattery can be anything between 0.33Ω and 1Ω.

    Short-circuit current for this AA battery would be somewhere between 1.421/0.33 = 4.33A and 1.421/1 = 1.42A
    Mesasurement made, it is around 4.2A. Watch out for your metter current rating if you do this. Some batteries have a much lower internal resistance.

  • Video snippets

    Posté le 27th septembre 2008 leucos Pas de commentaires

    Few usefull video snippets.

    Grabbing from DV cam, autosplitting scenes :

    dvgrab -- autosplit -timestamp  –format=dv2 video

    Deinterlacing :

    ffmpeg -i in-dv.avi -deinterlace -vcodec huffyuv -pix_fmt yuv422p -target pal-dvd out.avi

    Flv encoding :

    ffmpeg -i input.avi -ar 22050 -ab 64 -aspect 4:3 -b 768k -pass 1 -f flv -s 640x480 -acodec mp3 output.flv

    then again with

    -pass 2

    .

    Another solution :

    mencoder out.avi -o out.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
  • Microchip MCP23S08

    Posté le 27th septembre 2008 leucos Pas de commentaires

    This chip is a 8-bits port expander driven by SPI (or I2C for MCP23008 version).

    Microchip MCP23S08 datasheet