Getting Netflix to Run on Mint 15 (Olivia)

This turned out to be a bit tricky and required some digging. Here’s what worked for me:

Install Pipelight

Follow the instructions here to install Pipelight (which uses Wine to run the Silverlight plugin that Netflix needs):

Pipelight Installation Instructions

For me, this meant running the following commands:

sudo add-apt-repository ppa:pipelight/stable
sudo apt-get update
sudo apt-get install --install-recommends pipelight-multi
sudo pipelight-plugin --update

User Agent Switching

Before you can test anything, you need to install a user agent switcher in your browser. I normally run Firefox, but switched to Chromium for Netflix because I kept getting DRM errors (Turns out that Firefox was not the issue, but a clean install of Chromium eliminated some variables anyhow).

While testing in Firefox, I ran across these instructions to delete the contents of “/~/.wine-pipelight/drive_c/users/Public/Application\ Data/Microsoft/PlayReady/” to eliminate the DRM error. This didn’t seem to help for me, so I switched to Chromium, just in case. In fact, the real issue was that I needed to set my root filesystem to mount with extended attributes (see below). Both Chromium and Firefox worked in the end.

In Chromium, I installed this extension:

User-Agent Switcher for Chrome

In Firefox, this one:

User-Agent Overrider

I set the user-agent to “Firefox/Windows Firefox 15” in Chromium and “Windows/Firefox 29″ in Firefox (both worked – tips on which user-agent to choose are here).

Mount Filesystem with Extended Attributes

This turned out to be the key step. You need to mount the root filesystem with user_xattr enabled (as described here.

For me this meant editing /etc/fstab as root and adding “user_xattr,” (note the comma) before “errors=remount=ro” for my root filesystem (more info here). I recommend that you be very careful about doing this, because a typo could prevent you from mounting the operating system on reboot.

After rebooting my machine, everything worked like a charm in both Chromium and Firefox.

Installing Tiny Tiny RSS on Raspbian

Just finished installing Tiny-Tiny RSS on my pi. I was able to use the automatic configuration wizard, but had to do a bit of fiddling to get it to work.

Here are the steps I followed:

1) download the latest tt-rss package: http://tt-rss.org/redmine/projects/tt-rss/wiki/InstallationNotes

2) Move, decompress, and rename it in my web server directory

sudo mv 1.1.tar.gz /var/www
sudo tar xvzf /var/www/1.1.tar.gz
sudo mv Tiny-Tiny-RSS-1.11/ tt-rss

3) In my case, I had to forward port 3306 on my cable modem to my pi server for mysql connections.

4) Install mysql and choose a root user password when prompted

sudo apt-get update; sudo apt-get install mysql-server

5) Create a database and user, then assign privileges

mysql -u root -p [enter root password at prompt]

In mysql:

create database ttrss;
create user 'ttrss'@'localhost' identified by 'whatever_password';
grant all on ttrss.* to ttrssuser;
exit

6) Connect to url: http://999.999.999.999/tt-rss [where 999.999.999.999 is my server ip address]. This will take you to the install page. Enter your settings:

Database Type: MySQL
User Name: ttrssuser
Password: whatever_password
Database: ttrss
Host: [leave blank]
Port: [leave blank]
Tiny Tiny RSS URL: [leave as default]

Click “Test Configuration”

7) As instructed by the installer, I needed to copy the configuration from the installer webpage and use an editor to paste the contentts into a new /var/www/tt-rss/config.php. At this point, the TT-rss page wouldn’t load, but it helpfully told me to change the following permissions:

sudo chmod -R 777 cache/images
sudo chmod -R 777 cache/upload
sudo chmod -R 777 cache/export
sudo chmod -R 777 cache/js
sudo chmod -R 777 feed-icons
sudo chmod -R 777 lock

8) Last but not least, I had to set up regular updates by adding the following to my crontab

*/30 * * * * /usr/bin/php /var/www/tt-rss/update.php --feeds --quiet

And that’s it!

Creating Camera Ready Artwork Using the Gimp

I’m creating some business cards and my print shop needs PDF format output with a CMYK colour profile. Neither of these can be done with the Gimp as installed, so this is what I had to do in Ubuntu Oneiric Ocelot with Gimp 2.6.11 to finish the task:

1) install gimp-plugin-registry and icc-profiles from the apt repository (“sudo apt-get install gimp-plugin-registry icc-profiles” or use the software centre);
2) open the image I want to send to the print shop and select “Image/Flatten Image” (if the image has multiple layers) and then “Image/Separate/Separate”;
3) in the dialog, accept the default options, but optionally check “Make CMYK pseudo-composite” (this doesn’t seem to affect the final product, but it does generate an image with the colour layers blended in a way that is recognizable — that way you can see that you are getting what you expect);
4) when the new separated version of the image pops up in a new window, select “Image/Separate/Export…” and save as a TIF file;
5) use “tiff2pdf filename.tif -o filename.pdf” to create the pdf file for the printer.

The most useful info I found on this topic was here: https://wiki.archlinux.org/index.php/CMYK_support_in_The_GIMP and http://ian-pullen.suite101.com/how-to-save-cmyk-images-in-gimp-a107979.

Canon Vixia HV40 HDV Format Notes

So far I have always converted my HDV footage to NTSC before editing. For a small project I’m working on now, I’ve decided to try working directly with the raw HDV footage.

This thread explains why my m2t files show up as 1440×1080 even though they can be edited as 1920×1080 (aka 1080i). It has to do with square vs. rectangular pixels — or something — it doesn’t really matter. More general info on formats is here.

In Cinelerra, you must set the project format to 1440×1080, 16:9 ratio, then make sure you select “match output size” by right-clicking on the video track(s). This looks okay in the compositor window in Cinelerra, but the resulting file plays by default at 4:3 aspect ratio. You can set this manually when you open the video in VLC and see that everything looks okay. The only method I have found so far for getting the rendered video to play as 16:9 by default is by using a command such as this on to re-encode it after the fact:

ffmpeg -i full_render_test.mov -aspect 16:9 -sameq full_render_test_16-9.mov

For rendering in various formats, follow the instructions here as usual.

Using Smugmug as a Photo Backup Location

I’ve finally gotten around to uploading my photo collection. I’ve decided to pay for a subscription to Smugmug.com and so far I’m happy with it. I chose not to use Flickr or other options because I wanted a site which I could use as a private one-to-one backup of my personal store of photos. I can make albums or photos public using other services or through Smugmug. I also wanted to be able to synchronize tags and metadata between the on-line store and my digikam-managed local version. If I ever lose my local copy, I should be able to download a full copy of everything in its original form. Smugmug appears to be able to do all of that (and has other good features, too).

To do the synchronization, I’m using the php uploader found here. It seems to be working, although I had some trouble at first pointing it at the right directory on my system. Running the upload program is simple:

php /path/to/multi-album-upload.php /path/to/pictures

NOTE: I initially had a little trouble because I was pointing to the wrong level in the hierarchy of my picture directory tree. The program assumes an arrangement something like this:

home
user
photo_library
category
album
image.jpg

My reading of the instructions implied that you could point to “/home/user/photo_library/category” but that doesn’t work. You need to point to “/home/user/photo_library.”

Web Video

I’ve been experimenting with video codecs and formats for uploading video to the web (Facebook, Youtube, etc.).

Encoding for the Web

To make a tiny file, you can encode files this way:

ffmpeg -i foo.dv foo.mp4

For better quality output, there are a number of variables you can control. I’m starting with two assumptions for the time being: I’m using the h264 codec and my target output format is mp4. For YouTube, flv would be better.

ffmpeg -i foo.dv -ab 128k -ar 44100 -b 1200k -vc h264 -qscale 1 -s 480×360 foo.mp4

“-i foo.dv” just identifies the input file, and the rest of the options apply to the output file.

For my own future benefit, I will break down the options I’ve used: “-ab 128k” is the audio bitrate, “-ar 44100″ is the audio sampling frequency (44100 is the default anyhow); “-b 1200k” is the video bitrate; “-vc h264″ is the video codec; “-qscale 1″ sets the video quantizer scale (lower is better quality, use “-sameq” for the same quality); “-s 480×360″ is the target width and height. All of these variables can be changed to create a higher/lower quality file which is smaller/larger in size. These settings create a decent output file for people to download, but it will be resampled on uploading to websites for streaming.

FFMPEG Tricks

If you just want to do a quick trim of the clip before uploading, I’ve found this is an easy way to do it. First play the video:

mplayer -osdlevel 3 -menu -loop 0 -dr -ni -framedrop -autosync 30 -msglevel all=0 -really-quiet -nolirc foo.dv

Note the start and end points you want, then run the ffmpeg command with “-ss NN” for the starting point in seconds and “-t NN” for the duration. That allows you to trim either the start or end of the clip without having to break out Cinelerra or Kino. By the way, I’ve got a pile of switches enabled on mplayer, but the only one that really matters is “-osdlevel 3″ so you can see the counter.

Some Youtube guidance on formats here: http://www.google.com/support/youtube/bin/answer.py?answer=132460&safe=off

Facebook format details are found here. You could use this command and vary the qscale and bitrate to get a reasonable file size:

ffmpeg -i foo.dv -acodec libfaac -ab 128k -b 1200k -vc h264 -qscale 6 foo.mp4

Vimeo format recommendations give specific values for bit rates and codecs as follows for high quality:

ffmpeg -i foo.dv -acodec libfaac -ab 320k -b 2000k -vc h264 -sameq foo.mp4

For HD video on Vimeo:

ffmpeg -i foo.m2t -acodec libfaac -ab 320k -b 3000k -vc h264 -sameq -s hd720 foo.mp4

“-s hd720″ tells ffmpeg to create 1280×720 output.

Sources of Information

This video is a good ffmpeg intro: http://www.linuxjournal.com/video/linux-howto-video-editing-magic-ffmpeg

For Youtube uploads, they use the following command. The presenter explains that these parameters are good for Youtube because they will not be re-encoded on upload:

ffmpeg -i foo.mov -ar 22050 -acodec libmp3lame -ab 32k -r 25 -s 320×240 -vcodec flv -qscale 9.5 foo.flv

He also shows how to crop and letterbox using ffmpeg and even creates a moving spotlight. He also uses the “-loop_input” ffmpeg switch in order to make a 10 second clip of a still frame. Very handy!

ffmpeg -loop_input -i still.png -t 10 -r 29.97 -qscale 2 extendedstill.mpg

Here is an explanation of how to use ffmpeg for screencasting.

Extract Audio Track from a Video File

I needed to isolate the audio track from an HDV video I captured from my camera. This command worked great:

mplayer -dumpaudio video.m2t -dumpfile audio.mp3

as discussed here: http://linux.byexamples.com/archives/229/extract-audio-from-video-or-online-stream/

UPDATE: To extract wav audio data from a dv file, I had to use this command:

ffmpeg -i video.dv -vn -acodec copy audio.wav

Details here: http://www.tuxradar.com/content/ffmpeg-made-easy

Video Production on Linux Workshop

I’m putting on a workshop/demo this evening to introduce some people to open source software and Linux for video editing. Here are the handouts: linux_video.

Thanks to Western Arctic Moving Pictures for hosting the workshop!

Scripts for Monkeying with Cinelerra XML

I’ve moved my Cinelerra projects from one directory path to another and scrambled a few things in the process. I’ve written a few bash scripts which helped me sort things out.

In the process, I’ve learned a bit about the xml format which Cinelerra uses to store references to files and edits. When you add a resource, it appears twice between opening and closing “ASSET” tags with the format <ASSET SRC=”/path/to/filename”>[asset details]</ASSET>. Then every time you include that file in a track of your project, the filename appears again in an “EDIT” tag complex in the format <FILE SRC=”/path/to/filename”>[edit details]</FILE>

First, I needed to check the paths for all the resources in the file to make sure they are still valid. I called this program test_xml_paths.sh. I corrected the incorrect paths with a text editor, but found that Cinelerra was still crashing with a memory error when I loaded the project.

Second, I decided to find and eliminate all of the unused assets in the file. I originally had a forty minute video in one file, but some time ago I split the project into four ten minute chunks. When I created the original project, I had added a couple of thousands of clips for possible inclusion, so now that I’m working on the final cut, I don’t need all that bloat.

I created a function to figure out which assets were being used in the edit list and which were not: list_unused_assets.sh.

Finally, I wrote a script which would recreate a new xml project file with all the redundant assets removed: remove_unused_assets.sh.

I can’t offer any warranty on these scripts, of course, but I hope they may help somebody else. If nothing else, there’s a great example of multi-line sed editing in the last one.

Remove Unused Assets from a Cinelerra XML Project File

This is a bash script to remove all the unwanted assets from a Cinelerra project XML file. I needed it to cut out bloat from a project I was working on which had hundreds of unused resources after I split the project up into ten minute chunks. Doing so stopped Cinelerra from crashing when I loaded the project: YMMV.

Save this script as “remove_unused_assets.sh”. It needs the function in “list_unused_assets.sh” which I posted here.

#! /bin/bash
#kk remove_unused_assets.sh
#kk
#kk For cinelerra xml files
#kk this script removes the contents of asset tags which are not also used for edits

if [ -z "$1" -o "$1" = "-h" ]
then
echo “Usage: remove_unused_assets [xml_filename]“
echo “For cinelerra xml files, this script removes the contents of asset tags which are not being used for edits”
exit
fi

TMPDIR=”/tmp”
SCRIPTDIR=”$HOME/Video/video_new/common/scripts”

. $SCRIPTDIR/list_unused_assets.sh
. $SCRIPTDIR/include.inc

#assign the parameter to a variable
XMLFILE=$1

#location of the temporary files
ASSETS_FILE=”$TMPDIR/ASSETS_FILE”
EDITS_FILE=”$TMPDIR/EDITS_FILE”
XMLFILE_NEW=”$1″_new
XMLFILE_TMP=”$TMPDIR/XMLFILE_TMP”

#check if the xml file exists and exit if it does not
if [ ! -e $XMLFILE ]; then error “XML file does not exist”; fi

list_unused_assets $XMLFILE
if [ $? != 0 ] ; then error “list_unused_assets failed”; fi

cp $XMLFILE $XMLFILE_TMP

echo
echo Removing Unused Assets…
echo
echo “Working…”
echo

# loop through the list of unused assets and remove the ASSET tag lines for each
# sed command from here: http://ilfilosofo.com/blog/2008/04/26/sed-multi-line-search-and-replace/

for f in $( comm -23 $ASSETS_FILE $EDITS_FILE ); do

#to make the filename string work in sed, I have to escape all of the periods and slashes
FORMATTED_f=`echo “$f” | sed -e ‘s:\/:\\\/:g’ -e ‘s:\.:\\\.:g’`

#this complicated sed script came from the sed FAQ: http://sed.sourceforge.net/sedfaq4.html#s4.21
#in order to make the variable substitution work, I had to close the sed script with a single quote
#then enclose the variable in double quotes, then re-open the sed script with a single quote
#the -i option is for editing a file “in place”
sed -i -e ‘
# sed script to delete a block if /regex/ matches inside it
:Top
/\/ { # For each line between these block markers..
/\/ASSET\>/!{ # If we are not at the /end/ marker
$!{ # nor the last line of the file,
N; # add the Next line to the pattern space
b Top
} # and branch (loop back) to the :Top label.
} # This line matches the /end/ marker.
/’”$FORMATTED_f”‘/d; # If /regex/ matches, delete the block.
} # Otherwise, the block will be printed.
#—end of script—
‘ $XMLFILE_TMP

#diff $XMLFILE $XMLFILE_TMP

echo -n ‘ \r’
echo -n $f’\r’

done

cp $XMLFILE_TMP $XMLFILE_NEW

echo
list_unused_assets $XMLFILE_NEW

echo
echo Finished.
echo
echo The new version of the xml file has been saved as $XMLFILE_NEW.
echo

This program depends on include.inc which contains the following:

#!/bin/bash

#use colour in the output just for fun
GREEN=$(printf “\033[32m”)
RED=$(printf “\033[31m”)
NC=$(printf “\033[0m”)

error()
{
echo ERROR: $1
exit 1
}

I tried to make these scripts as tidy and portable as possible — you will, however, need to change the path for $SCRIPTDIR to the location you are using (and $TMPDIR if you don’t want to put your temporary files in /tmp).