Streaming to twitch.tv from Linux

I was looking to stream to twitch.tv from Linux, but none of the existing solutions were embedding the webcam over the captured desktop. Since twitch.tv works with rtmp, and existing scripts were using ffmpeg, it was easy to modify the script to add the camera as an overlay. Here’s the source for anyone interested:

#!/bin/bash

API_KEY="live_..."
FPS="30"
INRES="1920x1200"
OUTRES="640x400"

ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0 \
-f alsa -ac 2 -i default -vcodec libx264 -s "$OUTRES" \
-acodec libmp3lame -ab 128k -ar 44100 -threads 0 \
-vf "movie=/dev/video0:f=video4linux2, scale=120:-1, setpts=PTS-STARTPTS [movie];[in] setpts=PTS-STARTPTS, [movie] overlay=main_w-overlay_w:main_h-overlay_h [out]" \
-f flv  "rtmp://live.twitch.tv/app/$API_KEY"

How to use:
Copy the code and paste it into a file “stream.sh”. Edit in your API_KEY, then run it as “bash stream.sh”.

A few notes:

  1. Change fps, input resolution, output resolution to match your setup. If you have slow upload, keep FPS and OUTRES low.
  2. Change the last part of the command line (rtmp://…) to a file name to record screencasts.
Posted in scripting, tech Tagged with: , , , , , , , , ,

zsh is really awesome

A few months ago, I decided to try out zsh as my default shell. It’s very similar to bash, but is much more powerful. My favourite features so far:

  1. Shared command line history among all sessions. I usually have at least 4-5 shells open, and the command history being shared among them is awesome. Means I don’t have to hunt in which shell I typed that huge pipe command, it’s just available across all the shells!
  2. Better file globbing. ls **/, simulates find. Replacing ls by another command is equivalent to find -exec. Less typing!
  3. Programmable prompt.  My zsh shows the git/svn branch name in the prompt itself.  People have gone so far to have written a prompt which displays the battery status right there. One word, zsh is extensible, very extensible. zsh also has two prompts, one which appears on the left side (the normal one), and another on the right side.
  4. Auto-completion built in. bash-completion offers many of the auto completion features, but zsh has far more commands in the list.
  5. Command arguments expansion. Pressing tab on a command with wildcards/backtick commands expands them. So something like ls *avi, will actually fill in in all the .avi files in the prompt, so I know what’s going on.

You don’t even have to bother with your zshrc

My zsh experience improved ten-fold after I installed robbyrussel’s oh-my-zsh. Setting it up is just two commands (and another for changing your default shell):

oh-my-zsh will provide plugins (git, yum, deb, svn etc) , themes (I currently use afowler), a lot of sane configuration options, and better keyboard shortcuts.

You won’t go back to bash once you use zsh. :)

Posted in scripting, tech

Permission Denied

Update: The problem is solved now, it was because the parent directory had the +i flag set.

I ran into a weird problem today. I was cleaning up disk space and ran into a file that refused to delete.

geekbox:/media/7/ # rm file.iso

rm: cannot remove `file.iso’: Permission denied

No problem, huh? Did everything I could think of:

geekbox:/media/7/ # rm -f file.iso

Permissions?

geekbox:/media/7/ # chmod 777 file.iso

geekbox:/media/7/ # chown root:root file.iso

geekbox:/media/7/ # rm -f file.iso

rm: cannot remove `file.iso’: Permission denied

Filesystem problems?

geekbox:/media/7/ # fsck -f /dev/sdc2

7: 194131/31514624 files (0.3% non-contiguous), 119735268/126050006 blocks

Corrupted file?

geekbox:/media/7/ # dd if=file.iso of=/dev/null

7472920576 bytes (7.5 GB) copied, 302.342 s, 24.7 MB/s

Immutable bit set?

geekbox:/media/7/ # lsattr file.iso

————-e- file.iso

strace points me to this:

unlinkat(AT_FDCWD, “file.iso”, 0) = -1 EACCES (Permission denied)

I got my disk space back at least,

geekbox:/media/7/ # echo “” > file.iso

But now I’m stuck with a file I don’t know what to do with.

Posted in Linux Tagged with: , , , ,

TV Shows

Inspired by Rohan, I too decided to make a list of the TV shows I have seen/currently seeing. And (hopefully) by the end of next three years, I will have caught up on him. 😉 (The numbers in the bracket are the number of seasons seen).

Comedy:

  1. Friends (10/10) – It’s a good comedy, but the way people watch it over and over again makes me cringe.
  2. That 70’s Show (8/8) – I loved it, though it gets a bit boring halfway through.
  3. The IT Crowd (4/4) – Already a post dedicated to it.
  4. Happy Days (4/11) – I like watching old series, and seriously, The Fonz is awesome.
  5. Mind Your Language (1/3) – Gets very repetitive.
  6. The Cosby Show (8/8) – This is one show that gets better with each season, though it has does have its share of boring episodes.
  7. It’s Always Sunny in Philadelphia (1/5)
  8. The Big Bang Theory (3/3) – Ranks next to The IT Crowd.
  9. Cheers (3/11)
  10. Lucky Louie (1/1) – Why did this one last only one season?

Animation/Anime:

  1. Dragon Ball (all)
  2. Dragon Ball Z (all) – Frieza saga sucks, but the rest is very good.
  3. Dragon Ball GT (all) – Worth watching if you like the first two.
  4. Detective Academy Q (1/1) – The first anime I ever saw, the mysteries are totally amazing.
  5. Avatar: The Last Airbender (3/3) – I found this a bit cliched.
  6. South Park (14.5/14.5) – Some episodes are insanely funny, but quite a lot are bland (lots of Western cultural references).
  7. Star Trek: The Animated Series (2/2)

Mystery/Thriller/Action:

  1. Sherlock (1/1) – A very intriguing reboot of the old Sherlock.
  2. Sherlock Holmes (2/7) – The old series, faithful to the book as far as I have observed.
  3. Spartacus: Blood And Sand (1/1) – One of the best series in the last season. Looking forward to the next season.
  4. Star Trek: TOS (3/3) – A very good series considering it’s close to 50 years old.
  5. Star Trek: Enterprise (4/4) – I started with this series, it’s nowhere near to the others.
  6. Star Trek: Deep Space 9 (2/7) – The starting is boring, but I have been told it picks up in the 3rd season.
  7. Star Trek: The Next Generation (7/7) – The best of the canon. I wish there were more episodes.
  8. Mission Impossible (2/7)
  9. Xena: Warrior Princess (1/6)
  10. Heroes (4/4) – Only the first season is worth watching.
  11. 24 (7/8) – Started off good, but got boring and slow as it progressed.
Posted in TV Tagged with:

The IT crowd

…. is  an awesome sitcom. 18 episodes of pure humor. If you have not seen it yet, go get it and watch it.

And now, a true incident that happened today (inspired by The IT Crowd, of course).

I happened to go to the server room today.

JP: We are, izzin, having some issues, izzin, with the faculty mail server. It’s, izzin, giving input/output errors, izzin with the disk, izzin.

I (trying very hard to keep a straight face): Did you try turning it off and then turning it back on again?

Posted in IIIT Tagged with: , , , ,