2012-04-30 rotating a video using ffmpeg

  • turn to the right

    ffmpeg  -i  2012-04-29\ 19.31.32.mov  -vf "transpose=1" -sameq -y 2012-04-29\ 19.31.32_right.mov
    
  • turn to the left

    ffmpeg -i  2012-04-29\ 19.31.32.mov  -vf "transpose=3" -sameq 2012-04-29\ 19.31.32_left.mov
    
  • upside down

    ffmpeg -i  2012-04-29\ 19.31.32.mov  -vf "transpose=2" -sameq 2012-04-29\ 19.31.32_left.mov
    
  • made some scripts:

    $ vim ~/bin/video_rotate.sh
    $ chmod +x ~/bin/video_rotate.sh
    
    $ cat  ~/bin/video_rotate.sh
    #! /usr/bin/env bash
    ORIGINAL_IFS=$IFS
    IFS=$'\n'
    ffmpeg  -i $1 -v 0  -vf "transpose=$2"  -qscale 0 -y tmp.mov && mv tmp.mov $1
    IFS=$ORIGINAL_IFS
    
    $ video_rotate.sh 2012-04-29_19.31.32.mov 1
    

Comments

2012-04-22 Converting FLAC to AAC (or MP3 to OGG etc...)

  • the solution is http://audiotools.sourceforge.net/

  • installation on MacOsX Lion (with homebrew) :

    brew install libcdio
    brew install lame two-lame mpg123 mp3gain
    brew install libogg libvorbis     vorbis-tools  vorbisgain
    brew install faac faad2
    git clone git://github.com/laurentperrinet/python-audio-tools.git  audio-tools
    cd audio-tools
    make
    make install
    
  • using it:

    track2track  -t aiff *.flac #lossless
    track2track  -q 0 -t m4a *.ogg #lossy
    
  • and on a whole folder, placing the files in the same directory:

    find a_folder/with/lots_of_flac -name *flac -exec sh -c 'echo "Processing $0"; track2track -t aiff  "$0" -o "${0%.flac}.aiff"' {} \;
    find a_folder/with/lots_of_ogg -name *ogg -exec sh -c 'echo "Processing $0"; track2track -t m4a  "$0" -o "${0%.flac}.m4a"' {} \;
    
  • tried as a formula in homebrew: https://github.com/mxcl/homebrew but closed it.

Comments

2012-04-17 transition from movie15.sty to media9.sty

  • recently, a message popped-up :

    Package movie15 Warning: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    (movie15)                @@ Package `movie15' is obsolete and @@
    (movie15)                @@ superseded by `media9'.           @@
    (movie15)                @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.
    
  • a first read to the manual (texdocmedia9), seemed to be a regression, as it could do more complicated stuff (reading youtube files from within a PDF) but not the simple stuff you really use (I will never read a youtube files from within a PDF ...). In addition, the movie15 package was removed from texlive, so you have to make the transition (this was easily fixed by downloading a copy of movie15.sty)

  • to make the change, you have to change the lines which are like:

    \includemovie[label=aperture_aperture,poster=figures/aperture_aperture.png,mouse,repeat,autoplay]{\linewidth}{.75\linewidth}{./figures/aperture_aperture.mp4}
    
  • by something like:

    \includemedia[
    width=\linewidth,height=0.75\linewidth,
    activate=pageopen,
    addresource=./figures/aperture_aperture.mp4,
    flashvars={
    source=./figures/aperture_aperture.mp4 % same path as in addresource!
    &loop=true % loop video
    }
    ]{}{VPlayer.swf}
    
  • an interesting perspective is to use 3D objects generated by asymptote:

    \includemedia[
    width=0.8\linewidth,height=0.8\linewidth,
    activate=pageopen,
    add3Djscript=asylabels.js, %upright text labels
    add3Djscript=3Dspintool.js, %let scene rotate about z-axis
    % 3Dcoo, 3Droo values found with ‘Generate Default View’ from
    % context menu
    3Dmenu,
    3Dcoo=-21.371112823486328 -19.702425003051758 -395.4008483886719,
    3Droo=472.3543474473915,
    3Dc2c=4 2 3
    ]{}{epix.prc}
    
  • one solution for a smooth transition is my case where I need to just show a movie and nothing too fancy, one can create a command in the preamble like:

    \newcommand{\includemovie}[3]{%
    \includemedia[
    width=#1,height=#2,
    activate=pageopen,
    addresource=#3,
    flashvars={
    source=#3 % same path as in addresource!
    &loop=true % loop video
    }
    ]{}{VPlayer.swf}
    }
    
  • and then use something like:

    \includemovie{\linewidth}{.75\linewidth}{./figures/aperture_aperture.mp4}
    
  • note that (from http://tex.stackexchange.com/questions/45242/animations-with-movie15-and-swf-files ) :

    Video files must be in the MP4 format. Videos in other formats must be converted to MP4 or recreated from the raw material. The H.246 codec gives high quality video at stunningly small file size. With ffmpeg, video files can be created easily.
    
    From an existing video file, such as Sample.avi:
    
    ffmpeg -i Sample.avi -vcodec libx264 Sample.mp4
    
    From a numbered sequence of bitmaps, such as frame-0.png, frame-1.png, ... :
    
    ffmpeg -i frame-%d.png -vcodec libx264 myvideo.mp4
    

Comments

2012-04-05 managing defaults on MacOsX

  • when managing multiple machines, it is sometimes a pain to reset all default parameters. Still you want the same behaviour everywhere...

  • this repository https://github.com/mathiasbynens/dotfiles/blob/master/.osx display a large number of useful comands for your mac :

    # Always show scrollbars
    defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
    
    # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
    
    # Enable subpixel font rendering on non-Apple LCDs
    defaults write NSGlobalDomain AppleFontSmoothing -int 2
    
    # Enable the 2D Dock
    defaults write com.apple.dock no-glass -bool true
    
    # Automatically hide and show the Dock
    defaults write com.apple.dock autohide -bool true
    
    # Make Dock icons of hidden applications translucent
    defaults write com.apple.dock showhidden -bool true
    
    # Enable iTunes track notifications in the Dock
    defaults write com.apple.dock itunes-notifications -bool true
    
    # Show all filename extensions in Finder
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true
    
    # Show status bar in Finder
    defaults write com.apple.finder ShowStatusBar -bool true
    
    # Expand save panel by default
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    
    # Expand print panel by default
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    
    # Disable the “Are you sure you want to open this application?” dialog
    defaults write com.apple.LaunchServices LSQuarantine -bool false
    
    # Disable shadow in screenshots
    defaults write com.apple.screencapture disable-shadow -bool true
    
    
    # Display full POSIX path as Finder window title
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    
    # Increase window resize speed for Cocoa applications
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
    
    # Avoid creating .DS_Store files on network volumes
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    
    
    # Disable send and reply animations in Mail.app
    defaults write com.apple.Mail DisableReplyAnimations -bool true
    defaults write com.apple.Mail DisableSendAnimations -bool true
    
    # Copy email addresses as `foo@example.com` instead of `Foo Bar <foo@example.com>` in Mail.app
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    
    # Disable Resume system-wide
    defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
    
  • there is much more on

    git clone https://github.com/mathiasbynens/dotfiles.git && cd dotfiles && ./bootstrap.sh
    
  • {2} TODO: make default changes for a french keyboard

Comments

2012-03-25 going back to simplicity: duckduckgo

Comments

2012-03-24 Type your paths directly

  • from http://apple.blogoverflow.com/2012/03/open-and-save-like-a-pro-secrets-of-opensave-dialogs/ :

    Let’s move on to a more advanced feature: the Go to Folder dialog. Like in Finder, you can access a prompt for typing a path by pressing ⇧+⌘+G. If you love the keyboard, you’ll love this dialog; frequently, the fastest way to get to where you want to go is by typing its path. This is especially true because the Go to Folder dialog features tab autocompletion: type the beginning of the name of a file or folder and hit tab to fill in the rest of the name automatically. My favorite part about the Go to Folder dialog is that it appears automatically whenever you begin typing a path (/ or ~). When saving, the desired filename can even be included in the path.
    

Comments

2012-03-22 how to leave iphoto

  • iphoto.app is certainly a nice tool, but it is also

    1. slow, unresponsive and locks you in some ugly closed-source format.
    2. also, try to look in forums when you want to share pictures on different {computers / OSs / iphoto versions / places / users} = nightmare!
    3. on top of that, the *cloud stuff is intellectually just very corrupted...
    4. what decided me to drop it entirely was a sudden corruption of the library. It took 2 days to recover my files and re-rotate correctly all pictures...
    5. last nail in the coffin was the fact that libraries are not backward compatible : you have to upgrade to the new product.
  • so time to take back possession of your pictures!

  • I found some supporting arguments here: http://accretiondisc.com/blog/2011/10/26/leaving-iphoto/

  • solution: put the files in folders according to a date organization of the type 2011/P0747444.jpg, other tools for tagging, etc... follow naturally (and you share as you share folders on dropbox or whatever)

  • first, let's set the default application for upcoming pictures from cameras:

    1. With your camera connected, open Image Capture
    2. You will see your camera under devices. Click the icon.
    3. Down at the bottom, you will see “Connecting this iPhone opens…” with a pull-down menu under it.
    4. select "autoimport" (I choose "delete after importation")
    5. another solution is to use a feature from dropbox...
  • then, let's export the data from iPhoto: File.../Export.... I kept the original file names but with the modifications (mainly rotations that were applied to my old camera without a gravity sensor). you should end up with lots of files in one directory. but it ... does not work as iphoto raises a completly unmeaningful error ('could not create file').

  • so, let's explore the library:

    1. it is package, and we can right-click in the finder to 'show package content'
    2. click the Masters folder to open it, and you'll see folders organized by year; inside are more folders organized by date and album, and inside them are photos in JPG format and video clips.
  • then I found https://github.com/BMorearty/exportiphoto and you just have to type

    python exportiphoto.py Pictures/iPhoto\ Library Pictures/Photos
    

    to achieve the export

    • I used the following commands to post-process all

      counting if everything was moved (there was some corruption in the library file with MOVies)
      find ~/Pictures/iPhoto\ Library/Masters/2012 -iname *MOV |wc -l
      find ~/Pictures/iPhoto\ Library/Masters -iname *MOV |wc -l
      find ~/Pictures/Photos -iname *MOV |wc -l
      
      # brute force to compare the content of the trees (brute force for the computer, you can get a coffee)
      mkdir ~/Pictures/Photos/2011
      chmod -R u+rwX ~/Pictures/Photos/2011
      find ~/Pictures/iPhoto\ Library/Masters/2011 -iname *MOV -exec cp {} ~/Pictures/Photos/2011/ \;
      mkdir ~/Pictures/Photos/2012
      find ~/Pictures/iPhoto\ Library/Masters/2012 -iname *MOV -exec cp {} ~/Pictures/Photos/2012/ \;
      

      (for the last exampls, see http://en.wikipedia.org/wiki/Xargs )

  • at the end, the great relief is to remove all this iphoto cr*p:

    cd ~/Pictures/
    rm -rf iPhoto*
    cd ~/Library/Caches
    rm -rf com.apple.iPhoto
    
  • I'll be glad to help anybody with similar problem

Comments

2012-03-21 installing Dovecot on MacOsX using HomeBrew

  • master howto: https://trac.macports.org/wiki/howto/SetupDovecot

  • Install

    brew install dovecot
    sudo vim /Library/LaunchDaemons/homebrew.mxcl.dovecot.plist
    
  • Configure

    sudo cp /usr/local/etc/dovecot/dovecot-example.conf  /usr/local/etc/dovecot/dovecot.conf
    sudo vim /usr/local/etc/dovecot/dovecot.conf
    
  • Mine reads (it's just meant to access imap files from the local mail server and not to serve outside the localhost):

    disable_plaintext_auth = no
    mail_location = maildir:~/Maildir
    ssl = no
    default_login_user = lup
    passdb {
      args = login
      driver = pam
    }
    protocols = imap
    service auth {
      user = root
    }
    service imap-login {
      inet_listener imap {
        address = 127.0.0.1
        port = 10143
      }
      inet_listener imaps {
        address = 127.0.0.1
        port = 10943
      }
    }
    userdb {
      driver = passwd
    }
    
  • Reload

    sudo launchctl unload homebrew.mxcl.dovecot.plist
    sudo launchctl load homebrew.mxcl.dovecot.plist
    
  • It does not work on the first try... so read documentation

    less /usr/local/share/doc/dovecot/documentation.txt
    less /usr/local/share/doc/dovecot/auth-protocol.txt
    less /usr/local/share/doc/dovecot/wiki/PasswordDatabase.PAM.txt
    
  • Authentification

    ls -l /etc/pam.d/
    sudo vim /etc/pam.d/dovecot
    

    with /etc/pam.d/dovecot being

    auth       required       pam_permit.so
    account    required       pam_permit.so
    password   required       pam_deny.so
    session    required       pam_uwtmp.so
    

Comments

2012-03-16 Creating a bootable Debian USB flash drive on MacOsX

  • largely adapted from https://help.ubuntu.com/community/Installation/FromUSBStick#From_Mac_OSX

  • download the iso

    wget http://napoleon.acc.umu.se/debian-cd/6.0.4/i386/iso-cd/debian-6.0.4-i386-CD-1.iso # or http://debian.ens-cachan.fr/ftp/debian-cd/6.0.4/i386/iso-cd/debian-6.0.4-i386-xfce+lxde-CD-1.iso
    hdiutil convert -format UDRW -o target.img debian-6.0.4-i386-CD-1.iso
    mv target.img.dmg target.img
    
  • identify where is your USB stick

    diskutil list
    
  • unmount the USB stick

    diskutil unmountDisk /dev/disk2
    
  • write on the stick

    mv target.img.dmg target.img
    sudo dd if=target.img of=/dev/rdisk2 bs=1m
    
  • eject the USB stick

    diskutil eject /dev/disk2
    

Comments

2012-03-13 Moving Time Machine to a New Hard Drive

  • There exist some solution to move a time machine data folder to a new drive by making a clone of the drive. My problem is that I already have data on the new drive and that this data can difficultly be moved.

  • It try (after switching off Time machine of course) with rsync while keeping hard links:

    sudo rsync -av -H  /Volumes/tera_enigma/Backups.backupdb /Volumes/2T_un/
    
  • This takes a while as rsync has to manage a lot of them (may take also a lot of memory, so be patient)

Comments