Rotate/flip video with ffmpeg

1. Flip video  vertically:

ffmpeg -i INPUT -vf vflip -c:a copy OUTPUT

2. Flip video horizontally:

ffmpeg -i INPUT -vf hflip -c:a copy OUTPUT

3. Rotate 90 degrees clockwise:

ffmpeg -i INPUT -vf transpose=1 -c:a copy OUTPUT

4. Rotate 90 degrees counterclockwise:

ffmpeg -i INPUT -vf transpose=2 -c:a copy OUTPUT

Tesseract OCR gui fix + romanian language patch

On Fedora first make sure you have Tesseract OCR installed (and romanian langpack):

sudo yum install tesseract tesseract-langpack-ron

Download and extract tesseract-gui from Sourceforge (version 2.8 was latest at the time of this writting and the patch below applies to this version):

http://sourceforge.net/projects/tesseract-gui/files/tesseract-gui/tesseract-gui-2/

Here is the romanian.patch:

--- tesseract-gui.py    2012-03-20 14:20:37.000000000 +0200
+++ tesseract-gui.py.ro    2012-11-29 19:55:19.721193111 +0200
@@ -1321,6 +1321,7 @@
                     self.LCdutch:"nld",\
                     self.LCgerman:"deu",\
                     self.LCfrench:"fra",\
+                    self.LCromanian:"ron",\
                     self.LCenglish:"eng"}
         self.ListLanguages={}
         nnfin=len(Languages)
@@ -1329,7 +1330,7 @@
         for lang in Languages.keys():
             #print Languages[lang]
             #print os.path.join(TESSDATA_PATH, Languages[lang] + ".lm")
-            if os.path.isfile(os.path.join(TESSDATA_PATH, Languages[lang] + ".cube.lm")) or os.path.isfile(os.path.join(TESSDATA_PATH, Languages[lang] + ".unicharset")):
+            if os.path.isfile(os.path.join(TESSDATA_PATH, Languages[lang] + ".cube.lm")) or os.path.isfile(os.path.join(TESSDATA_PATH, Languages[lang] + ".traineddata")):

                 self.ListLanguages[lang] = Languages[lang]
                 self.cmbLang.append_text(lang)
@@ -1508,6 +1509,7 @@
             self.LCfrench = "Francés"
             self.LCitalian = "Italiano"
             self.LCportuguese = "Portugués"
+            self.LCromanian = "Romanian"
             #--- tips spanish
             self.LCtooltips_tip = "Mostrar o esconder mensajes de ayuda"
             self.LCselimg_tip = "Seleccionar las imágenes a convertir en texto"
@@ -1590,6 +1592,7 @@
             self.LCfrench = "Français"
             self.LCitalian = "Italien"
             self.LCportuguese = "Portugais"
+            self.LCromanian = "Romanian"
             #--- tips french
             self.LCtooltips_tip = "Montrez ou masquer messages d'aide"
             self.LCselimg_tip = "Sélectionner des fichiers d'images à changer en texte"
@@ -1672,6 +1675,7 @@
             self.LCfrench = "Francese"
             self.LCitalian = "Italiano"
             self.LCportuguese = "Portoghese"
+            self.LCromanian = "Romanian"
             #--- tips italian
             self.LCtooltips_tip = "Mostrare o nascondere i messaggi di aiuto"
             self.LCselimg_tip = "Selezionare le immagini da convertire in testo"
@@ -1757,6 +1761,7 @@
             self.LCfrench = "French"
             self.LCitalian = "Italian"
             self.LCportuguese = "Portuguese"
+            self.LCromanian = "Romanian"
             #--- tips english
             self.LCtooltips_tip = "Show or hide tooltips"
             self.LCselimg_tip = "Selecting images to convert to text"
@@ -1922,7 +1927,7 @@
     #figure out where '/usr/share' is relative to the direcotry where we are located
     SHARE_PATH = os.path.join(os.path.split(os.path.abspath(sys.argv[0]))[0], "..", "share")
     TESSDATA_PATH = "."
-    for path in ("/usr/share/tessdata",
+    for path in ("/usr/share/tesseract/tessdata",
                  "/usr/local/share/tessdata",
                  os.path.join(SHARE_PATH, "tesseract-ocr", "tessdata")):
         if os.path.isdir(path):

Create romanian.patch in tesseract-gui-2.8/bin directory and apply.

patch -p0 < romanian.patch

Then install tesseract gui from tesseract-gui-2.8 with

make install

Romanian language should be available in the language selector from tesseract gui.

Converting bin/cue image to iso

In order to convert an bin/cue image to iso format (which can be easily mounted), bchunk is your friend. You can install it in Fedora from standard repository using yum:

sudo yum install bchunk

To convert “foo” bin/cue pair image to iso is strightforward:

bchunk foo.bin foo.cue foo.iso

Browse samba home dirs in Fedora 17

In order to browse shares in /home dir in Fedora 17, the following parameter must be enabled in selinux:

sudo setsebool -P samba_enable_home_dirs on

Finally working Nvidia Optimus in Fedora

Notes: This applies to Fedora 17 & 18 with latest updates and was tested on Asus K93SV laptop with GT540M GPU (wrongly reported as GT555M by lspci in F17).

Now there is also an official page on Fedora wiki on this topic here: https://fedoraproject.org/wiki/Bumblebee.

1. Get latest bumblebee sources (3.0.1) from

https://github.com/Bumblebee-Project/Bumblebee/downloads

2. Get latest bbswitch sources (0.5)

https://github.com/Bumblebee-Project/bbswitch/downloads

3. Install libbsd-devel, kmod-nvidia and dkms as root or with sudo if they are not already installed:

sudo yum install libbsd-devel kmod-nvidia dkms

After installing kmod-nvidia, remove /etc/X11/xorg.conf, /etc/X11/xorg.conf.d/00-nvidia.conf and /etc/modprobe.d/blacklist-nouveau to continue using nouveau driver by default.

sudo rm -f xorg.conf
sudo rm -f /etc/X11/xorg.conf.d/00-nvidia.conf 
sudo rm -f /etc/modprobe.d/blacklist-nouveau.conf

I also removed “nouveau.modeset=0 rd.driver.blacklist=nouveau” kernel parameters from /etc/grub2.cfg for current kernel.

4. Compile bbswitch and install it with DKMS

From directory where you downloaded bbswitch:

tar xvzf bbswitch-0.5.tar.gz
sudo cp -Rv  bbswitch-0.5 /usr/src
sudo ln -s /usr/src/bbswitch-0.5/dkms/dkms.conf /usr/src/bbswitch-0.5/dkms.conf
sudo dkms add -m bbswitch -v 0.5
sudo dkms build -m bbswitch -v 0.5
sudo dkms install -m bbswitch -v 0.5

5. Download and install latest VirtualGL RPM from here:

http://www.virtualgl.org/Downloads/VirtualGL

sudo yum localinstall VirtualGL-2.3.1.x86_64.rpm

or install directly with yum from ‘updates-testing’ repo in Fedora 18:

sudo yum --enablerepo=updates-testing install VirtualGL

6. Compile & install bumblebee

tar xvzf bumblebee-3.0.1.tar.gz
cd bumblebee-3.0.1
./configure --prefix=/usr --sysconfdir=/etc 
make 
sudo make install 
sudo cp scripts/systemd/bumblebeed.service /lib/systemd/system

Edit /lib/systemd/system/bumblebeed.service line 7 to read:

ExecStart=/usr/sbin/bumblebeed --config /etc/bumblebee/bumblebee.conf

Edit /etc/bumblebee/bumblebee.conf and change:

Driver=nvidia

and in section [driver-nvidia]:

KernelDriver=nvidia

Edit /etc/bumblebee/xorg.conf.nvidia and add the following at the begining:

Section "Files"
    ModulePath   "/usr/lib64/xorg/nvidia"
    ModulePath   "/usr/lib64/xorg/modules"
EndSection

and the following at the end:

Section "Screen"
    Identifier "Screen1"
    Device "Device1"
EndSection

Create bumblebee group and add you to the group:

sudo groupadd bumblebee
sudo usermod -a -G bumblebee $USER

Enable and start bumblebeed service:

sudo systemctl enable bumblebeed.service
sudo systemctl start bumblebeed.service

7. Nvidia modules path fix (Thanks Tomash Brechko)

This completely separates intel and nvidia stuff for main and bumblebee screens respectively. Note that it moves files originating from RPMs around, so repeating the fix will likely be required after next yum update.

sudo rm /etc/ld.so.conf.d/nvidia-lib64.conf
sudo ldconfig
sudo cp -R /usr/lib64/xorg/modules/extensions/nvidia /usr/lib64/xorg
sudo rm -rf /usr/lib64/xorg/modules/extensions/nvidia

Re-run above commands after each kernel & kmod-nvidia upgrade.

Here is the output of dmesg succesfull message:

[ 2177.186042] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  304.32  Thu Aug  2 18:41:39 PDT 2012
[ 2179.880140] bbswitch: disabling discrete graphics
[ 2179.880331] bbswitch: Result of Optimus _DSM call: 11000059
[ 2179.891039] pci 0000:01:00.0: Refused to change power state, currently in D0
[ 2179.892219] pci 0000:01:00.0: power state changed by ACPI to D3
[ 2268.536424] bbswitch: enabling discrete graphics
[ 2269.060244] pci 0000:01:00.0: power state changed by ACPI to D0
[ 2269.060266] pci 0000:01:00.0: power state changed by ACPI to D0
[ 2269.101247] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=none,decodes=none:owns=none

8. Run applications on Nvidia GPU with optirun

optirun glxgears

1111 frames in 5.0 seconds = 222.122 FPS
1030 frames in 5.0 seconds = 205.921 FPS
1009 frames in 5.0 seconds = 201.757 FPS

Frame rates are on dual monitor 1920×1080 in Fedora17 with Gnome session.

Thanks to the developers of Bumblebee Project.

9. Primus

For speed imrovements you can use primus from https://github.com/amonakov/primus. Download, extract and compile, then run:

vblank_mode=0 ./primusrun glxgears

23359 frames in 5.0 seconds = 4671.624 FPS
23650 frames in 5.0 seconds = 4729.844 FPS
23659 frames in 5.0 seconds = 4731.731 FPS

Seems to be a big step forward. This is a replacement for VirtualGL.

10. Notes

Step 7 should be repeated on every kernel (and kmod-nvidia) upgrade.

Keep an eye on /etc/X11 and remove xorg.conf installed by kmod-nvidia. Also /etc/X11/xorg.conf.d/00-nvidia.conf (installed also by kmod-nvidia) should be removed.

Updated to bbswitch 0.5 and use kmod-nvidia. Step 5 is optional when using Primus. Tested on Fedora 18 and works OK.

Extracting pages from PDF files under Linux

If you need to extract some pages from a PDF file under Linux, you can easily do it with pdftk:

pdftk A=infile.pdf cat ASP-EP output outfile.pdf

where:

infile is the input PDF file

outfile is the output PDF file

SP – start page

EP – end page

For example to extract pages from 36 to 40 from file infile.pdf you can use:

pdftk A=infile.pdf cat A36-40 output outfile_p36-40.pdf

If you do not have pdftk installed you can install it with yum on RPM based distributions:

sudo yum install pdftk
Follow

Get every new post delivered to your Inbox.