Author: Vince

Convert flv to mp4

Convert flash videos (flv) to mp4 for viewing on your ipod.

ffmpeg -i FILE_NAME.flv -ar 22050 NEW_FILE_NAME.mp4

The -ar 22050 is the sample rate and it makes a big difference with audio quality. It is usually necessary to set a sample rate when encoding flv files because the MP3 encoder only supports rates of 11025, 22050, and 44100 Hz.

For practical uses you will probably want to take control over more of the quality settings for something that looks like:

ffmpeg -i video.mov -b 600k -r 24 -ar 22050 -ab 96k video.flv

These are the common settings and an explanation of what they do:

  • “-b 600k” selects a video bitrate of 600 kilobits per second. This is a compromise between quality and bandwidth (with older versions of FFmpeg you would use “-b 600”. Type “ffmpeg -h” to check which units are expected in your version);
  • “-r 24” selects 24 video frames per second;
  • “-ar 22050” selects an audio sample rate of 22050 Hz, which is sufficient for voice;
  • “-ab 96k” selects an audio bit rate of 96 kilobits per second; you could go a little lower for voice-only audio (with older versions of FFmpeg you would use “-ab 96”. Type “ffmpeg -h” to check.)

ffmpeg can also be used to convert to avi, wmv, mpg, and mov i believe.

More info found here and here where all of this info comes from.

scp a path with spaces

I find the easiset way to scp a path with spaces is like so:
scp username@host:”‘/this/is my path/with spaces/and this is my file.txt'” ./

Note the double quotes followed by a single qoute ( ” ‘ text ‘ “), and closed in reverse order. Your shell will ignore the double qoute and the remote shell will receive the single qoutes.

You can also escape it, but that’s kind of a pain. example:
scp username@host:/this/is\\ my\\ path/with\\ spaces/and\\ this\\ is\\ my\\ file.txt ./

My preferences is obvious.

Enable a Swap File in Linux

You can use a Swap File instead of a Swap Partition with the linux kernel 2.6. Yeah, old news, but I’ve still always used a partition out of habit. Time to change that habit!

1. Log in as root, or use sudo
2. Type following command to create 512MB swap file
sudo dd if=/dev/zero of=/swap.img bs=1024k count=512
could also do it this way (1024 * 512MB = 524288 block size)
sudo dd if=/dev/zero of=/swap.img bs=1024 count=524288
3. Format it as swap.
sudo mkswap /swap.img
4. Activate your swap file immediately
sudo swapon /swap.img
5. Optional, but I recommend activating the swap file on boot. Edit your /etc/fstab file and add the following:
/swap.img none swap sw 0 0
6. To verify that the swap is working type:
free -m

Links this information was taken from:
http://blog.mypapit.net/2007/07/how-to-add-linux-swap-file-if-you-dont-have-swap-partition.html
http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

Find your Ipod fwid

Linux
Connect your iPod
In terminal type sudo lsusb -v | grep -i Serial
Look for your iPod device, the FWID should be the 16 character long string shown.

Windows
If iTunes is installed FWID should be retrieved automatically.

Otherwise (XP or newer only):
Open the Control panel and got to Device manager
Find your iPod in the list of devices (probably under hard drives) and double click it
Go to Details tab and select Device Instance ID in the drop down box
The FWID is the 16 digit number near the end of the string shown

Mac
Connect your iPod
From the apple menu (top left of screen) select About this Mac and click More Info
(optional) Select Mini Profile in the View menubar
In the left column select Hardware and then USB
In the USB Device Tree you should see your iPod listed, select it
the FWID is the Serial Number listed in the lower box

Convert FLAC to ALAC

If you have a ipod you know it can’t play FLAC files. If you still want lossless quality music you’ll have to convert it to ALAC. This can be done very easily with ffmpeg. Here is how to do it:


ffmpeg -i input_flac_file -acodec alac outputfile.m4a

Here is a script to convert all flac files in a directory to alac.


#!/bin/bash
#get all flac files in a directory
#loop over all files
#get file name without extention
#run it through ffmpeg with the output file as the filename.m4a

for file in *flac
do
basename=`basename "$file" .flac`
ffmpeg -i "$file" -acodec alac "$basename".m4a;
done

Simple Way to Record TV with Ubuntu

Taken from this post.

This is how I record TV without installing mythtv.

1. Get mencoder

Code:


sudo apt-get install mencoder

2. Create the script (record.sh):
Code:


#!/bin/sh

# Duration of recording (in seconds)
DURATION=$1

CHANNEL=$2

# Filename (excluding extension)
FILE=$3\.avi

# Record from tv
mencoder tv:// -tv driver=v4l2:device=/dev/video0:channel=$CHANNEL:forceaudio:norm=NTSC-M:chanlist=us-cable:alsa:adevice=hw.0,0:immediatemode=0 \
-ovc xvid -xvidencopts bitrate=800 \
-oac pcm \
-endpos $DURATION -sws 1 -o $FILE

3. Make the script executable and run it:

Code:

chmod u+x record.sh
./record.sh 3600 3 heroes

Another script from here:


#!/bin/bash

if [ $# -ne 3 ]
then
echo "Usage: $0 channel seconds filename"
exit
fi

WIDTH=640
HEIGHT=480
MENCODER=/usr/bin/mencoder
AUDIO="-oac mp3lame -lameopts cbr:br=128:mode=3"
VIDEO="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=6400"
DSP="adevice=/dev/dsp"
TV=" -tv driver=v4l2:width=$WIDTH:height=$HEIGHT:outfmt=yuy2:input=0:device=/dev/v4l/video0:norm=NTSC:chanlist=us-cable:channel=$1:$DSP"
$MENCODER tv:// $TV $VIDEO $AUDIO -endpos $2 -ffourcc divx -o "$3.avi"