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.


Thursday, January 29, 2015

Icecasting From Home: Part 1

This is how to run a minimalistic internet radio service. It uses the well known and free icecast server to serve the audio streams. Theoretically, there is no limit to the number of streams of audio you can serve. You are limited only by your hardware and bandwidth.

In this example, the backend uses the ices0 server to serve mp3 songs to icecast. The newer ices server serves only Ogg streams. This is largely an open source issue since mp3 is not open source. As I already have a ton of mp3 sitting on my drives, I went for ices0 instead.

First off, note that I'm on OpenSuse 12.2.

To install icecast I had to fulfill some dependencies.

These were:

libxml
libxslt
libogg
libvorbis


Build the dependencies for icecast:

libxml

Download the source files- libxml2-2.9.1.tar.gz
Untar:
tar -xvzf libxml2-2.9.1.tar.gz

cd to the extracted folder:
cd libxml2-2.9.1

In the usual manner run the configure, make and installation commands:
./configure
make
sudo make install

libxslt

For libxslt, download the source files- libxslt-git-snapshot.tar.gz

Untar:
tar -xvzf libxslt-git-snapshot.tar.gz

cd to the extracted folder:
cd libxslt-1.1.28

In the usual manner run the configure, make and installation commands:
./configure
make
sudo make install

libogg

For libogg, download the source files- libogg-1.3.2.tar.gz

Untar:
tar -xvzf libogg-1.3.2.tar.gz

cd to the extracted folder:
cd libogg-1.3.2

In the usual manner run the configure, make and installation commands:
./configure
make
sudo make install

libvorbis

For libvorbis, download the source files- libvorbis-1.3.4.tar.gz

Untar:
tar -xvzf libvorbis-1.3.4.tar.gz


cd to the extracted folder:
cd libvorbis-1.3.4


In the usual manner run the configure, make and installation commands:
./configure

make

sudo make install



icecast

download the source files: icecast-2.4.1.tar.gz

Untar:
tar -xvzf icecast-2.4.1.tar.gz


cd to the extracted folder:
cd icecast-2.4.1


In the usual manner run the configure, make and installation commands:
./configure

make

sudo make install



BACKEND CLIENT- ices0 for mp3:

There is at least one dependency- libshout2.

Build the dependency for ices0:

Download the source files: libshout-2.3.1.tar.gz

Untar:
tar -xvzf libshout-2.3.1.tar.gz


cd to the extracted folder:
cd libshout-2.3.1


In the usual manner run the configure, make and installation commands:
./configure

make

sudo make install



ices0

Download the source files: ices-0.4.tar.gz

Untar:
tar -xvzf ices-0.4.tar.gz


cd to the extracted folder:
cd ices-0.4.tar.gz


In the usual manner run the configure, make and installation commands:
./configure

make

sudo make install


Now we are set up minimally.


Run ice cast server with :

icecast -c /usr/local/etc/icecast.xml


go to http://localhost:8000 to see default icecast in action.

You should this if all has gone well.


You should now edit icecast.xml to suit your purposes.

Running multiple instances of ices and multiple radio stations:

First, edit the icecast.xml to allow more sources and listening ports.
In this example we edited to add port 8443, and increased sources to 6.

Note that you need su priviledges. So use :

gnomesu gedit


SECTION TO EDIT- "limits":

    <limits>

        <clients>100</clients>

        <sources>6</sources>

        <queue-size>524288</queue-size>

        <client-timeout>30</client-timeout>

        <header-timeout>15</header-timeout>

        <source-timeout>10</source-timeout>

        <!-- If enabled, this will provide a burst of data when a client 

             first connects, thereby significantly reducing the startup 

             time for listeners that do substantial buffering. However,

             it also significantly increases latency between the source

             client and listening client.  For low-latency setups, you

             might want to disable this. -->

        <burst-on-connect>1</burst-on-connect>

        <!-- same as burst-on-connect, but this allows for being more

             specific on how much to burst. Most people won't need to

             change from the default 64k. Applies to all mountpoints  -->

        <burst-size>65535</burst-size>

    </limits>


Here sources are set to 6.

Then edit to open more ports:
SECTION TO EDIT - "listen-socket":

    <!-- You may have multiple <listener> elements -->

    <listen-socket>

        <port>8000</port>

        <!-- <bind-address>127.0.0.1</bind-address> -->

        <!-- <shoutcast-mount>/stream</shoutcast-mount> -->

    </listen-socket>

    <!--

    <listen-socket>

        <port>8080</port>

    </listen-socket>

    -->

    

    <listen-socket>

        <port>8443</port>

        <!--ssl>1</ssl-->

    </listen-socket>


An added port 8443 has been opened up.
Next, make a copy of the ices.conf. Name this to say "jazz.conf".
Edit the jazz.conf to point to the relevant playlist.
SECTION TO EDIT- "Playlist"

<Playlist>

    <!-- This is the filename used as a playlist when using the builtin 

     playlist handler. -->

    <File>/home/rnx/jazz.txt</File>

    <!-- Set this to 0 if you don't want to randomize your playlist, and to

     1 if you do. -->

    <Randomize>0</Randomize>

    <!-- One of builtin, perl, or python. -->

    <Type>builtin</Type>

    <!-- Module name to pass to the playlist handler if using  perl or python.

     If you use the builtin playlist handler then this is ignored -->

    <Module>ices</Module>

    <!-- Set this to the number of seconds to crossfade between tracks.

         Leave out or set to zero to disable crossfading (the default).

    <Crossfade>0</Crossfade>

    -->

  </Playlist>

Edit the mountpoint, stream name and genre to reflect jazz:
SECTIONS TO EDIT- "mountpoint", "Name" and "Genre":

    <!-- The name of the mountpoint on the icecast server -->

    <Mountpoint>/jazz</Mountpoint>

    <!-- The name of the dumpfile on the server for your stream. DO NOT set

     this unless you know what you're doing.

    <Dumpfile>ices.dump</Dumpfile>

    -->

    <!-- The name of you stream, not the name of the song! -->

    <Name>Jazz</Name>

    <!-- Genre of your stream, be it rock or pop or whatever -->

    <Genre>Jazz</Genre>

This will operate on port 8000 because we left that unchanged. Note that it is better to change the port to another, because 8000 is icecast's default display port, which shows a webpage.
Make another copy of the ices.conf file and name it to say bollywood.conf.
Edit this to point to the relevant playlist.
SECTIONS TO EDIT- "Playlist", "mountpoint",and "Crossfade":

<Playlist>

    <!-- This is the filename used as a playlist when using the builtin 

     playlist handler. -->

    <File>/home/rnx/bollywood.txt</File>

    <!-- Set this to 0 if you don't want to randomize your playlist, and to

     1 if you do. -->

    <Randomize>0</Randomize>

    <!-- One of builtin, perl, or python. -->

    <Type>builtin</Type>

    <!-- Module name to pass to the playlist handler if using  perl or python.

     If you use the builtin playlist handler then this is ignored -->

    <Module>ices</Module>

    <!-- Set this to the number of seconds to crossfade between tracks.

         Leave out or set to zero to disable crossfading (the default).

    <Crossfade>5</Crossfade>

    -->

  </Playlist>

Edit the port to connect to the other open port in icecast (8443).
Edit the mountpoint name, stream name, and genre.
SECTIONS TO EDIT- "Server", "mountpoint", "Name" and "Genre":

    <Server>

      <!-- Hostname or ip of the icecast server you want to connect to -->

      <Hostname>localhost</Hostname>

      <!-- Port of the same -->

      <Port>8443</Port>

      <!-- Encoder password on the icecast server -->

      <Password>hackme</Password>

      <!-- Header protocol to use when communicating with the server.

           Shoutcast servers need "icy", icecast 1.x needs "xaudiocast", and

       icecast 2.x needs "http". -->

      <Protocol>http</Protocol>

    </Server>



    <!-- The name of the mountpoint on the icecast server -->

    <Mountpoint>/bollywood</Mountpoint>

    <!-- The name of the dumpfile on the server for your stream. DO NOT set

     this unless you know what you're doing.

    <Dumpfile>ices.dump</Dumpfile>

    -->

    <!-- The name of you stream, not the name of the song! -->

    <Name>Bollywood</Name>

    <!-- Genre of your stream, be it rock or pop or whatever -->

    <Genre>Bollywood</Genre>

    <!-- Longer description of your stream -->

    <Description>Default description</Description>

    <!-- URL to a page describing your stream -->

    <URL>http://localhost/</URL>

Start icecast:
icecast -c /usr/local/etc/icecast.xml

Start the two instances of ices in two separate terminals:
ices -c /usr/local/etc/jazz.conf

ices -c /usr/local/etc/bollywood.conf

Connect VLC to the two streams:
http://localhost:8000/jazz

and then
http://localhost:8443/bollywood

You should be able to hear both stations and they should get saved on the playlist.
To open up to other comps in your network, remember to use yast>firewall to open the ports. Click the advanced button and open the ports, using http as protocol.