Sunday, December 4, 2016

Combining audio with different sample and bit rates with a video track


There's lots of way to go about changing sample rates, bit rates, merging files, and most result in noise.  There likely is a way to do it all in one sox command line, if one has a lifetime to play with sox flags, and most wav merge tools I tried produced static, but conversion to a Matroska container just worked.   The below steps are simple, and they provide the wanted result.

Audio from one source (Cannon SX260HS camera, in file 16-edgeofsteel.wav ) is at 16bit 48khz and audio from another source (Zoom H4N, in file 16-edgeofsteel2.wav) is at 24bit 96khz.  Video track is 1080p from the Cannon SX260HS (in file edgeofsteel.mov).

1) Up sample 16-edgeofsteel2.wav from 48k to 96k using sox:

sox 16-edgeofsteel2.wav 16-edgeofsteel-96.wav rate 96000

2) Put both .wav files into to a .mkv container using ffmpeg:

ffmpeg -i 16-edgeofsteel.wav  -acodec aac -strict -2 -b:a 500k 16-edgeofsteel3.mkv

ffmpeg -i 16-edgeofsteel-96.wav -acodec aac -strict -2 -b:a 500k 16-edgeofsteel4.mkv

3) Merge the .mkv files using mkvmerge:

mkvmerge -o 16-edgeofsteel-final.mkv 16-edgeofsteel3.mkv +16-edgeofsteel4.mkv

4) Combine the audio and video tracks into one file:

ffmpeg -i 16-edgeofsteel-final.mkv -i edgeofsteel.mov -acodec copy -vcodec copy 16-edgeofsteel.mkv -y

Here the results below, the transition is at 4:20:



  • --------

    Some more tricks, I mixed a track from a CD in with a live clip and kept the last 29 seconds of the live sound:

    1) Put final 29 seconds from video into aac file:

    ffmpeg -i 20140503_195452.mp4 -ss 00:04:40 -t 00:05:09 -acodec copy wolf2.aac -y

    2) Convert to FLAC:

    ffmpeg -i wolf2.aac -f flac wolf2.flac

    3) Cut 4:40 out of the studio track:

    ffmpeg -i 11.Wolf_and_Dog.flac -ss 00:00:01 -t 00:04:41 -acodec copy wolf.flac -y
    4) Convert to 48k so it matches the sample rate of the video:

    sox wolf.flac wolf48.flac rate 48000
    5) Combine the two audio tracks:

    sox wolf48.flac wolf2.flac wolftotal.flac

    6) Combine the video and complete audio track:

    ffmpeg -i wolftotal.flac -i 20140503_195452.mp4 -acodec copy -vcodec copy wolf.mkv -y

    Results below, sound transition at 4:40


    ReVamp - Wolf and Dog Live Slim's San Francisco


    Replacing audio on a video:

    ffmpeg -i 01_Sonata_Arctica_-_Wolf_And_Raven_2001.VOB -i 16_-_Wolf___Raven__Remake_2008_.flac -vcodec copy -acodec copy -map 0:v -map 1:a -strict -2 output.mp4


    Wednesday, November 2, 2016

    Bit perfect sound on Linux

    "bit perfect" means the sound comes out of your speakers without being downgraded by the computer.  "Hi-res audio" is generally rates above 16/44, like 192/24 and DSD audio.

    Jack audio
    Kodi
    Disable pulse
    Fedora JAM spin
    Audiophile Linux

    Matricom G-Box MX2 Combo Dual Core XBMC TV Box 8GB Android 4.2.2

    Intel Compute Stick STCK1A8LFC

    MOC

    wtfplay

    Monday, October 24, 2016

    Getting USB label maker working in Linux

    Fedora 21 - Phase 1, installation, first do:
    yum install glabels cups-devel gcc
    Next grab the drivers, although F21 had Dymo drivers they didn't work, if the below URL doesn't work then google dymo-labelwriterlabelmanager-sdk
    http://developers.dymo.com/2012/02/21/announcing-dymo-labelwriterlabelmanager-sdk-1-4-0-for-linux/
    tar xfv dymo-cups-drivers-1.4.0.tar.gz
    cd dymo-cups-drivers-1.4.0.5, ./configure. make all, make install as root.
    Next add the printer, either with System Settings/Printer or
    http://localhost:631/admin (login root, and your root pw)

    Phase 2, making labels. 
    Nice write up for Ubuntu below, on Fedora you can skip the apt-get steps.  
    http://www.smartfruit.com/?p=188
    (Or google Dymo LabelManager PnP on Linux CUPS smartfruit)
    The important point is the how to use glabels to create your label.

    Major gotchas were not having cups-devel installed, and wasting time trying print labels with LibreOffice and lpr - don't! Use glabels only!!



    Sunday, October 23, 2016

    genisoimage: No such file or directory. Invalid node

    genisoimage: No such file or directory. Invalid node

    I've found and fixed this before and forgotten how.

    When ripping CD/DVD whatever one gets the mystery error:

    "genisoimage: No such file or directory. Invalid node"

    And/or the more puzzling:

    "input-charset not specified, using utf-8"

    mkisofs, genisoimage, etc all give the same error, and from what the forums
    say no one has a clue what to do about it.

    Although the error message is utterly useless the cause is very simple.
    mkisofs, genisoimage, etc are unhappy about /tmp, I expect it's a space
    issue, whatever, just delete /tmp/kde-user and ln -s it off to a larger
    filesystem.  Or change the app settings to use another tmp location.  Or the
    much harder route of increasing /tmp size.

    CD ripper "rflac"

    #!/bin/bash

    cd /locnar-ex/Audio/Music

    #abcde -o flac -q high -N -x
    abcde -o flac -N -x

    NEWCD=`ls -hFt | head -1`
    export NEWCD
    echo $NEWCD; cd $NEWCD ; pwd
    NEWCD=`ls -hFt | head -1`
    echo $NEWCD; cd $NEWCD ; pwd

    #parallel --gnu ffmpeg -i {} -qscale:a 0 {.}.mp3 ::: *.flac

    #mkdir `pwd`MP3
    #mv *mp3 `pwd`MP3

    #basename `pwd`


    fixspace

    #!/bin/sh

    I=10

    while [ $I -gt 1 ]; do

            rename " " _ *
            rename "(" _ *
            rename ")" _ *
            rename "'" _ *
        rename "&" _ *
        rename "[" _ *
        rename "]" _ *
        rename "?" _ *
        rename ":" _ *
        rename "!" _ *


            I=`expr $I - 1`

    done
    Version 2 - with recursion:

    #!/bin/sh

    I=10

    while [ $I -gt 1 ]; do

    find . -name "* *" -print -exec rename " " _ {} \;
    find . -name "*&*" -print -exec rename "&" _ {} \;
    find . -name "*(*" -print -exec rename "(" _ {} \;
    find . -name "*)*" -print -exec rename ")" _ {} \;
    find . -name "*'*" -print -exec rename "'" _ {} \;
    find . -name "*[*" -print -exec rename "[" _ {} \;
    find . -name "*]*" -print -exec rename "]" _ {} \;
    find . -name "*:*" -print -exec rename ":" _ {} \;
    find . -name "*|*" -print -exec rename "|" _ {} \;
    find . -name "*%*" -print -exec rename "%" _ {} \;
    find . -name "*\**" -print -exec rename "*" _ {} \;
    find . -name "*\!*" -print -exec rename "!" _ {} \;
    find . -name "*\?*" -print -exec rename "?" _ {} \;

            I=`expr $I - 1`

    done

    XBMC on AppleTV 1



    Got 3 Apple TV 1's?



    Got XBMC on AppleTV?  Upgrade not working?  Did they change the name to Kodi?

    From the GUI it fails, from commandline, file not found:

    wget http://mirrors.xbmc.org/releases/osx/xbmc-11.0.dmg
    wget http://atv-xbmc-launcher.googlecode.com/svn/tags/ul-info/scripts/xbmc-11.0_update.sh

    (file not found)

    Here's the fix:

    ssh frontrow@appletv (pw frontrow)

    wget http://mirrors.xbmc.org/releases/osx/i386/old/xbmc-11.0.dmg
    wget http://atv-xbmc-launcher.googlecode.com/svn/tags/ul-info/scripts/xbmc-11.0_update.sh

    sudo sh xbmc-11.0_update.sh xbmc-11.0.dmg

    This will take you to Eden, the highest release for AppleTV 1.  Unless you want reinstall with Linux / OpenElec. BUT then you lose iTunes access.... (this was my first hybrid Frontrow launcher)

    ----- 2016 -----

    Now there's a fork out of OpenElec, called LibreELEC that will take you up to the latest releases of Kodi for your AppleTV hardware.  This what I recommend you do.

    ----- 2017 -----

    Forget it, the LibreELEC release sucks mud, the newer Kodi version requires too much memory. Which means chewitt's OpenElec 6.0.1 is the final ever release for the Apple TV 1.  And, it doesn't boot, at least the USB img file didn't work for me, so the only way to go is with the 6.0.0 img, which is not show on the site.  However, here's a direct link.  And the harddrive img.  This takes you up to Kodi 15

    OSMC?  Maybe, the installer hangs on the versions I've tried, so I don't know.  Truth be told, even with the OpenELEC-ATV build I had to redo it 5 times due to odd hangs, but once I got a clean install it's been totally solid.

    TV Wifi card



    Why you want to do this!

    If you have a TV, projector or other video device that only has Component Video input (YPBPR 1080i/p), the Apple TV1 is your best bet, it's pretty much the only computer you can buy that has Component Video output. It also has HDMI output, but of course there's many devices out there with HDMI support.  My display is the Pioneer SD-532HD5 1080i analog HDTV.

    What you should do:

    First, order some parts.  You'll need 3 items: T8 Torx screwdriver, SSD drive, Crystal HD video card.
    You don't have to do this hardware upgrade in order to run Kodi, but it's easy and it's a huge preformance boost.

    Simply pry up the four corners of the rubber pad on the underside of the AppleTV 1 and remove the Torx screws.  Open the AppleTV up, replace the harddrive with the SSD and replace the wifi card with the Crystal video card.  Close it up and install LibreELEC via a USB stick.  There's several videos on Youtube showing how to do all of these steps and/or Google OpenELEC and LibreELEC if you need help.
    The Apple TV1 runs very hot.  Replacing the Apple harddrive with a SSD solves the heat problem and greatly speeds up boot time. You can pop your original Apple drive back in to revert.  Many instructions say you must completely remove the rubber pad on the underside of the AppleTV, this is a lot of work that's not necessary!  You can locate the screws by feel and/or look at the Youtube video.  Just peel up the edges or cut a little hole with an exacto knife.

    The Crystal HD video card will get you smooth playback in 1080i/p video, mostly.  Sometimes I still have playback issues, when this happens the fix is convert the video via Handbrake, on the Video tab choose MPEG-4 as the Video Encoder and set QP: 3.  Check the Audio List tab to be certain you're getting 5.1 past through audio.  MakeMKV and DVD Audio Extractor are also very useful tools.

    Remote control!  The stock Apple TV remote with its 6 buttons is very limited to control Kodi.  However all the USB based remotes and keyboards I've tried work fine with the Apple TV, as do USB splitters. The best one I've used is the mini wireless Trackball Mouse, you can really fly through the Kodi menus with this and it's not line of sight limited like the Apple remote is.  Also there is Yaste, the Kodi app for your phone/tablet, most of the time I'm using Yaste, not the IR remote.  Keep in mind you need to enable remote control devices and start the web server on the Kodi Services/Control menu in order to use Yaste or Kore.

    YouTube!  Often a pain to use with Kodi, however there is a simple fix.  Use Yaste and Android device to select the video.  Open YouTube on your tablet or phone, touch the "share" right arrow, select play with Yaste.  This assumes you've already config'd Yaste to connect to your Kodi center.
    You can also build up a play list of YouTube videos that can be added to the Kodi play queue.







    How-to get RockBox on your iPod Classic and make it work with your car.





    Hardware: iPod Classic 6g 120, Alpine cda-9857 with iPod cable

    Finally to get rid of all those nasty "Apple issues" I've had since I bought the iPod (due having an iPod connection in my car), the crashes, random freezes, track skips, encrypted databases, no FLAC support, etc, etc :( The solution is to install Linux on the iPod. The problem was my hardware (iPod Classic 120GB) wasn't supported, however figuring out a few extra steps, I got it to work.

    Step 1)
    http://www.freemyipod.org/wiki/EmCORE_Installation/iPodClassic/PrepareDFULinux
    Step 2)
    http://www.rockbox.org/wiki/RockboxUtility#Download
    http://www.rockbox.org/wiki/GraphicalInstall
    Select "Show disabled targets", Install dev version
    Step 3)
    (the tricky part)
    https://github.com/ilikenwf/rockbox-ipod6g#compiled-release
    Grab this build:
    https://mega.co.nz/#!5JMCwJjD!N-Ay2NFnDUGap-USDv8gwUxDBlwpjzbJYnuFThIiGbc
    Unzip, mount iPod, cp -r .rockbox (which is from the zip file) to (path to your iPod), unmount and yes to reboot. This replaces dev version 983c808-150717 with c299412-150616. It hung for me, so I had to hard reboot with select/menu, once up it's running fine on c299412-150616, and working with the Alpine headend.