Open Source, Embedded Systems, Computer Vision, Computational Photography, Self-Improvement
Tuesday, February 28, 2012
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.
...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.
$ 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:
- Python recipe for evaluating PSNR metric of two YUV420 frames
- Fast image comparison with Python
- Video quality analysis
- tiny_psnr.c: part of FFMPEG
# yum install python-imaging python-LevenshteinThe 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
Untar file and install RAR.
After all the above, you can use rar and unrar commands.
Creating an archive:
Add as many files & directories as you want.
Creating an archive with password:
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.
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.
2. Install Google Chrome by creating the file /etc/yum.repos.d/google.repo and adding these lines.
Then, install Chrome by:
3. Run gnome-tweak-tool:
4. Enable RPMfusion repository.
Then can install free software such as rar
Note: it's still better to install RAR from the original site.
5. Install JabRef.
Download the JAR file.
6. Install MediaInfo.
Install each RPM in the proper sequence.
7. Install Fedora Utils etc
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.jarThen 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.
- libzen0 (http://downloads.sourceforge.net/zenlib/libzen0-0.4.24-1.i386.Fedora_16.rpm)
- libmediainfo0 (http://downloads.sourceforge.net/mediainfo/libmediainfo0-0.7.53-1.i386.Fedora_16.rpm)
- MediaInfoCLI (http://downloads.sourceforge.net/mediainfo/mediainfo-0.7.53-1.i386.Fedora_16.rpm)
- MediaInfoGUI (http://downloads.sourceforge.net/mediainfo/mediainfo-gui-0.7.53-1.i386.Fedora_16.rpm)
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.
It can be done the long way, by converting to YUV first:
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.
Summary for File 1:
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:
Suddenly, Dirac doesn't look so bad.
$ 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.mp4Note: FFMPEG crashes when converting directly from AVI to H.264.
Summary for File 1:
Codec | MJPEG | YUV | Dirac (.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:
Codec | MJPEG | 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
$ 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 --nogpgcheck2 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
Subscribe to:
Posts (Atom)