Monday 28 May 2012

Rip a DVD Using The Command Line



Use this command to rip a DVD using the command line.

Mount a DVD disc or iso to a convenient place. I will use an iso in this example;


mkdir /tmp/dvd

sudo mount -o loop /path/to/dvd.iso /tmp/dvd

Issue this command to rip a DVD to a file in your home directory;

cat ./VIDEO_TS/VTS_01_1.VOB | nice avconv -i - -s 512x384 -vcodec libtheora -acodec libvorbis ~/dvd_rip.mp4

If you prefer to use closed h264 and mp3 codecs you can install them from the multiverse repository;

sudo apt-get install libavcodec-extra-53 (libavcodec-extra-52 for maverick and earlier)

Change these parameters;

-vcodec libx264 

-acodec libmp3lame

The default bitrate is about 800kbs. To change this use these parameters;

-b 1200000       : Video in bps

-ab 128000       : Audio in bps

Sometimes you don't want to re-encode the streams, in such cases you copy the stream using -c:v copy, -c:a copy and -c:s copy (for subtitles)

Example: Transcode video but copy audio;

cat ./VIDEO_TS/VTS_01_1.VOB | nice avconv -i - -vcodec libx264 -c:a copy -b 1200000 ~/dvd_rip.mp4

Notes: The '-i -' means take input from stdin

Thursday 24 May 2012

Tuesday 22 May 2012

CentOS 6 Bridged Networking

If you are intending to run KVM under Centos, you will most likely want to use bridged networking.

I am starting with a standard CentOS 6 "minimal" install but the same process applies to RHEL and CentOS all versions.



First, install the bridge utils package;

yum install bridge-utils


Create/edit these two files, substituting the ipaddress and other details as applicable;

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT=yes
HWADDR=FF:FF:FF:FF:FF:FF   # Use the actual hardware address for your NIC
TYPE=Ethernet
BRIDGE=br0

# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.0.0.1
PREFIX=24
GATEWAY=10.0.0.254     # You can put this in /etc/sysconfig/network if you prefer
DNS1=10.0.0.2
DOMAIN=example.net
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System br0"


Restart your server and you should now have a bridge adapter called "br0";

# ifconfig br0
br0    Link encap:Ethernet  HWaddr FF:FF:FF:FF:FF:FF 
          inet addr:10.0.0.1  Bcast:10.255.255.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:64ff:fe78:3f44/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9092 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4424 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9175506 (8.7 MiB)  TX bytes:369549 (360.8 KiB)


Confirm the bridge;

#brctl show
bridge name          bridge id           STP enabled    interfaces
br0                  8000.001a64783f44   no             eth0
virbr0               8000.525400badaa9   yes            virbr0-nic

Sunday 13 May 2012

The Games Industry

I'm old enough to have been there at the birth of what we now know as the multi-billion dollar "games industry" and I've been along for the ride ever since.

Over the last few years I have noticed a disturbing trend, and that is tying games to the Internet, even when the game has no online aspect at all (or virtually none).

I don't count idiotic "achievements" as online play.

This weekend on Steam, an entry for "Tropico 4" appeared in my library and the news section indicated that it is one of those "free weekend play" offers where you get to play the game for the weekend and then decide whether to buy it once the deal ends.

I've seen Tropico in the past and thought I might take a look. It took some time to download it on my slow adsl but eventually it was all done and installed.

So, this morning the weather is crappy so I decide to spend a few hours trying it out.

I fire up the game and lo, what are I met with but an "enter your email address and password" screen.

What? Yes, like so many modern games it requires that I must register the game before I can start it.

This wouldn't be so bad if the game at least used my existing Steam credentials but no, it is not that clever. I must provide details to "Kalypso Media" before I can play.

Apparently the benefits to me of this mandatory registration is the usual bunk that has been the unappetising bait for registration seekers since the dawn of time, namely "Game news, Updates, "premium support" and "community features".

Right. Nothing I want then. The only benefit that of  any value, which is not mentioned in that list, is the ability to play the game in the first place.

Thanks but no thanks, I think I'll pass.

This is not the worst offender in the dubious registration stakes though, that accolade goes to Grand Theft Auto 4, which requires a grand total of three separate accounts (Steam, Rockstar Social Club and Windows Live) before you can play it.

Unbelievable.

It's this sort of nonsense which drives people to pirating games.

Obviously if you aren't playing it in Steam it only requires two registrations but that is still two too many.

I didn't register for Tropico 4 and have already deleted the game. That's one potential sale lost due to game industry stupidity.

Nice one marketing cretins.

Friday 4 May 2012

HOWTO: Upgrade from Lucid to Precise

UPDATED 12/06/2012. I have had reason to attempt this on two more systems and both times  it was successful.

The Ubuntu distribution continues its rapid decline with the Precise release.

The Internet is teeming with examples of people who have discovered that upgrading to Precise is difficult at best, and near impossible at worst.

It doesn't appear that upgrading from the last LTS, 10.04 Lucid is possible at all.

Well, not easily anyway.

Attempting to upgrade a server from Lucid to Precise will most likely result in an error;

E: Could not perform immediate configuration on 'python-minimal'.Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)

Searching the Internet might lead you to a suggested fix such as this one;

sudo apt-get install -o APT::Immediate-Configure=false -f python-minimal

Apparently, sometimes that doesn't work either, forum post suggests adding apt to that command;

sudo apt-get install -o APT::Immediate-Configure=false -f python-minimal apt

Having got that far, I received another error;

E: Couldn't configure pre-depend multiarch-support for libnih-dbus1, probably a dependency cycle

Joy.

No help was forthcoming from the Internet on that one.

So, I tried a desperate move.

I decided to remove the offending file (libnih-dbus1) and re-install it.

Now, before I continue, I should make it absolutely clear that what follows is capital N Nasty.

The server I was working on was a scratch virtual machine that I would not care about if I accidentally toasted it.

It is entirely possible that doing this on your server may completely trash it!

You have been warned.

OK, with that out of the way, what I did was this;

apt-get remove libnih-dbus1

Apt went away and calculated a whole lot of dependencies that would be removed which resulted in it giving me a nasty warning;

You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'


Undaunted, I copy-pasted the list of files being removed into a text editor (just in case) and typed the "Yes, do as I say!" phrase as requested;

After a while apt was finished.

Note: If you are following this "procedure", do not reboot your system now!

OK, I was afraid my SSH session or network (or something) may have been broken causing me to lose my connection (yes, I was doing this remotely) but the server still seemed to be working, which was good.

So I installed everything back.

apt-get install ubuntu-minimal

This returned no errors.


Now, when we did the nasty remove of libnih-dbus1 and its dependents earlier, one of the things that was removed was the Linux kernel.

Without being to dramatic, it is fair to say that this is an extremely important package. Another important thing that was removed was openssh-server

Install them now;

apt-get install linux-image-server openssh-server


The final thing to do is to reboot and to make sure everything is truly OK

The server rebooted without problems and finally I have managed to upgrade from Lucid to Precise.

Yay, I suppose, but it really shouldn't be that hard.


Canonical should spend less time working on horrible user interfaces and more time getting the basics right.

A final note: Check your list of files that were removed to check whether anything else that may have been installed was removed. You should manually re-install anything you need.

Tuesday 1 May 2012

Socks5 Proxy using SSH


ssh -f -N -D 0.0.0.0:1080 localhost


Notes;

-f   run as a daemon

-N   stay idle and don't execute commands on localhost

-D   dynamic port forwarding on port 1080

You test it using curl;

curl --socks5 localhost:1080 www.google.com