Saturday, February 18, 2012

KDE 4.7 Window Rules are ignored: Gotcha!

The following applies under KDE 4.7.2, possibly other versions:

KStart > Favorites > Configure Desktop > Window Behavior >
renders a number of options for
    Task Switcher
    Windows Behavior
    Window Rules
If you right click the title bar of a KDE window, e.g., Konsole then select
    Advanced > Special Window Settings
you end up at the same place.

If from the latter you then change something this automatically creates a Window Rule with which you can set all manner of things.

Similarly, from the former, choosing Window Rules gives you a screen where you see a list of your existing Window rules and options
    New …
    Import
    Modify …
    Export
    Delete …

Unfortunately, you can configure away happily and KDE will just as happily ignore your settings until you middle click the maximize button!!!

Now... that is intuitive... NOT.

Saturday, February 11, 2012

How to save YouTube video and audio under Linux - BASH script

As promised:

A script to save video and audio from a YouTube URL:
===============================================
#! /bin/bash
#
#    License: LGPL v3+ (see the file LICENSE)
#    (c)2001-2012 C. Andrews Lavarre
#    email : alavarre@gmail.com
#
########################################################################
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or    #
# (at your option) any later version.                                  #
#                                                                      #
# This program is distributed in the hope that it will be useful,      #
# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
# GNU General Public License for more details.                         #
#                                                                      #
# The GNU General Public License is posted at                          #
#    http://www.gnu.org/licenses/gpl.txt                               #
# You may also write to the Free Software Foundation, Inc.,            #
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA             #
########################################################################

# This routine was modified 120211 by C. A. Lavarre (Andy).
# It captures a YouTube stream, saves the clip, and then rips the audio
#    to an MP3 file
# Arguments:
#    $1 The YouTube URL
#    $2 The basename
#    $3 [Optional] The destination path
# Usage
#    getUT http://www.youtube.com/watch?v=abcdefg myyoutubefile
# Trap errors
  if [ "$1" == "" ]; then
    # Give instructions
      echo "Usage: getUT http://www.youtube.com/watch?v=abcdefg myyoutubefile"
    # Quit
      exit 0
    # Finish
  fi
# Set the variables
  sourceurl=$1
  base_name=$2
  destdir=$3
  destfile=$3/$2
  if [ "$3" == "" ]; then
    # Change the destination
      destfile=$2
    # Finish
  fi

  destflv=$destfile.flv
  destmp3=$destfile.mp3
# Declare intentions
  echo "Copying "$sourceurl" to "$destflv
# Get the full video
  youtube-dl -o $destflv $sourceurl
# Declare intentions
  echo "Copying audio from "$sourceurl" to "$destmp3
# Rip the audio
ffmpeg -i $destflv -vn -acodec libmp3lame -ac 2 -ab 128k $destmp3


===============================================
I get a weird "unsupported sampling rate" warning, but the output sound ($destmp3) is beautiful nevertheless.


If you have comments or tips please submit. We all win or we all lose. It is not a contest.

Easy when you know how: Saving YouTube Video and Audio

So as usual, the answer isn't simple, but easy when you know how.

    http://linux.seindal.dk/2005/09/12/converting-aac-audio-files-to-mp3/
gives the basics:
    youtube-dl    lets you capture the entire video
    ffprobe          examines the contents of the video

    ffmpeg          strips out the audio and also converts it to a 
                           more favorable format
 

But as always there are gotchas: under linux the mp3 codec doesn't exist, rather there is a libmp3lame library.

So, step by step:


1. Install youtube-dl, ffprobe, ffmeg, and libmp3lame using your usual process, repositories, whatever.
 

2. Given a YouTube URL of
    http://www.youtube.com/watch?v=abcdefg
    at a terminal issue the command (under Linux, do whatever equivalent elsewhere):
    cd "directory I want it to be in"
    The quote marks protect the path from embedded spaces... Then issue
    youtube-dl -o "myyoutubefile.flv" http://www.youtube.com/watch?v=abcdefg
    This will save (output: -o) the YouTube video clip as a Flash video (.flv) file containing both the video and the audio.  Kaffeine will quite happily play both.
 

3. Check the audio and video channel formats with
    ffprobe "myyoutubefile.flv"
    The output of this will contain a string
        Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 147 kb/s
    or something similar, indicating that the audio format is aac.
 

4. Strip out the audio to another format  (e.g., here we go to mp3) with
    ffmpeg -i myyoutubefile.flv -vn -acodec libmp3lame -ac 2 -ab 128k myyoutubeaudio.mp3

 
You can do this all in one step with a handy script. Watch this space.

Easy when you know how...

Saturday, February 4, 2012

GnuCash 2.4.9 Workaround

The upgrade of openSUSE to version 12.1 results in an upgrade of the guile library from version 1.8 to version 2.0.
Unfortunately GnuCash (versions 2.4.7 and 2.4.9)  still depend on guile 1.8. As a result GnuCash crashes on start with 
     ERROR: In procedure debug-options-interface: Unknown option name: maxdepth
See
for the gory details.
Fortunately, there is a workaround until the openSUSE folks sort this out.
The workaround is to use YaST (yast2 sw_single) to DELETE guile 2.0. This will result in an offer to roll back gnucash to version 2.4.7 and to roll back guile to version 1.8.
Which is fine by me.