Thursday, October 08, 2015

"ffmpeg" instead of "avconv" in youtube-dl

youtube-dl  https://www.youtube.com/watch?v=9SgpcpZU-tw

WARNING: Your copy of avconv is outdated and unable to properly mux separate video and audio files, youtube-dl will download single file media. Update avconv to version 10-0 or newer to fix this.

Use instead:

youtube-dl  --prefer-ffmpeg  https://www.youtube.com/watch?v=9SgpcpZU-tw

.

Sunday, September 27, 2015

Embedding Subtitles in a Video File

The easiest way is with the MP4Box tool.

First install the GPAC

sudo apt-get install gpac

Then you can use the following command

MP4Box  -add  inputfile.srt  target.mp4

More about this command in this link.

Another Option to do so:

apt-get install mkvtoolnix

mkvmerge -o output.mkv video.mp4 subtitles.srt

or

mkvmerge -o output.mp4 video.mp4 subtitles.srt

In the case you need subtitle conversion:

ffmpeg -i file.srt file.vtt

or

ffmpeg -i file.vtt file.srt

More info in the ffmpeg manual ("man ffmpeg").

How to download only subtitles of videos using youtube-dl

Options:
--write-sub                      Write subtitle file
--write-auto-sub                 Write automatic subtitle file (YouTube only)
--all-subs                       Download all the available subtitles of the video
--list-subs                      List all available subtitles for the video
--sub-format FORMAT              Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"
--sub-lang LANGS                 Languages of the subtitles to download (optional) separated by commas, use IETF language tags like 'en,pt'

So for example, to list all subs for a video:

youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw

To download all subs, but not the video:

youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw

The other way, this really works but makes the file bigger:

mencoder movie.avi -sub movie.srt -o movie.hardsubs.avi -oac copy -ovc lavc -lavcopts vbitrate=1200

Source: Ubuntu Forums.


-----------///

Thursday, October 24, 2013

Converting Still Images to Video from the Command Line

ImageMagick and ffmpeg combined can be used to turn still images into video. Both ImageMagick and ffmpeg have been around for years, and are readily available as packages with most Linux distributions. The tips below allow you to convert images on the command line, which for a may appear to be time consuming, but once you know how to do it you'll find it much faster than using a GUI!

The Packages
You'll need:
ImageMagick
ffmpeg


Resizing Images from the Command Line
ImageMagick includes "mogrify" which is a fine tool for easily changing image size and resolution. Great for converting images for uploading to the web, or preparing large images for video. For example, the following code re-sizes all *.JPG images to a maximum width of 800 pixels and a maximum height of 600 pixels. This will over-write the originals, so take copies of your snaps first!

mogrify -resize 800x600 *.JPG

Morphing Images Together
This step is only needed if you want to create a smooth transition between the images.

Another fine part of ImageMagick is the ability to morph images together. In the following example we take all *.JPG files and create 10 images for each "gap" between the images. The resulting set of images are saved as XXXXX.morph.jpg, where X is the next number in the series.

convert *.JPG -delay 10 -morph 10 %05d.morph.jpg

Creating a Video from Images
ffmpeg can be used to stitch several images together into a video. There are many options, but the following example should be enough to get started. It takes all images that have filenames of XXXXX.morph.jpg, where X is numerical, and creates a video called "output.mp4". The qscale option specifies the picture quality (1 is the highest, and 32 is the lowest), and the "-r" option is used to specify the number of frames per second.

ffmpeg -r 25 -qscale 2 -i %05d.morph.jpg output.mp4

Putting It All Together
Here's a simple example of how to create a video from the command line, using the resizing and morphing techniques we have gone through above. The example first creates a "temp" directory to work in, so we don't risk destroying the original images. Note: the morphing stage may take a while, so be patient!

mkdir temp
cp *.JPG temp/.
mogrify -resize 800x800  temp/*.JPG
convert temp/*.JPG -delay 10 -morph 10 temp/%05d.jpg
ffmpeg -r 25 -qscale 2  -i temp/%05d.jpg output.mp4
# rm -R temp

The Code Used

# Create a directory and copy the original images there for manipulation:
mkdir temp
cp *.JPG temp/.

# Resize the images:
mogrify -resize 200x200  temp/*.JPG
# Create the morph images
convert temp/*.JPG -delay 10 -morph 5 temp/%05d.jpg
# Stitch them together into a video
ffmpeg -r 50 -qscale 2  -i temp/%05d.jpg output.mp4

---------------------------///
In order to make a video out of still images, like in a Power Point or Libre Office Impress, I created one image from every slide starting from a blanc one, naming them form 000.rdp.jpg to 025.rdp.jpg, then I used the command:

avconv -r .1 -qscale 2 -i %03d.rdp.jpg output.mp4

The "-r .1" gave 10 seconds lapse for every slide.


----------
Source: It For Everyone.

Creating an ISO image

Create a cdrom image
sudo dd if=/dev/cdrom of=cd.iso

Create a dvd image
sudo dd if=/dev/dvd of=dvd.iso

Create a scsi cdrom image
For a SCSI CDROM image, your device is probably called /dev/scd0
sudo dd if=/dev/scd0 of=cd.iso

Create an ISO image from files in a directory
To create an ISO image from files within a directory is just as simple. State an output directory and name of the ISO to create, along with a source directory. For example:
mkisofs -o /home/linuxlookup/example.iso /source/directory/

Another way to make any Linux directory into an ISO file:

mkisofs -V LABEL -r DIRECTORY | gzip > cdrom.iso.gz

Using GENISOIMAGE to Create ISO-9660 CD-ROM filesystem
sudo apt-get install genisoimage

To create a vanilla ISO9660 filesystem image of directory:
genisoimage -o cd.iso cd_dir

In the next command the -r and -J ensures long file names work for Unix (using Rock Ridge) and Windows (using Joliet extensions).
genisoimage -r -J -o cd_image.iso /directory

Mounting an image

mkdir -p /mnt/isoimage

mount -o loop -t iso9660 cd.iso /mnt/isoimage


Unmounting

umount -lf /mnt/isoimage

Wednesday, December 26, 2012

How to Put a Password on a PDF File on Linux

First you need to have installed the "pdftk" application.


Then type this command into the terminal:
pdftk  original.pdf  output  new.pdf  user_pw  PROMPT

Replace "Original.pdf" with the original name and change "new.pdf" to a name of your choice. Enter a password when prompted. You will now have a password protected PDF.


Saturday, November 17, 2012

How to play movies with subtitles in mplayer

The basic command is:
$ mplayer name_of_movie.avi -vobsub name_of_subtitle 

As you can note, the name of the subtitle is written without any extension which usually are '.idx', '.ifo' or '.sub'.
The next command will do exactly the same than the first:
$ mplayer name_of_movie.avi -vobsub name_of_subtitle -vobsubid 0

If there is a second language available in the captions then you do:
$ mplayer name_of_movie.avi -vobsub name_of_subtitle -vobsubid 1

The name of the subtitles has to be exactly the same than the name of the movie.

Monday, August 08, 2011

Procedure to mount ISO images under Linux

Link to source.

1) You must login as a root user, if not root user then switch to root user using following command:
$ su -

2) Create the directory i.e. mount point:
# mkdir -p /mnt/disk

3) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk

4) Change directory to list files stored inside an ISO image:
# cd /mnt/disk
# ls -l

Setting date and time on Linux/Unix

date mmddhhmi

where:
mm = month
dd = day of month
hh = hour
mi = minute

Example for today date:
sudo date 08081530

Another way, set new data to 8 August 2011 15:30:00, type the following command as root user:
# date -s "8 AUG 2011 15:30:00"

OR
# date --set="8 AUG 2011 15:30:00"

You can also simplify format using following syntax:
# date +%Y%m%d -s "20110808"

Linux Set Time
To set time use the following syntax:
# date +%T -s "15:30:00"

Tuesday, May 24, 2011

Ubuntu Tip: Howto reduce PDF file size from command line

Link to the source.

If you want to reduce PDF file size using command line you can use ghostscript.Ghostscript is used for PostScript/PDF preview and printing. Usually as a back-end to a program such as ghostview, it can display PostScript and PDF documents in an X11 environment.

Furthermore, it can render PostScript and PDF files as graphics to be printed on non-PostScript printers. Supported printers include common dot-matrix, inkjet and laser models.

Package gsfonts contains a set of standard fonts for Ghostscript.

Use the following command syntax to reduce your pdf files

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Replace your file names output.pdf, input.pdf files with your file names.

This is only example you can check man gs command for more options.

For  greater file size reduction, change /ebook for /screen but the resolution might not be good enough.

If you want to install ghostscript use the following command

sudo apt-get install ghostscript

------------
Note: You can achieve great reduction in file size using the commands pdftops and then ps2pdf.

Also you can use pdf2ps and then ps2pdf.

Or using the following script from here, and a copy of it here. The usage is the following:
./shrinkpdf.sh  in.pdf  out.pdf
We can optionally specify an output resolution in DPI (default is 72 DPI):
./shrinkpdf.sh  in.pdf  out.pdf  90

--

Friday, April 08, 2011

How To Set Up Journaled Quota On Scientific Linux 6

As you already know, Scientific Linux 6 is a clon of RHEL 6, so this instructions should work for CentOS 6 too.

First do:
yum install quota

Also you have to edit the edit the /etc/fstab and add:
usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0

If you do not need to set quotas for groups then omit the grpjquota=aquota.group as I did, thenin my fstab I have this:

/dev/mapper/vg_aguila-lv_root   /   ext4   defaults,usrjquota=aquota.user,jqfmt=vfsv0   1  1
UUID=8768d821-e441-40fd-ac08-6ef7b6234d0f  /boot  ext4  defaults  1  2
/dev/mapper/vg_aguila-lv_swap  swap  swap  defaults  0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0


After that you need to use the following commands:
touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /

quotacheck -avugm
quotaon -avug

if you need to turn the quotas off then do:
 quotaoff /
or the equivalent
quotaon -f /

The quota system is ready to go, now we have to set the quotas for every user:
 edquota -u username

And we get:

Disk quotas for user username (uid 501):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg_aguila-lv_root         36        0          0         10        0        0


The system automatically uses the default editor.
If we want to set 5MB of quota for username then we edit the file to:

Disk quotas for user username (uid 501):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg_aguila-lv_root         36       5000          0         10        0        0




------
Related links:
Quotas on Debian Lenny
RHEL 6 Quotas
faqs.org

Thursday, February 03, 2011

How To Create An ISO Image Of Directory / Filesystem

To create CD ISO image of directories that contain long file name or non-8.3 format (particularly if you want to burn the CD image for use in Windows system), use the -J option switch that generates Joliet directory records in addition to regular iso9660 file names.

mkisofs   -o   MyDirectory.iso   -J   MyDirectory

Wednesday, February 10, 2010

Migrate users from one Linux machine to another

Have you ever had a need to migrate current running Linux users from installation to another? That would be a simple task if the user count was low. But what happens when the user count is in the hundreds? What do you do then? If you’re not using LDAP, you know you will have to migrate the users’ data, passwords, etc from the old machine to the new. Believe it or not, this is just a matter of a few commands – not necessarily simple commands, but it’s not as complex as you would think.

In this article I am going to show you how to make this migration so your Linux users do not loose their data and their passwords are all retained.

What we're migrating

The list is fairly simple:

/etc/passwd - Contains information about the user.
/etc/shadow - Contains the encrypted passwords.
/etc/group - Contains group information.
/etc/gshadow - Contains group encrypted passwords.
/var/spool/mail - Contains users email (the location will depend upon the mail server you use).
/home/ - Contains users data.
Unfortunately these files can not simply be copied from one machine to another – that would be too easy. Just make sure you enter the following commands correctly.

Source machine

These are the commands you will need to run on the machine you are migrating users FROM. I will assume you are doing this on a system that uses a root user (such as Fedora), so all commands will be done as root:

mkdir ~/MOVE

The above command creates a directory to house all of the files to be moved.

export UGIDLIMIT=500

The above command sets the UID filter limit to 500. NOTE: This value will be dictated by your distribution. If you use Red Hat Enterprise Linux, CentOS, or Fedora this value is shown in the command above. If you use Debian or Ubuntu that limit is 1000 (not 500).

awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > ~/MOVE/passwd.mig

The above command copies only user accounts from /etc/passwd (using awk allows us to ignore system accounts.)

awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/group > ~/MOVE/group.mig

The above command copies the /etc/group file.

awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534) {print $1}’ /etc/passwd | tee – |egrep -f – /etc/shadow > ~/MOVE/shadow.mig

The above command copies the /etc/shadow file.

cp /etc/gshadow ~/MOVE/gshadow.mig

The above command copies the /etc/gshadow file.

tar -zcvpf ~/MOVE/home.tar.gz /home

The above command archives /home.

tar -zcvpf ~/MOVE/mail.tar.gz /var/spool/mail

The above command archives the mail directory. NOTE: If you are using Sendmail this is the correct directory. If you are using Postfix that directory most likely will be /etc/postfix.

Now it’s time to move everything in ~/MOVE over to the new server. You can do this using the scp command like so:

scp -r ~/MOVE/* USER@IP_OF_NEW_SERVER:/home/USER/

Where USER is the username you will use to send the file and IP_OF_NEW_SERVER is the address of the new server. NOTE: If this server is not on line yet you can always copy these files onto a thumb drive and move them that way.

Target machine

Now we’re working on the new server. Follow these commands (run as the root user):

mkdir ~/newsusers.bak

The above command will create a new directory that will house the backup of the current users.

cp /etc/passwd /etc/shadow /etc/group /etc/gshadow ~/newsusers.bak

The above command will copy the necessary files to the new backup directory.

cd /PATH/TO/DIRECTORY
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
/bin/cp gshadow.mig /etc/gshadow

The above commands will restore all password files onto the new system. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.

cd /
tar -zxvf /PATH/TO/DIRECTORY/home.tar.gz

The above commands will first change you to the / directory and then unpack the archived /home directory. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.

cd /
tar -zxvf /PATH/TO/DIRECTORY/mail.tar.gz

The above commands will first change you to the / directory and then unpack the archived/var/spool/mail directory. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.

You can now reboot your system with the users in place.
----------
Source: ghacks.net

Monday, January 04, 2010

BibTeX in 60 seconds

[Link to source]
Ok, so you just want to give it a whirl. No worries, just:

  1. Download a bibliography style file such as h-physrev3.bst, into the directory where your document is. (There are many options about - just look around the web.)
  2. Create your bibliography database file by downloading (into the directory where your document is) and editing the example file tau.bib.
  3. Remove any \begin{thebibliography} ... \end{thebibliography} commands from your document.
  4. Just before the \end{document} command, add
    \bibliographystyle{h-physrev3.bst}
    \bibliography{tau}
    (Alternatively, just download and edit this example file.)
  5. When processing the file, you need to do: latex filename, bibtex filename, latex filename, latex filename.
Another useful reference to this is in the Reed College.

Friday, November 27, 2009

How to convert a JPG file to PDF

You need to have installed "ImageMagick" or "GraphicsMagick"
In Ubuntu or Debian you can install it with the command:
sudo apt install imagemagick

or
sudo apt install graphicsmagick

Then you go to your work directory.
cd my/work/directory/path
And write the command
convert myfile.jpg myfile.pdf

Or with GraphicsMagick
gm convert file.jpg file.pdf

To convert multiple images:
gm convert file1.png file2.png file3.jpg file.pdf

For more, just run:
man gm

With ImageMagick you can also convert multiple JPG files into one multi-image PDF
convert *.jpg -adjoin myfiles.pdf

To merge multiple PDFs into one file:

$ pdftk file1.pdf file2.pdf file3.pdf cat output file123.pdf

CONVERTING  WITH  IMG2PDF

sudo apt install img2pdf

img2pdf --pagesize Letter input.jpg -o output.pdf

man img2pdf 



=====///////

Sunday, October 11, 2009

Create, mount and copy floppy disks images under Linux

If we need it we can create an empty image and mount it using linux's loop devices.
(link to page)

Creating an empty floppy image (1.44MB):
$ dd bs=512 count=2880 if=/dev/zero of= /path/imagefile.img
Format it:
$ mkfs.msdos /path/imagefile.img

There's a more direct way to do this.
Create & format a floppy image of 1.44 MB:
$ /sbin/mkfs.msdos -C /path/imagefile.img 1440

Mounting it:
$ sudo mkdir /media/floppy1/
$ sudo mount -o loop /path/imagefile.img /media/floppy1/

If you want to transfer some files to Windows in VirtualBox then, after copying your files into the floppy image, you have to umount the image.
$ umount /media/floppy1

Now in VirtualBox you start Windows and mount the floppy image (Devices ==> Mount Floppy ==> Floppy Image) as you see in the picture.

Then you can transfer the files from the floppy image to Windows. Do not forget to unmount the floppy image once you're done or you'll get an error next time you try to boot into Windows. This is because the virtual machine tries to boot first from the floppy image.
In case you need to transfer bigger files, instead of a floppy image you can use a CDROM image. If you already have the files in a CD, that's easier since you can directly mount the CD.

Sunday, October 04, 2009

Password-Protect Compressed Zip Archives

(link to note)
The Zip program allows you to password-protect your Zip archives using the -P option. You shouldn't use this option. It's completely insecure, as you can see in the following example (the actual password is 12345678):

$ zip -P 12345678 moby.zip *.txt

Because you had to specify the password on the command line, anyone viewing your shell's history (and you might be surprised how easy it is for other users to do so) can see your password in all its glory. Don't use the -P option!

Instead, just use the -e option, which encrypts the contents of your Zip file and also uses a password. The difference, however, is that you're prompted to type the password in, so it won't be saved in the history of your shell events.

$ zip -e moby.zip *.txt
Enter password:
Verify password:
adding: job.txt (deflated 65%)
adding: moby-dick.txt (deflated 61%)
adding: paradise_lost.txt (deflated 56%)

The only part of this that's saved in the shell is zip -e moby.zip *.txt. The actual password you type disappears into the ether, unavailable to anyone viewing your shell history.

Caution - The security offered by the Zip program's password protection isn't that great. In fact, it's pretty easy to find a multitude of tools floating around the Internet that can quickly crack a password-protected Zip archive. Think of password-protecting a Zip file as the difference between writing a message on a postcard and sealing it in an envelope: It's good enough for ordinary folks, but it won't stop a determined attacker.

Also, the version of zip included with some Linux distros may not support encryption, in which case you'll see a zip error: "encryption not supported." The only solution: recompile zip from source. Ugh.

----------
In case you want to ZIP a directory, this is the command:
zip  -re  myDirectory.zip  myDirectory

Monday, September 28, 2009

Tuesday, August 25, 2009

How to create a custom Ubuntu distro

(link to note)
*Get the packaged you need
sudo apt-get install squahfs-tools mkisofs

*Load the squashfs
sudo modprobe squashfs

create a iso image of Dapper CD
* confirm that cdrom is not mounted, if it is then
sudo umount /cdrom

* dd if /dev/hdc of=/pathtoiso/image.iso
else dd if /dev/cdrom of=/pathtoiso/image.iso

* Create a working directory
mkdir ~/custom

* move the iso to custom
mv /pathtoiso/image.iso ~/custom
cd ~/custom

* mount the image.iso
mkdir mnt
sudo mount -o loop image.iso mnt

* get the contents of iso in to a local dir
mkdir extract
rsync –exclude=/casper/filesystem.squashfs -a mnt/ extract

*Mount squashfs
mkdir squahfs
sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs
mkdir tmp
sudo cp -r squashfs/* edit

*Mount the root
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
export HOME=/root

*Customization
Now you have all the settings ready and you can readily customise by apt-get
for eg, to add mplayer
sudo apt-get install mplayer

*The default backgrounds and splashscreens can be simpley copied .

*Edit LiveCD user
sudo vi edit/usr/share/initramfs-tools/scripts/casper-bottom/10adduser
sudo vi edit/usr/share/initramfs-tools/scripts/casper

*Cleanup
rm -rf /tmp/*
umount /proc
umount /sys
exit

chmod +w extraxt/casper/filesystem.manifest
sudo chroot edit dpkg-query -W –showformat=’${Package} ${Version}\n’ > extract/casper/filesystem.manifest
sudo cp extract/casper/filesystem.manifest extract/casper/filesystem.manifest-desktop
sudo sed -ie ‘/ubiquity/d’ extract/casper/filesystem.manifest-desktop
sudo mksquashfs edit extract/casper/filesystem.squashfs
sudo vim extract-cd/README.diskdefines

*Generate new md5sum
sudo -s
rm extract/md5sum.txt
(cd extract && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)
exit

*Create the iso
cd extract
sudo mkisofs -r -V “$IMAGE_NAME” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../custom.iso .

*You can test the cd by
qemu -cdrom custom.iso -boot d

*Burn the iso using k3b or nautilus-cd-burner
or
cdrecord dev=/dev/hdc custom.iso

Friday, May 29, 2009

Converting VOB or MP4 to FLV format

FLV file converter in Linux
(link to page)
Using "mencoder" to create "flv" from "VOB" DVD video format files

Many websites nowadays are using swf and flv file formats to play videos hosted on their site or sites, it's advantage is clear in that the file itself is often in comparison to regular video format files, smaller and easier to upload so the site is able to hold and run more video content with much less bandwidth than would normally be required.

#> mencoder inputfile.VOB -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=150 -ofps 25 -oac mp3lame -lameopts abr:br=32 -srate 22050 -vf scale=720 -o outputfile.flv

In our first test video conversion format a file named VTS_01_2.VOB was successfully converted from a 776.9Mb file to a 17mb outputfile.flv although the video and audio was brilliant the file stopped short of it's actual completion target in other words outputfile.flv was considerably shorter than it should have been, we have concluded from this that the VOB file is corrupt and the conversion terminates at that point. Having obtained another dvd with which to copy from we tried again, you should not this recording was original obtained from a small video recorder and transfered to DVD which we then migrated to a flash video (flv). Below is how we archived it, please note the above mencoder script is different to the one below which did eventually work.

#> mplayer dvd://1 -dumpstream -dumpfile myvideo.vob
#> mencoder myvideo.vob -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=150 -ofps 25 -oac mp3lame -lameopts abr:br=32 -srate 8000 -vf scale=720 -o outputfile.flv

It is important to note the above "mplayer" command it does not play the file not visibly at least but dumps or rips 1 or more VTS_01_n.VOB files into a single "vob" extension file that can then be converted into a video file format you require. The input file has been altered to reflect the file output from mplayer and "-srate" has been altered to "8000". If you think a graphical user interface is the way to go you may be right it would take a lot of the guess work and fun out of using command line, but for now command line seems much better than "gui". Ahh problems with the above it turns out with an "-srate of 8000" you might get some rapid clicking when transfered to a website or you tube, through some investigation and some trial and error we came up with the following which you might think is much better.

#> mplayer dvd://1 -dumpstream -dumpfile myvideo.vob
#> mencoder myvideo.vob -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=150 -ofps 25 -oac mp3lame -lameopts abr:br=32 -srate 44100 -vf scale=720 -o outputfile.flv

The "flv" format files can only support 8000, 22050 and 44100 I believe for the available -srate.
----------------------------------
Converting MP4 to FLV
ffmpeg -i myvideo.mp4 -ar 44100 myvideo.flv

Monday, March 30, 2009

Graphs with PyXPlot

These are the contents of mydata.dat file:
--------------------------------------
8 4.3950
16 7.7879
24 11.0650
32 14.4312
40 17.3884
48 21.6769
56 23.7509
64 27.7398
72 31.5975
80 35.7720
88 39.2403
96 44.0992
----------------------------
Note: The separation between numbers is a tab space.
-------------------------------------------
$ pyxplot

____ __ ______ _ _ PYXPLOT
| _ \ _ _\ \/ / _ \| | ___ | |_ Version 0.6.3.1
| |_) | | | |\ /| |_) | |/ _ \| __| 26/02/2007
| __/| |_| |/ \| __/| | (_) | |_
|_| \__, /_/\_\_| |_|\___/ \__| Copyright (C) 2006-7 Dominic Ford
|___/

With thanks to Joerg Lehmann and Andre Wobst for writing PyX, and to
Ross Church for his many helpful suggestions along the way.

Send comments, bug reports, feature requests and coffee supplies to:
coders@pyxplot.org.uk

pyxplot> set ylabel 'Average'
pyxplot> set xlabel 'n'
pyxplot> plot 'mydata.dat'
pyxplot> exit

Goodbye. Have a nice day.

coders@pyxplot.org.uk
------------------------------------
Other examples:
Bar Charts

Script

set multiplot
set nodisplay
set samples 25
width=7
gold_ratio = 1/((1+sqrt(5))/2)

set width width
set xrange [-10.9:10.9]
set yrange [-1.2:1.2]
set nokey

# Plot 0 (bottom left)
set xlabel 'x'
set ylabel 'y'
set label 1 '(a)' at -9,0.8
set label 2 'histeps' -3.7,0.8
plot 'example6.dat' with histeps, 'example6.dat' with points

# Plot 1 (bottom right)
set origin 1*width, 0*width*gold_ratio
set xlabel 'x'
set ylabel 'linkaxis 0'
set label 1 '(b)' at -9,0.8
set label 2 'boxes' -3.7,0.8
plot 'example6.dat' with boxes, 'example6.dat' with points

# Plot 2 (middle left)
set origin 0*width, 1*width*gold_ratio
set xlabel 'linkaxis 0'
set ylabel 'y'
set label 1 '(c)' at -9,0.8
set label 2 'fsteps' -3.7,0.8
plot 'example6.dat' with fsteps, 'example6.dat' with points

# Plot 3 (middle right)
set origin 1*width, 1*width*gold_ratio
set xlabel 'linkaxis 1'
set ylabel 'linkaxis 2'
set label 1 '(d)' at -9,0.8
set label 2 'steps' -3.7,0.8
plot 'example6.dat' with steps, 'example6.dat' with points

# Plot 4 (top left)
set origin 0*width, 2*width*gold_ratio
set xlabel 'linkaxis 0'
set ylabel 'y'
set label 1 '(e)' at -9,0.8
set label 2 'impulses' -3.7,0.8
plot 'example6.dat' with impulses, 'example6.dat' with points

# Plot 5 (top right)
set origin 1*width, 2*width*gold_ratio
set boxfrom -0.5
set xlabel 'linkaxis 1'
set ylabel 'linkaxis 4'
set label 1 '(f)' at -9,0.8
set label 2 'boxes' -3.7,0.8
plot 'example6.dat' with boxes, 'example6.dat' with points

set display
refresh

Sunday, March 29, 2009

Python: Random numbers

(link to webpage)


>>> random.random() # Random float x, 0.0 <= x <>
0.37444887175646646
>>> random.uniform(1, 10) # Random float x, 1.0 <= x <>
1.1800146073117523
>>> random.randint(1, 10) # Integer from 1 to 10, endpoints included
7
>>> random.randrange(0, 101, 2) # Even integer from 0 to 100
26
>>> random.choice('abcdefghij') # Choose a random element
'c'

>>> items = [1, 2, 3, 4, 5, 6, 7]
>>> random.shuffle(items)
>>> items
[7, 3, 2, 5, 6, 4, 1]

>>> random.sample([1, 2, 3, 4, 5], 3) # Choose 3 elements
[4, 1, 5]

---------------------------------
Using the Random Module
(link)
>>>
import random

>>> # 0.0 <= float <>
>>> random.random()
0.41360177662769904

>>> # 10.0 <= float <>
>>> random.uniform(10,20)
15.743669918803288

>>> # 10 <= int <= 20 (can be 20)
>>> random.randint(10,20)
10

>>> # 10 <= int < step="2) random.randrange(10,20,2)
16

>>> # choose from a list
>>> random.choice([1, 2, 3, 5, 9])
2

>>> # make a list into random order
>>> cards = range(52)
>>> random.shuffle(cards) # order is random now
>>> cards[:5] # get 5 cards
[37, 14, 42, 44, 6]
-------------------------------------------

Wednesday, March 04, 2009

Mommy, I found it! — 15 Practical Linux Find Command Examples

One very basic example with the command 'find':
find . -name '*.txt' -type f

(link to article)
This article is written by SathiyaMoorthy
Apart from the basic operation of looking for files under a directory structure, you can also perform several practical operations using find command that will make your command line journey easy.

In this article, let us review 15 practical examples of Linux find command that will be very useful to both newbies and experts.

Monday, March 02, 2009

Configuring a printer

With the next command you can call the printer GUI configurator in Ubuntu.

$ sudo system-config-printer


Saturday, February 14, 2009

rtorrent

# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
#max_peers_seed = 50

# Maximum number of simultanious uploads per torrent.
max_uploads = 2

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 5

# Default directory to save the downloaded torrents.
#directory = ./

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
#session = ./session

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.
schedule = low_diskspace,5,60,close_low_diskspace=100M

# Stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent.
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
#schedule = ratio,60,60,"stop_on_ratio=200,200M,2000"

# The ip address reported to the tracker.
#ip = 127.0.0.1
ip = rakshasa.no

# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no

# Port range to use for listening.
#port_range = 6890-6999

# Start opening ports at a random position within the port range.
#port_random = no

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
#check_hash = no
# Set whetever the client should try to connect to UDP trackers.
#use_udp_trackers = yes

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# encryption = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
# dht = auto

# UDP port to use for DHT.
#
# dht_port = 6881
# Enable peer exchange (for torrents not marked private)
#
# peer_exchange = yes

#
# Do not modify the following parameters unless you know what you're doing.
#

# Hash read-ahead controls how many MB to request the kernel to read
# ahead. If the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read
# pages in memory thus end up trashing.
#hash_read_ahead = 10

# Interval between attempts to check the hash, in milliseconds.
#hash_interval = 100

# Number of attempts to check the hash while using the mincore status,
# before forcing. Overworked systems might need lower values to get a
# decent hash checking rate.
#hash_max_tries = 10

Monday, November 10, 2008

HOWTO: Use dpkg to Install .deb Files.

by Jon on November 27th, 2005

I’ve written about using apt-get to get and install debian packages. However, a recent comment by a reader brought the fact that I hadn’t written anything on what to do with a .deb file that exists on your system already either by download or other media.

Using the apt-get application is the quickest way to find and install debian packages. The installation part is done by an application
named dpkg. Dpkg doesn’t have to be used by apt-get, you can use it manually as well.

From the man dpkg command:

dpkg - a medium-level package manager for Debian

Whatever that means.

In keeping with GNU/Linux system security, only the superuser can use the dpkg application. Dpkg is a typical GNU/Linux application that is controlled by command-line switches. Possibly the most common use of dpkg is to install a local .deb file.

To install a .deb file, become root and use the command:

dpkg -i filename.deb

Dpkg can also be used to:

* dpkg –unpack: unpacks the file but does not install it
* dpkg –configure: presents whatever configuration options are available for the package
* dpkg –remove: removes a package

Some of the package manipulation commands are actually carried out by an application called dpkg-deb. In those cases, dpkg just acts as a front end to dpkg-deb and passes the commands to it.

Dpkg-deb can also be used to manipulate .deb files. Some of the more useful commands of dpkg-deb are:

dpkg-deb –show filename.deb

This will display the information for filename.deb. Normally, this is boring information like the application version (which is normally evident from the filename), but in some cases more interesting and useful information is displayed.

Consult the dpkg man page for information on the more arcane uses for dpkg.