Wednesday, October 14, 2015

Finding and Using Fonts in OpenSuse

To find the font directories in use, simply cat the fonts.conf file:

cat /etc/fonts/conf.d


This gives you this sort of results at the top of the output:

<!-- Font directory list -->

    <dir>/usr/share/fonts</dir>
    <dir>/usr/X11R6/lib/X11/fonts</dir>
    <dir>/opt/kde3/share/fonts</dir>
    <dir>/usr/local/share/fonts</dir>
    <dir>~/.fonts</dir>



Note that there are 5 directories in use in this case:

/usr/share/fonts/
/usr/X11R6/lib/X11/fonts/
/opt/kde3/share/fonts/
/usr/local/share/fonts/
~/.fonts/



To find the fonts in use by the system, in the /usr/share/fonts/ folder, use the command:

fc-list


You may want to redirect the output to a text file:

fc-list > fontlist.txt


To install additional fonts system-wide, manually copy the font files to a suitable directory, such as /usr/share/fonts/

Instead of copying the actual fonts, you can also create symbolic links. For example, you may want to do this if you have licensed fonts on a mounted Windows partition and want to use them. Subsequently, run:
SuSEconfig --module fonts


SuSEconfig --module fonts executes the script /usr/sbin/fonts-config, which handles the font configuration. For more information on this script, refer to its manual page (man fonts-config).

The procedure is the same for bitmap fonts, TrueType and OpenType fonts, and Type 1 (PostScript) fonts. All these font types can be installed into any directory known to fonts-config.


However, for many applications and operations, fonts can be called through specific conf files from other folders as well.
One example would be as in xslt/fo operations.

To add fonts in a particular directory to the xslt transformations, register the fonts in the directory by adding the path in fop.xconf:


<fonts>

    <!-- register all the fonts found in a directory -->
        <directory>/home/rnx/workingfonts</directory>

.....

</fonts>

Reinstalling Grub on Corrupted Opensuse (even Dual boot) Systems

Boot into Rescue mode from the DVD.
Once the DVD rescue gets to 'login', type:
root

Run fdisk -l to confirm the HD partition order.
We need to mount root. Say that's /sda3
Now mount /sda3 with:
Code:
mount  /dev/sda3  /mnt


To mount the other devices:

mount  --bind  /dev  /mnt/dev
mount  --bind  /proc  /mnt/proc
mount  --bind  /sys  /mnt/sys

If this preparation went well, perform the actual change.
Then chroot:
chroot /mnt
Mount filesystems: mount /proc mount /sys
Install Grub:
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda

Then exit and reboot.

Code:
exit
reboot


Coverting Wav to Mp3 with LAME

lame command to convert wav to mp3:

lame -V2 input.wav --tt "Title" --ta "Artist Name" --tl "Album Name" --ty 2015 --ti Logo_art.png output.mp3


This adds a title, Artist name, year and other ID3 metadata including album art.

Adding album art only:

lame --ti /path/to/file.jpg audio.mp3


It is possible to add more than one image to a MP3 with eyeD3. To do this you have to add a description to each image tag like:

eyeD3 --force-update --no-color --quiet --add-image "frontcoverimage.jpg:FRONT_COVER:front cover" --add-image "backcoverimage.jpg:BACK_COVER:back cover" file.mp3


The developer of eyeD3 said:

    The ID3 spec says that if there are multiple images in a single tag than each must have a unique description.

How to Make a Title Card Movie out of a static image: Part 2- ADDING BLUR

While converting text images to titles, you can blur the edges minimally to smooth out jaggies:



#!/bin/bash

for i in *.png;
do
ffmpeg -y -loop 1 -f image2 -i $i -f lavfi -i anullsrc -t 00:00:05 -s 1280x720 -aspect 16:9 -acodec pcm_s24le -b:a 128k -vcodec qtrle -b:v 1024k -filter_complex 'boxblur=1:1, fade=in:0:10, fade=out:110:10' -f mov ${i%%.png}.mov

done


This uses "boxblur", but you can also use "smartblur".


Creating Titles in ImageMagick from Text Input

Basic command:

convert -size 1920x1080 xc:'rgb(36,66,149)' -background none -gravity Center -font 'Futura-Bk-BT-Heavy' -pointsize 100 -fill white -interline-spacing -5 -size 1600 caption:"Pricing And Inventory:\nSetting The Calendar" -composite Title.png



Here the background color of the title is defined by the color RGB=36,66,149. The text is centred (gravity), uses the "Futura-Bk-BT-Heavy" font at 100 points. The space defined as allowed is 1600 pixels. When it overflows 1600 pixels the line will flow to the next line. But we also define a hard newline by using "\n" within the text. The parameter "-background none" means the text itself will NOT have another separate label like background, but will be composited with transparent surroundings over the canvas. "xc" defines the canvas. Text color is defined as white with "-fill white".

You can add some kerning to space out:

convert -size 1920x1080 xc:'rgb(36,66,149)' -background none -gravity Center -font 'Futura-Bk-BT-Heavy' -pointsize 100 -kerning 10 -fill white -interline-spacing -5 -size 1600 caption:"Pricing And Inventory:\nSetting The Calendar" -composite title.png



Positive kerning values add space, negative values crush space.

Now if we wanted to make several titles, we will need to define the separate texts and their separate outputs, i.e. separate filenames. This can be done through 2 arrays, one for text input, and one for matching filename:

#! /bin/sh


# define the text array

text=("Benifits Of eDiig" "Short Summary Of Registration Process" "How To Fill The Registration Form" "How to Make Payment Of Deposit For Account Activation" "Documents Required For KYC" "Contact From eDiig Administration \nTo Explain Process For Activation" "Intimation On Completion \nOf Account Activation" "Non-Refundable One Time Security Deposit" "Security Deposit For Auctions (EMD)" "What You Can See Once EMD Security Deposit Is Paid" "Forfeiture Of Security" "Logging In Into eDiig" "Introduction To Interface" "How To Use Sale Calendar" "How To Use The Sale List" "How To View Live Auctions" "What Happens If Security Is Not Paid" "Inspection Of Vehicles- Physical" "Creating A Shortlist Of Vehicles \nYou Are Interested In" "How To Participate In Quoted Auctions" "Closing Date" "Closing Time" "Extension Of Closing Time \nOn Bidding At Last Moment" "How To Place A Quote And Bid" "Non-Quoted Or Regular Auctions" "Consumer Events " "How To Use My Quotes" "How To Use My Live Events")

#define filename array

filename=("TITLE00100.png" "TITLE00200.png" "TITLE00300.png" "TITLE00400.png" "TITLE00500.png" "TITLE00600.png" "TITLE00700.png" "TITLE00800.png" "TITLE00900.png" "TITLE01000.png" "TITLE01100.png" "TITLE01200.png" "TITLE01300.png" "TITLE01400.png" "TITLE01500.png" "TITLE01501.png" "TITLE01600.png" "TITLE01700.png" "TITLE01800.png" "TITLE01900.png" "TITLE02000.png" "TITLE02100.png" "TITLE02200.png" "TITLE02300.png" "TITLE02400.png" "TITLE02500.png" "TITLE02600.png" "TITLE02700.png")


# Use c style for loop
# get total subscripts in an array

total=${#movie[*]}


for (( i=0; i<=$(( $total -1 )); i++ ))
do

convert -size 1920x1080 xc:'rgb(189,95,33)' -background none -gravity Center -font 'Futura-Bk-BT-Heavy' -pointsize 100 -kerning 10 -fill white -interline-spacing -5 -size 1600 caption:${text[i]} -composite ${filename[i]}

done





Blurring Text Minimally in ffmpeg for Smoothing Jaggies

This uses single pass and CRF. This is meant for text based Infographics or Animations.

With mapping and filter_complex:


ffmpeg -i inpu.mov -y -filter_complex "[0:v]boxblur=0.5[o]; [0:a]anull[k]" -map '[o]' -map '[k]' -s 1280x720 -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart out.mp4


With plain video filter and no mapping:


ffmpeg -i input.mov -y -s 1280x720 -vf "smartblur=0.5" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart output.mp4



Note that you can use smartblur or boxblur as per requirements. This has nothing to do with "-vf" or "-filter_complex".

However, smartblur can be more precise and fine tuned. Boxblur seems to have no effect below values of 1 in luma power and radius.

This does not seem to produce results:

ffmpeg -i input.mov -y -s 1280x720 -vf "boxblur=lr=0.8:lp=0.8" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart boxblur_test.mp4


Going up to value of 1 for Luma radius (lr=1) and luma power (lp=1) does have a strong effect- MUCH more than required:

ffmpeg -i input.mov -y -s 1280x720 -vf "boxblur=lr=1:lp=1" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart boxblur_test.mp4


With Smartblur this can be better controlled:

ffmpeg -i input.mov -y -s 1280x720 -vf "smartblur=lr=0.8:ls=0.8" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart Smartblur_test.mp4


Here lr is Luma radius and ls is Luma strength.