Tuesday, February 28, 2012

FFMPEG with x264: another option

http://ubuntuforums.org/showthread.php?t=786095

Monday, February 27, 2012

KISS (Keep It Simple Stupid) FFMPEG

How to remove jitter from the first couple of seconds of Nikon DSLR video, and keep only 60 seconds.

$ lav2yuv +n DSC_0000.AVI > dsc0000.yuv
$ ffmpeg -i dsc0000.yuv -ss 3 -t 60 -y -s vga dsc0000.mp4
$ mediainfo dsc0000.mp4

...asumming you want to convert the MJPEG original to MPEG-4, of course....

By the way, my Nikon outputs 1280x720 HD video (hd720 in FFMPEG-speak). No Full HD (aka hd1080) from this baby.

Sunday, February 26, 2012

Video Quality Analysis

Things scrubbed from Internet so far:
I hope the links won't disappear before I can use them. To use the second Python program, I had to install Python Imaging Library and Python Levenshtein.
# yum install python-imaging python-Levenshtein
The Levenshtein distance is a string metric for measuring the amount of difference between two sequences (Wikipedia).

Saturday, February 25, 2012

Minimal RAR in Fedora

Working with RAR files in Fedora is not as easy as in Ubuntu.

We can download RAR package from http://www.rarlab.com/download.htm

# wget http://www.rarlab.com/rar/rarlinux-4.1.1.tar.gz

Untar file and install RAR.

# tar zxvf rarlinux-4.1.1.tar.gz
# cd rar
# make
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib

After all the above, you can use rar and unrar commands.


Creating an archive:

$ rar a archivename.rar files...

Add as many files & directories as you want.

Creating an archive with password:

$ rar a -ppassword archivename.rar files...

There is no space between -p and the password itself.

To extract, click on the right-mouse-button and use Archive Manager to extract.

Of course, for more advanced uses, refer to the RAR in Ubuntu Manual.

Friday, February 24, 2012

Fedora First Login

Here's my TO DO list on a fresh Fedora installation.

1. Update the OS and install "important" software.

$ su -
password
# yum update
# yum install -y eclipse gimp inkscape geany texmaker ffmpeg vlc opencv
# yum install gnome-tweak-tool

2. Install Google Chrome by creating the file /etc/yum.repos.d/google.repo and adding these lines.

[google-chrome]
name=google-chrome - 32-bit
baseurl=http://dl.google.com/linux/chrome/rpm/stable/i386
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

Then, install Chrome by:

# yum install -y yum install google-chrome-stable

3. Run gnome-tweak-tool:

$ gnome-tweak-tool

4. Enable RPMfusion repository.

# yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Then can install free software such as rar
# yum install rar

Note: it's still better to install RAR from the original site.
5. Install JabRef.

Download the JAR file.
# wget http://downloads.sourceforge.net/project/jabref/jabref/2.7.2/JabRef-2.7.2_01.jar
Then create a shortcut somewhere, like on the desktop.
[Desktop Entry]
Name=Jabref
GenericName=Jabref
Exec=java -jar /home/maczulu/JabRef-2.7.jar
Icon=jabref
Terminal=false
Type=Application

6. Install MediaInfo.

Install each RPM in the proper sequence.


7. Install Fedora Utils etc

Wednesday, February 15, 2012

Converting AVI to Dirac

FFMPEG understands Dirac. So here's the command to convert MJPEG/AVI to Dirac. Use MKV extension for the output file to keep the sound.

$ ffmpeg -i t1.avi -vcodec libschroedinger t1.drc

It can be done the long way, by converting to YUV first:

$ lav2yuv +n DSC_0023.AVI > tmp.yuv
$ ffmpeg -i tmp.yuv -vcodec libschroedinger t1.drc

From a 55.2 MB AVI/MJPEG file with audio and 720x480 video, a 729.9 MB YUV420 file is produced.

Encoding to Dirac directly from AVI, results in a 562.4 KB file.
Encoding to MKV from AVI produces a 563.9 KB file.

Compare that to 6.8 MB H.264 file produced form YUV420.
$ ffmpeg -i tmp.yuv -vcodec libx264 t1.mp4
Note: FFMPEG crashes when converting directly from AVI to H.264.

Summary for File 1:

CodecMJPEGYUVDirac (.DRC)
Dirac (.MKV)
H.264
File size (MB)
55.2
729.9
0.562
0.563
6.8
Compression ratio (x)
13.22
1
1297.8
1294.4
107.3

But that's not the whole story. The quality of the Dirac video is so bad...because I used libschroedinger.

Here's the results for File 2, using libdirac switch:

CodecMJPEG
YUV
Dirac (.DRC)H.264(.MP4)
File size (MB)
47.0
1891.1
3.4
8.1
Compression ratio (x)
40.2
1
556.2
233.5

Suddenly, Dirac doesn't look so bad.

Tuesday, February 14, 2012

Converting AVI to YUV to H264

Using FFMPEG to transcode directly from AVI/MJPEG won't work:

$ ffmpeg -i input.avi -vcodec libx264 output.mp4

Still trying to get the commands from the following article to work:

http://www.linuxjournal.com/article/9005

$ mencoder -vf format=i420 -nosound -ovc raw -of rawvideo -ofps 24 -o tmp.yuv input.avi

$ x264 -o output.mp4 --fps 24 --bframes 2 --crf 26 --subme 6 --analyse p8x8,b8x8,i4x4,p4x4 --input-res 720x480 tmp.yuv

Using the lav2yuv command produces a raw YUV file of exactly the same size playable in VLC. The one from mencoder produces garbage.


Another example x264 invocation from http://mewiki.project357.com/wiki/X264_Settings:

$ x264 --output /dev/null --fps 30000/1001 --input-res 720x480 input.yuv

Monday, February 13, 2012

Install Handbrake on Fedora 16

1. Enable the Missing Box Studio repo:

# yum localinstall -y http://repo.missingbox.co.nz/repo/linux/fedora/missingboxstudio-release-1-1.noarch.rpm  --nogpgcheck
2 Install Handbrake and libdvdcss (optional, if you want to rip DVDs):

# yum install HandBrake-gui libdvdcss

Friday, February 3, 2012

Converting Nikon D90 video to YUV

Not that straightforward, as it turned out. FFMPEG won't do it for you. So here goes:

$ sudo yum install mjpegtools
$ lav2yuv +n DSC_0023.AVI > test.yuv
   INFO: [lav2yuv] Norm set to NTSC
   INFO: [lav2yuv] chroma '422' recommended with this input
   INFO: [lav2yuv] set default chroma '420jpeg'
   INFO: [lav2yuv] Repeated frames (for error concealment): 0
$ lav2yuv +p -C 422 DSC_0023.AVI > test4.yuv
   INFO: [lav2yuv] Norm set to PAL
   INFO: [lav2yuv] Repeated frames (for error concealment): 0