Thursday, August 15, 2013

Google Chromecast

After trying to watch a Vimeo video on my Panasonic TV, I'm now sold on the Chomecast:

1) pressing buttons on the normal TV remote sometimes didn't work. Batteries dying?  Not clear.  True a smartphone's batteries only last a day, but when the power is dead, it's obvious.

2) using up/down/left/right keys on a TV remote to gradually pick out letters on a search box is not fun.

3) after this process, the Vimeo TV app gave me 9/533 matches, but none of the matches were my video, nor was there a way to see page two of results!

Here's the eventual workflow for watching Vimeo on the TV:

0) associate TV Vimeo app with my Vimeo account

1) boot up laptop, log into Vimeo

2) laptop: find video, click "Watch Later"

3) TV: wait

4) TV: magic happens, video appears on the beginning of the Watch Later list

5) TV: click Select to watch first video

After all that, the video play was like a laptop: audio/video occasionally stutters.  Pressing play and waiting a minute seems to help, but it's not clear.  On the other hand, video and audio quality is quite good.

It looks like the Chromecast version of this is:

1) use tablet to find video

2) click "Send to Chomecast"

3) there is no #3

I'm sold!

(And yes I know Vimeo doesn't support the Chromecast; I'm just going over the overall thing here.)

Monday, August 12, 2013

converting video for a media player (Roku, Panasonic, Android)

Media players are awesome, but only play certain types of videos.  Currently I work with a newish Panasonic TV (awesome), a Roku (very good), and a Bluray player with a USB port (pretty good).

All of these are rather particular about which videos and which codecs and which audio they'll play.  Sometimes everything will be great, but the sound will be out of sync!  Or everything will be in sync... until the end of the movie, where things will gradually get messed up.

It's helpful to have a workflow to iron out video conversion issues quickly.

What finally worked for me was:

1) install Handbrake (both handbrake-gtk and handbrake-cli)
2) convert 20-ish seconds several minutes into the program
3) copy video to USB stick
4) put in media player, try it
5) change conversion settings, repeat from step 2

Here is step #2 in a command line:
HandBrakeCLI -i input.avi --start-at duration:200 --stop-at duration:20 -o z.mp4


Lastly, it's easy to automate this.  This debugging script prints out input.mp4 for each input.avi file:
for input in *.avi ; do echo ${input%.avi}.mp4 ; done

Many video files have spaces, which Linux doesn't like too well.  Quote them:
for input in *.avi ; do echo "$input" "${input%.avi}.mp4" ; done

Putting it all together, we can convert all our videos to mediaplayer-friendly MP4 files with this one-liner.  In my case I found adding the "deblock" filter made my bad source files a little nicer to watch:
for input in *.avi ; do HandBrakeCLI -i "$input" --deblock -o "${input%.avi}.mp4" ; done

If you're insane like me, convert the movies in parallel, two at a time (P2):
for input in *.avi ; do echo "${input%.avi}" ; done | xargs -i -P2 HandBrakeCLI -i "{}".avi -o "{}".mp4 
The output will stutter, as Handbrake will write multiple status lines on top of each other, but them's the breaks.


A version of this on bashoneliners.com





Saturday, August 3, 2013

Functional Programming with Python

Excellent explanation of how to use functional programming to make your Python code smaller and easier to debug

Functional Programming with Python