Using gphoto2 to Automate Taking Pictures

Using gphoto2 to Automate Taking Pictures

Image

Shawn Powers
Sat, 01/27/2018 – 09:04

Introducing an app that allows DSLR cameras to function as an image or video capture device in Linux.

With my obsession—er, I mean hobby—regarding BirdCam, I’ve explored a
great number of camera options. Whether that means trying to get Raspberry
Pi cameras to focus for a macro shot of a feeder or adjusting depth of
field to blur out the neighbor’s shed, I’ve fiddled with just about every
webcam setting there is. Unfortunately, when it comes to lens options,
nothing beats a DSLR for quality. Thankfully, there’s an app for that.

The gphoto2 suite of drivers and apps allows a huge list of DSLR cameras
to function as image or video capture devices inside Linux. There’s a
compatibility list at the gphoto site,
and even if your camera isn’t listed, it’s likely you’ll be able to use
it in some manner. For example, my Nikon Coolpix P610 isn’t officially
supported, but I’m able to get some images from it regardless. In fact,
it even supports previewing a photo in ASCII art. That might not be a
useful feature, but I found it incredibly fun to play with.

In all reality, if you want to automate taking pictures while using a
real DSLR camera, gphoto2 is probably the tool you want. Whether it’s a
short-term setup on a tripod or a future super-high-def BirdCam (send
me a link!), be sure to check it out. And if I
can get my wife to loan me her Canon DSLR with the 50mm prime lens,
BirdCam might rise to a whole new level!

Building Your Own Audible

Building Your Own Audible

Image

Shawn Powers
Sat, 01/20/2018 – 08:35

A quick look at some options for streaming audio books.

I have audiobooks from a variety of sources, which I’ve purchased in a
variety of ways. I have some graphic audio books in MP3 format, a bunch
of Audible books in their DRM’d format and ripped CDs varying from m4b
(Apple format for books) to MP3 and even some OGG. That diversity makes
choosing a listening platform difficult. In order to meet my idea of
perfection, I need:

  • A system that plays any audio format.

  • A way to play books on multiple platforms, iOS Android and web browsers.

  • Current location stored and honored across platforms.

  • The ability to play audiobooks at different speeds.

  • An easy way to access my entire library remotely.

Several options come close. My favorite Android audiobook app, for
instance, is «Listen», available in the Play Store. But, it falls short on the
multi-platform front and also on accessing books remotely. Audible itself
will do most of what I need, but it doesn’t allow importing remote
books. And, traditional music players are out.

Honestly, Plex seems like the perfect platform for audiobooks. And although
some people do use it, they’re just kludging things. Plex doesn’t natively
support the concepts behind audiobooks, so the process isn’t smooth at
all. I’m honestly hoping that changes in the future, because it would
be a perfect addition to an already amazing system. Thankfully, in the
meantime, there’s BookSonic.

You’ve probably heard of SubSonic, which is a music streaming server that
allows you to do pretty much what I’m looking for with audiobooks, but it’s strictly for
music. Patrik Johansson
has forked SubSonic
and created BookSonic, specifically modified to handle audiobooks. It
even handles tagging and book art. Currently, the system isn’t perfect,
but it’s closer than any other projects come to book nirvana, and if
you use Docker, it’s dead simple to get installed. A simple:


docker -d create \
  --name booksonic \
  -p 8080:8080 \
  -v :/audiobooks \
  -v :/var/booksonic \
  ironicbadger/booksonic

will get BookSonic running on your Docker host. Once it’s installed,
just head over to http://docker_host:8080 and log in as admin/admin. You
can start the book scan, and fairly soon, your books will show up for
you to start playing!

Many things about BookSonic do need work (syncing locations
to the web client and so on), but it’s a great start, and it’s a wonderful way
to access all your books in one place. Well, as long as you figure
out how to strip the DRM from your Audible books anyway!
For more details, head over to http://booksonic.org.

Creating an Internet Radio Station with Icecast and Liquidsoap

Creating an Internet Radio Station with Icecast and Liquidsoap

Image
radio

Bill Dengler
Mon, 01/15/2018 – 08:34

Ever wanted to stream prerecorded music or a live event, such as a lecture or
concert for an internet audience? With Icecast and Liquidsoap, you can set up a
full-featured, flexible internet radio station using free software and open
standards.

Icecast is «a streaming media (audio/video) server that currently
supports Ogg (Vorbis and Theora), Opus, WebM and MP3 streams. It can
be used to create an internet radio station or a privately running
jukebox and many things in between. It is very versatile in that new
formats can be added relatively easily and supports open standards for
communication and interaction.»

Liquidsoap is «a powerful and flexible
language for describing your streams. It offers a rich collection of
operators that you can combine at will, giving you more power than you
need for creating or transforming streams. But Liquidsoap is still very
light and easy to use, in the UNIX tradition of simple strong components
working together.»

When combined, Icecast and Liquidsoap can
create a flexible, feature-rich internet radio station. In this article,
I describe how to configure Icecast to host an internet radio station. Then, I
explain how to
install and configure Liquidsoap to connect to Icecast, adding random
(or sequential) music playback with smart cross-fading, prerecorded
randomly inserted announcements and jingles, a song request system
and support for live streams, with automated recording and seamless
switching between live and automated programming. I also show how to configure the
server to serve your stream in MP3, Ogg and Opus formats for maximum
player compatibility.

Icecast, Vorbis and related projects are maintained by Xiph.Org,
a nonprofit organization that develops open multimedia standards and
software. To ensure that you are running the latest version of Icecast,
with all (or most) features, you should install from an official Xiph.Org
repository. Visit the list of official repositories here, and follow the instructions on that page to add the Icecast
repository for your distribution. Then, install using your system’s
package manager. On Debian-based systems (such as Ubuntu), you may be
asked to «configure Icecast» during package installation; select
«no»
as you will configure the server manually if you are following along with this
article.

Open the Icecast configuration file using your preferred
text editor. On Debian-based systems, the file is located at
/etc/icecast2/icecast.xml. The location on other systems may differ; check
your package’s documentation for the correct path. The configuration
file is in XML format and is divided into several sections. First,
enter your server’s location and email into the location and admin fields,
respectively—for example:


The Heart of Gold
zaphodb42@mail.example.com

Since each format you’ll set up in Liquidsoap is a separate Icecast
«source», you’ll quickly exhaust the default source limit of two.
So, change
that to ten:


10

Unless you anticipate listeners connecting from slow or low-bandwidth
environments, disabling Icecast’s burst-on-connect feature will
significantly decrease latency:


0
        0

The default passwords, «hackme», invite security compromise. Change them
to something else. Also, it’s probably a good idea to change the default
admin user name. The following passwords are just examples; change them
for your configuration both here and when they are mentioned later in
the article:


dontpanic
    dontpanic42
            zaphod
            2Headsarebetterthanone!

Enter your system’s fully qualified domain name in the hostname field:


example.com

Save and close the file. If you edited the file as root, you’ll need
to reset its permissions. On Debian-based systems, Icecast runs under
user icecast2 and group icecast. To fix permissions on a Debian-based
system, run:


chown icecast2:icecast /etc/icecast2/icecast.xml

On Debian-based systems, Icecast’s system service is disabled by
default. Open the file /etc/default/icecast2, and set enabled to
true. Then save and close the file.

Most modern Linux systems use systemd for service management. To enable
Icecast on boot and start it for this session, run the following commands
as root (using sudo or similar):


systemctl enable icecast2
systemctl start icecast2

Service names on various systems differ; if those commands don’t work,
check your system’s documentation for the correct service name.

Many distributions provide broken and out-of-date versions of Liquidsoap
in their repositories. For this reason (along with improved ability
to customize your installation), the Liquidsoap developers recommend
installing it using the OCaml Package Manager (opam). Use your distro’s
package manager to install opam. If you’ve been doing everything up to
this point logged in as root, you’ll now need to create a non-root user
under which to install Liquidsoap. You also need to install sudo and give
this new user permission to use it. On Debian-based systems, the
adduser
and gpasswd utilities allow you to create users and add them to groups,
respectively. On Debian-based systems, run the following commands as root
to add a new user and grant it sudo access (for other systems, refer to
the documentation). Let username represent the user name of the new user:


adduser username
gpasswd -a username sudo

Performing as your non-root user, initialize the OCaml Package Manager
by running:


opam init

Answer «yes» when asked to modify your profile; this will place Liquidsoap
on your path and allow it to be executed when you type its name. To
apply opam changes, run:


eval `opam config env`

Next, install Liquidsoap’s system dependencies:


opam install depext
opam depext taglib mad lame vorbis cry ssl samplerate
 ↪magic opus liquidsoap

Now, install liquidsoap by replacing depext with
install:


opam install taglib mad lame vorbis cry ssl samplerate
 ↪magic opus liquidsoap

To set up a starting point for the station configuration and enable
Liquidsoap as a service, the developers have created liquidsoap-daemon, a
set of scripts for using Liquidsoap as a system service. Liquidsoap-daemon
uses systemd for service management by default; therefore, it is compatible
with most modern Linux distributions. To set it up, install Git using your
system’s package manager, then run the following as your non-root user:


git clone https://github.com/savonet/liquidsoap-daemon
cd liquidsoap-daemon
./daemonize-liquidsoap.sh

You may be prompted to enter your user’s password to authenticate
sudo. Once the dæmon is installed, you’ll now create a directory
structure for storing music, jingles and archives of live streams in
your non-root user’s home directory. Run the following command:


mkdir -p ~/music/music1 ~/music/jingles ~/archives

Now, open the file main.liq in the liquidsoap-daemon directory. At this point,
that file just contains:


output.dummy(blank())

This line sends no audio nowhere, which is not very interesting, so delete that
line and add the following base configuration (lines starting with # are
comments, so they are ignored by Liquidsoap). This base configuration sets up
one music playlist with songs played in random order, jingles inserted
approximately every seven songs, smart cross-fading, song requests and
automatically recorded live streams. music.mp3, music.ogg and music.opus
stream stored music and jingles in MP3, Ogg Vorbis and Ogg Opus formats
respectively; stream.mp3, stream.ogg and stream.opus play a live stream
when available, falling back to music when the live stream is down:


#Settings
set("server.telnet", true)
set("server.telnet.port", 1234)
set("harbor.bind_addr","0.0.0.0")
# Music playlists
music1 = playlist("~/music/music1")
# Some jingles
jingles = playlist("~/music/jingles")
# If something goes wrong, we'll play this
security = single("~/music/default.ogg")
# Start building the feed with music
radio = random([music1])
# Add the security, requests and smart crossfade
radio = fallback(track_sensitive = false,
 ↪[smart_crossfade(fallback([request.queue(id="request"),
↪radio])),security])
# Now add some jingles
radio = random(weights = [1, 7],[jingles, radio]) # This plays
# a jingle once every approximately seven songs, change 7 to
# another number to change this
# Add a skip command for the music stream
server.register(
usage="skip",
description="Skip the current song.",
"skip",
fun(_) -> begin source.skip(radio) "Done!" end
#Add support for live streams.
live =
audio_to_stereo(input.harbor("live",port=8080,password=
↪"dontpanic1764",buffer=1.0)) #dontpanic1764 is the
# password used to connect a live stream; it can (and should) be
# different from the source-password in icecast.xml.
full = fallback(track_sensitive=false,
[live,radio])
# Dump archives
file_name = '~/archives/%Y-%m-%d-%H:%M:%S$(if $(title),
↪"-$(title)","").ogg'
output.file(%vorbis,file_name,live,fallible=true)
# Stream it out
output.icecast(%mp3.vbr,
host = "localhost", port = 8000,
password = "dontpanic", mount = "music.mp3",
name="myStation Music Service", description="This is the myStation
 ↪music stream. Add some information about your station's automated
 ↪programming.",
radio)
output.icecast(%vorbis,
host = "localhost", port = 8000,
password = "dontpanic", mount = "music.ogg",
name="myStation Music Service", description="This is the myStation
 ↪music stream. Add some information about your station's
 ↪automated programming.",
radio)
output.icecast(%opus(vbr="unconstrained",bitrate=60),
host = "localhost", port = 8000,
password = "dontpanic", mount = "music.opus",
name="myStation Music Service", description="This is the myStation
 ↪music stream. Add some information about your station's
 ↪automated programming.",
radio)
output.icecast(%mp3.vbr,
host = "localhost", port = 8000,
password = "dontpanic", mount = "stream.mp3",
name="myStation Main Stream", description="The myStation main stream.",
full)
output.icecast(%vorbis,
host="localhost",port=8000,password="dontpanic",
mount="stream.ogg",
name="myStation Main Stream", description="The myStation main stream.",
full)
output.icecast(%opus(vbr="unconstrained",bitrate=60),
 ↪description="The myStation main stream.",
host="localhost",port=8000,password="dontpanic",
mount="stream.opus",
full)

Multiple Music Playlists

You may wish to set up multiple
music playlists, perhaps with different types of music, and change the
frequency at which songs from each playlist are played. To do this,
create directories under music for each playlist, named music2, music3 and so on.
Then just copy the music1 line in the music playlists section of
main.liq, changing the reference to music1 accordingly.

To insert songs randomly from the new playlist every n songs in the stream, add
a line below radio = random([music1]), where
n represents the approximate number of songs to play
before inserting a song from the new playlist:


radio = random(weights = [1, n],[music2, radio])

Here’s an example with three music playlists:


# Music playlists
music1 = playlist("~/music/music1")
music2 = playlist("~/music/music2")
music3 = playlist("~/music/music3")
...
radio = random([music1])
radio = random(weights = [1, 6],[music2, radio])
radio = random(weights = [1,12],[music3, radio])

File-Based Playlists

In the base configuration, Liquidsoap
will search the directory ~/music/music1 recursively for songs to
play. However, you also can give Liquidsoap a newline-delimited text
file of paths to songs, either locally on your system or on the web. To
do this, simply change the path to a directory to a path to your text
file, like this:


music1 = playlist("~/music/music1.pls")

Sequential Playback

By default, Liquidsoap plays tracks in random
order. If you want to play tracks sequentially, add
mode="sequential"
to your playlist definition, like this:


music1 = playlist("~/music/music1",mode="sequential")

Instead of using random (for example, when adding other playlists or jingles),
use rotate:


radio = rotate(weights = [1, 7],[jingles, radio])

Sequential playback is best combined with file-based playlists as they
both give you total control over the order in which tracks are played
by Liquidsoap.

Compression and Normalization

If you’d like to add a more
«radio-like» sound to your automated programming, Liquidsoap supports
automatic compression and normalization. To compress and normalize the
tracks of a playlist or input.harbor live stream, wrap it in an
nrj()
operator, like so:


music1 = nrj(playlist("~/music/music1"))

Talking Over Automated Programming

You can add a mountpoint allowing you to
talk over the automated programming, which will have its volume reduced
while you’re connected. Add the following to your configuration above
#Add support for live streams. The automated programming volume will
be changed to 15% of normal while the mic is connected; change
p=0.15 to adjust:


# Talk over stream using microphone mount.
mic=input.harbor("mic",port=8080,password="dontpanic1764",buffer=1.0)
radio = smooth_add(delay=0.8, p=0.15, normal=radio, special=mic)

Finishing Up

Edit the configuration as necessary, then save and close the file. Record
a file to ~/music/default.ogg; this file will be played when Liquidsoap
cannot find other tracks to play. The file should tell listeners that
the stream is down and give them information for contacting you to
notify you of the problem. Populate the playlist(s) with music, then
start Liquidsoap with the following command:


sudo systemctl start liquidsoap

Enable it on boot:


sudo systemctl enable liquidsoap

Once Liquidsoap is started, visit http://example.com:8000 in a web browser
(where example.com is the fully qualified domain name of your server). If
your system is configured properly, music.mp3, music.ogg and music.opus
will appear, playing automated programming. Also, stream.mp3, stream.ogg
and stream.opus will play automated programming unless a live stream
is connected.

If Icecast appears but no mountpoints are listed, check the Liquidsoap
logs at liquidsoap-daemon/log/run.log for errors. If Icecast doesn’t
load, restart it with systemctl restart icecast2.

To broadcast a live stream through your server, you will need a
compatible source client. For Windows, I recommend Altacast.
For Mac users, I suggest Ladiocast, available in the Mac
App Store. For Linux, install DarkIce through your system’s package
manager. On iOS, I recommend iCast. On Android, I suggest Cool Mic. In
all cases, use the following configuration:

  • Host: your server’s fully
    qualified domain name.

  • Port: 8080

  • Mount (mountpoint): live (or /live)
    for a live stream.
    If you enabled the ability to talk over automated
    programming, replace live with mic to talk over the music.

  • username:
    source (some clients don’t prompt for a user name, in which case, source
    is the implied default).

  • password: dontpanic1764 (or the password you
    specified in the input.harbor configuration).

You can stream in Ogg Vorbis
or MP3. Ogg Opus may or may not work, depending on your source client.

Liquidsoap offers control via TCP (over telnet or similar). The base
configuration presented in this article enables a song request system
and the ability to skip tracks on demand. By default, this interface is
available only to users on the local system. The telnet protocol does not
support authentication. If you want to make song request functionality
available to your users, you’ll need to write a program or script
customized for your station that interfaces with Liquidsoap.

Connect to Liquidsoap via telnet, like so:


telnet localhost 1234

Once connected, you can request a song with the following, where
uri is an absolute path to an audio file on your system or
a URL of an audio file on the internet:


request.push uri

To skip the currently playing song
and immediately play the next one, simply type skip.

For a list of all available commands, type help,
or type help followed by the name of a command for usage information on
a particular command.

To end your session, type quit.

In addition to Liquidsoap’s telnet interface, Icecast also has a web-based
administrative interface that you can use to view listener statistics, kill
Liquidsoap’s streams or move listeners among mountpoints. Access it at
http://example.com:8000/admin (where example.com is your server’s fully
qualified domain name). Use the admin-user and admin-password you set
in icecast.xml.

At this point, you now have a fully functional streaming server that
should fit the needs of most users. However, Liquidsoap is extremely
flexible, allowing for more exotic setups for special use cases. Refer to
the Liquidsoap
documentation
for information
on additional language features that may be useful to you.

Live Stream Your Pets with Linux and YouTube!

Anyone who reads Linux Journal knows about my fascination with
birdwatching. I’ve created my own weatherproof video cameras with
a Raspberry Pi. I’ve posted instructions on how to create your own
automatically updating camera image page with JavaScript. Heck, I even
learned CSS so I could make a mobile-friendly version of BirdCam that
filled the screen in landscape mode.
more>>

Live Stream Your Pets with Linux and YouTube!

Live Stream Your Pets with Linux and YouTube!

Image

Shawn Powers
Thu, 10/26/2017 – 06:53

Anyone who reads Linux Journal knows about my fascination with
birdwatching. I’ve created my own weatherproof video cameras with
a Raspberry Pi. I’ve posted instructions on how to create your own
automatically updating camera image page with JavaScript. Heck, I even
learned CSS so I could make a mobile-friendly version of BirdCam that
filled the screen in landscape mode.

Recently, however, I’ve finally
been able to create an automated system that streams my BirdCam live
over YouTube. It starts when the sun comes up and stops when the sun
goes down. And thanks to some powerful open-source software, I never
have to touch the system!

Some of the tools I describe here have been
covered in other articles, but this is the first time I’ve been able to
create a stream that anyone can see utilizing bandwidth Google pays for!

Figure 1. Birds are always camera-shy. If you watch long enough, however,
they come and steal peanuts!

My List of Ingredients

First off, I want to be clear about what sort of hardware and software is
required in order to accomplish something similar to what I’m doing:

  • A Linux computer: if you plan to use USB cameras, this needs to
    be a physical computer. If your video source is network-based, this
    can be a virtual machine on your network. A Raspberry Pi isn’t really
    powerful enough for the video work that has to be done, unless maybe
    it’s low-resolution. I have an old i5 CPU running at 1.6GHz, and it’s
    more than enough.

  • A video source: this can be pretty much any video source you have
    at hand. If you plan to use a USB webcam, you’ll need to be sure you
    are using a physical Linux computer as noted above. I’ve used USB,
    MJPEG over http (see my old BirdCam articles), cheap wireless security
    cameras that have an RTSP stream, and most recently, I started using
    UniFi video cameras. In fact, if you are considering purchasing outdoor
    video cameras for a project like this, I can’t recommend UniFi cameras
    enough. They are PoE, HD and the free software handles recording and
    provides RTSP streams that have both HD video and top-notch audio.

  • A YouTube account with Live Streaming enabled: you’ll need to verify
    your account
    ,
    and then enable live
    streaming here.
    It’s not a
    difficult process, but without following those steps, you won’t be able
    to use the free service.

  • Open Broadcaster Software: I’ve tried multiple ways to use a CLI solution
    to stream directly to YouTube with FFmpeg or mencoder, but I’ve never been
    able to make it work consistently. I was hesitant to use OBS, because it’s a
    GUI solution and doesn’t have a CLI interface, but I worked around that
    problem, and I’m actually happy to have the GUI now.

  • A web server to host your embedded channel: you could just share the
    URL to your YouTube channel, but embedding is much cooler, because you
    can integrate it into your own site.

  • Enough upstream bandwidth to support 1.5–2mbps while streaming: since
    YouTube is going to redistribute, the local bandwidth requirements
    don’t change regardless of how many people are watching your stream. For
    some folks (like me, unfortunately), sacrificing that much bandwidth is
    difficult and sometimes causes issues. Just know that it takes a small,
    but not insignificant amount of constant upstream bandwidth to stream
    live video. That should be obvious, but it’s something to consider.

  • A few other utilities like crontab and sunwait: the latter is only if
    you want to time your streams with sunrise and sunset. And, crontab is
    needed only if you want to automate the starting and stopping. Those touches
    really make a difference for me though, so I encourage you to consider it.

Gather Your Info

YouTube:

In order to live stream, you’ll need a few bits of information. As
I mentioned above, you’ll need to verify your account to turn on streaming. Then you’ll need to get your streaming key (Figure 2). It’s
important that you not share the streaming key, because it acts like
your authentication. If others get your key, they can stream to
your channel, even without your user name.

Figure 2. That’s not my real streaming key, just FYI.

The other bit of information you’ll need from YouTube is your
channel ID. It’s not easy to find the channel ID, but if you
want to embed your video, you’ll need it later. Head to
this page, and find the
line that
looks like, «YouTube Channel ID: UCbUTB3bVg3cmeyJUtUC9DPA» (your channel
ID will be different from mine). The long string of text is your channel
ID, copy that somewhere easy to find.


Video Camera Feeds:

I can really give you only hints about what to look for here. You need
to find the streaming video feed coming from your camera. Make sure you
don’t use the web page that has the stream embedded (most cameras have
a rudimentary web server that embeds the stream). You need the raw feed
itself. Google or the user’s manual will be your best bet for figuring
out the raw stream URL.

I have an Onvif-compatible video camera that has an MJPEG stream URL
that looks like this:
http://192.168.1.170:9090/stream/video.mjpeg.

One of my Foscam cameras requires a user name and password in the URL in
order to get the stream. It looks like this:
http://192.168.1.180:88/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=admin&pwd=xxx.

And my new UniFi cameras actually use an RTSP URL that comes from the
UniFi server instead of from the cameras directly. It looks like this:
rtsp://192.168.1.16:7447/58cf11bef14c359f4b3c7b2e_1.

The point I’m trying to make is that finding your video camera’s
streaming URL often is challenging. If you do it before you start, it
can save hours of frustration. An easy way to test if you’ve found the
correct URL is to try opening it in VLC. I haven’t found a video camera
that VLC can’t view, so if it complains about an invalid video source,
you probably don’t have the correct URL. Google, along with your camera’s
model number, is probably the best way to figure it out.

The Software

There are many scripts online claiming to stream from a camera source to
YouTube using FFmpeg. I’m sure they work for someone, but I’ve never
gotten them to work, no matter how many settings I tweak. In fact,
I gave up for quite a while because I didn’t want to rely on a GUI
interface to stream. I wanted my server to do the dirty work and do it
without my interaction. One day recently, however, I discovered that
Open Broadcaster Software (OBS) supports command-line flags for starting
streaming. That means I could have the server start streaming without
the need to «click» anything.

One problem I had to overcome was the lack of the X Window System on my BirdCam
server. There’s no monitor connected to the server, but in order
for OBS to work, it has to have a logged-in GUI desktop. I hooked up a
monitor long enough to get a GUI installed and then set the system
to log in automatically. I also disabled all power-saving features for
the monitor, because I wouldn’t have one logged in anyway. Once it was
set up, I installed TeamViewer so I could control the system
remotely if I needed to. There have been some issues with TeamViewer’s security
recently, so it might not be the software you choose for controlling the
server, but it’s what I have installed, and it works. Figure 3 shows my
«server» controlled remotely via TeamViewer.

Figure 3. I don’t normally have the security camera to my cat’s litter
cave on my live stream, but I wanted to show multiple cameras.

Installing OBS is simple. Head over to the OBS
site

and download the
latest version, or simply install their PPA if you’re using Ubuntu. The
software has matured since I last mentioned it, and I didn’t have any
problems with dependencies, even when connecting over a remote session.

OBS also has the great feature of saving your last-used session. That
means once you set up your cameras, you don’t have to worry about
readjusting them on the next launch. OBS just uses the same settings you
had before. If you look back at Figure 3, you’ll see there are multiple
cameras added to the preview window. Without the need to save a layout,
OBS just remembers from launch to launch how you had the cameras positioned.

In order to get the best results, you need to tweak a few OBS settings.
Click the settings button, and then head over to
the Video tab (Figure 4). This is a little confusing, but you have two
different resolutions to set. The «canvas» is how big you want OBS to
show on your preview window. The «output» resolution is what it scales
your video to for streaming and recording. I just set them both to 720p,
because I figure scaling takes CPU. You also set the frames per second
(FPS) for the output video. I use 10FPS with the 720p size. You can
adjust this if you want 1080p, or down if you don’t have bandwidth.

Figure 4. The resolutions are flexible, but I like to keep it simple.

Next, click on the «Output» tab (Figure 5). My settings are visible, and
I recommend keeping them close to mine, except for the bitrate of the
video and audio. If you want higher quality video (and you can afford
the bandwidth), this is where you set the average upload speed. You
also can change the audio quality if you want higher quality. Keep in
mind that the resolution you chose in the last step will work with the
bandwidth you selected here to give you the video quality users will
see. A video rate of 1500 (measured in kbps) works well with my 10FPS
and 720p resolution. But if you try to stream 1080p, 30FPS video with
1500kbps, it’s going to be really poor quality video. You’ll have to
experiment to find the sweet spot.

Figure 5. 1500 is the maximum my current internet connection can handle.

The «Stream» tab is where you configure the streaming service you want
OBS to use (Figure 6). You should be able to select YouTube and then paste
that stream key you got from YouTube earlier. (This is
not the channel
ID; it’s that hidden key from back in Figure 2.) Once entered, you shouldn’t
need to make any changes in settings. OBS will keep all the settings,
including streaming information.

Figure 6. It’s truly amazing how well OBS does with YouTube streaming.

All that’s left is to add the camera(s) to your preview screen. This is
the nicest feature of OBS, well apart from actually being able to stream
to YouTube. The setup is drag and drop, and you can resize cameras,
overlap cameras and arrange them however you want. Since OBS supports
so many types of inputs, you can get crazy with text overlays and so on. To
add a network camera, click the + at the bottom middle of the main
window, and select «media source» (Figure 7). Then uncheck
«local file»
and enter the camera URL in the «input» field (Figure 8). Once you click OK,
your camera should appear on the preview window, and you can resize and
move it. The interface also allows you to crop the section of the video
you want to use. It’s very powerful and incredibly
user-friendly. Plus,
as I mentioned earlier, OBS stores all your tweaks automatically,
so the next time you start it, you’ll get the same arrangement.

Figure 7. Media source isn’t obvious as the choice for network cameras.

Figure 8. Be sure to uncheck the «local file», or you won’t have an
input field.

Once you have your camera(s) set up, you can decide whether you want
to include audio if your camera supports it. The audio levels should
appear in the column next to the list of cameras. Then just click «Start
Streaming» to send your stream live to YouTube. It takes 30 seconds or
so to show up in the YouTube dashboard, but now is the time to make sure
streaming works.

Automation

I could just leave OBS running 24/7 and have it stream my bird feeders all
night. Honestly, I’m not sure how YouTube would handle a 24/7 stream, but
I don’t want to do that anyway. I not only want to automate the starting
and stopping of OBS, but I also want to make sure that if something crashes,
it starts back up the next day without me needing to fix it. Cron was
the obvious way to manage that, but since OBS is a GUI program, cron
proved to be challenging. In the end, I was able to include environment
variables in my crontab, and things worked smoothly. Here’s what my OBS
part of crontab looks like. Check it out, and I’ll explain it afterward:


DISPLAY=:0
@reboot sleep 10; obs --startstreaming
0 5 * * * /usr/local/bin/sunwait civ up 45.3733N 84.9553W;
 ↪obs --startstreaming
0 16 * * * /usr/local/bin/sunwait civ down 45.3733N
 ↪84.9553W; pkill obs

First off, setting the DISPLAY environment variable
to :0 means that
crontab can launch a GUI application on the current desktop. I was
embarrassed when I realized how easy it was to get cron to launch GUI
apps. It is important to note that the user must be logged in, however.

The @reboot line starts OBS when the system boots. The simple
--startstreaming flag tells OBS to launch and immediately start
streaming. It’s awesome. Really, if I had to figure out a way to automate
actually clicking a button, we probably wouldn’t be doing this project
together.

The next two lines are a little confusing. First off, I have the program
«sunwait» installed. It’s an old program, but it’s so
incredible,
I can’t
believe it’s not in every distribution by default. I’ve mentioned it
before in BirdCam articles, but basically, it’s a C program that determines
sunrise and sunset based on your longitude and latitude. The last version
was released in 2004 (seriously), but it still compiles. You can get
the source here.

Anyway, those two cron lines tell the server to start and stop OBS
at sunrise and sunset. At 5AM, I tell sunwait to «wait» until the sun
rises. It literally just waits until sunrise and then ends. Once it ends,
OBS is started up. Then at 4PM, I tell sunwait to wait until sunset, and
after the sunwait program ends, kill stops OBS. Why 5AM and 4PM? Well,
in my part of the world, the sun never rises before 5AM and never sets
before 4PM. There is the potential problem that if I reboot my server
after 4PM, it will stream all night. But that potential problem doesn’t
concern me enough to make the logic more complicated.

Since my server doesn’t have a monitor or keyboard connected, a random
GUI application starting and stopping in the middle of the screen doesn’t
affect anything. Since I connect to my server’s desktop only when I
want to make a change to OBS, it’s actually convenient that it’s always
running front and center on my desktop! I couldn’t be happier with the
current live stream setup.

Embedding the Stream

Not long ago, YouTube made a change so that every time a live stream
starts, it gets its own embed code. That means if you simply use the
«share» button on the live stream to get the embed code, it will work
only for that current streaming session. For me, that means the next day it
would show a recording of the previous day, but not the live stream. I’ll
be honest, that quiet change was very frustrating! Thankfully, there is
a way to embed the actual live stream, so that any time you start live
streaming, it becomes active—that’s where the Channel ID you got earlier
comes in.

Here is the embed code for my live stream at http://birds.brainofshawn.com»>:




Obviously, you’ll need to make the changes for your own channel, but
it should be clear what the various things mean. I stuck with the 720p
size even on my embedded page. Since this is embed code, you don’t have
to put it on its own page like I did; you could embed a tiny resolution
version on your blog, for instance.

Setting up the live stream through YouTube is nice for several
reasons. One, your bandwidth requirements don’t change even if you have
10,000 viewers. Also, since it’s YouTube, you can «cast» the video to
a television or Chromecast device and show off your channel to your
friends. I still hope to get more cameras and maybe set up camera
rotation on multiple bird feeders, but for right now, I couldn’t be
happier. Enjoy!

Working with YouTube and Extracting Audio

Working with YouTube and Extracting Audio

Image

Dave Taylor
Tue, 10/10/2017 – 06:48

In my last few articles, I’ve been exploring the capabilities of ImageMagick,
showing that just because you’re working on a command line
doesn’t mean you’re stuck processing only text. As I explained,
ImageMagick makes it easy to work
with images
, adding
watermarks
and analyzing
content far more accurately than with the standard Linux
file command,
and much, much more.

Continuing in a similar vein, I want to look at audio and video in this
article.
Well, maybe «listen» to audio and «look» at video, but
again, I’m still focusing on the command line, so in both instances,
player/viewer apps are required.

YouTube to MP3 Audio

As someone who watches a lot of lectures online, I’m also intrigued by
the online services that can extract just the audio portion of a YouTube or
Vimeo video and save it as an MP3. Listening to a lecture while driving is
far safer than trying not to watch a video on the move, for example.

Since there are so many live concert performances online, many people also
like to use a video-to-MP3 service to add those songs to their music libraries.

Note: be leery of copyright issues with any download and conversion of content.
Just because it’s on Vimeo, YouTube or other online service,
doesn’t mean you have permission to extract the audio or even download
it and save it on your computer.

Let’s start with the most basic functionality: downloading a video from
YouTube so you can watch it on your Linux system. There are a lot of
browser plugins and even websites devoted to this task, but who wants to
risk malware or be plagued by porn site ads? Yech.

Fortunately, there’s a terrific public domain program called youtube-dl
on GitHub that covers all your needs. At its most basic, it lets you
download video content from YouTube and a variety of other online video
repositories, but as you’ll learn, it can do quite a bit more.

You can grab a copy for your system
here.

Let’s start by downloading a copy of one of my own YouTube videos.
It’s a review of the splendid 1More quad-driver headphones, and its URL
is https://www.youtube.com/watch?v=BFL1E77hTHQ.

As an aside: I have a YouTube channel where I review consumer electronics
and gadgets. You should subscribe! Find all my videos at
http://youtube.com/askdavetaylor.

YouTube has a bunch of ways it can assemble a URL, however, including using
its URL-shortener youtu.be, but fortunately, youtube-dl can handle the
variations.

Downloading a copy of the video to the current working directory is now as
simple as:


youtube-dl 'https://www.youtube.com/watch?v=BFL1E77hTHQ'

The full output of the command is a bit, um, hairy, however:


$  youtube-dl 'https://www.youtube.com/watch?v=BFL1E77hTHQ'
[youtube] BFL1E77hTHQ: Downloading webpage
[youtube] BFL1E77hTHQ: Downloading video info webpage
[youtube] BFL1E77hTHQ: Extracting video information
[youtube] BFL1E77hTHQ: Downloading MPD manifest
WARNING: Requested formats are incompatible for merge and
will be merged into mkv.
[download] Destination: 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.f137.mp4
[download] 100% of 118.74MiB in 02:49
[download] Destination: 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.f251.webm
[download] 100% of 4.81MiB in 00:03
[ffmpeg] Merging formats into "1More Quad Driver In-Ear
Headphones Reviewed-BFL1E77hTHQ.mkv"
Deleting original file 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.f137.mp4 (pass -k to keep)
Deleting original file 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.f251.webm (pass -k to keep)
$

You can wade through the output messages, but it’s the message from
companion open-source program ffmpeg that’s most important:
merging formats into ... mkv.

In other words, the download format of the video is MKV by default. MKV is
part of the increasingly popular Matroska Multimedia Container format, and
it works with a lot of video players (including VideoLan, aka VLC, my favorite
cross-platform video player).

A quick ls reveals the result and that the default filename is taken from
the title of the video, something that might not be particularly desirable:


$ ls -lh *mkv
-rw-r--r--  1 taylor  staff   124M Jan 31 16:56 1More Quad
Driver In-Ear Headphones Reviewed-BFL1E77hTHQ.mkv

Do you prefer to specify the output name and have the output file in MP4 (MPEG4)
format instead? That’s doable:


$ youtube-dl -o 1more-review.mp4 -f mp4 \
    'https://www.youtube.com/watch?v=BFL1E77hTHQ'
[youtube] BFL1E77hTHQ: Downloading webpage
[youtube] BFL1E77hTHQ: Downloading video info webpage
[youtube] BFL1E77hTHQ: Extracting video information
[youtube] BFL1E77hTHQ: Downloading MPD manifest
[download] Destination: 1more-review.mp4
[download] 100% of 57.63MiB in 00:27

As a bonus, you get less ominous informational messages from the program
too, so it’s cleaner. And the output, sure enough, is in MP4 format:


$ ls -lh *mp4
-rw-r--r--@ 1 taylor  staff  58M Jan 31 16:57 1more-review.mp4

As a second bonus, it’s also more efficient in its video encoding, so
the MP4 version of the downloaded video is only 58M as opposed to the 124M
of the MKV-merged version.

So how do you watch it? Most likely, do a double-click and it’ll be up and
running, as shown in Figure 1.

Figure 1. Downloaded YouTube Video Playing in Ubuntu Player

That’s easy enough, but the original goal was to be able to extract just the audio
component of a YouTube video, so let’s look at that task.

Downloading Just the Audio Track

Since I’ve already started to delve into the command-line options for
the youtube-dl program, it’s not a leap to find out that there’s
yet another command-line option that lets you save just the audio portion
of a video:


$ youtube-dl -x --audio-format mp3 \
    'https://www.youtube.com/watch?v=BFL1E77hTHQ'
[youtube] BFL1E77hTHQ: Downloading webpage
[youtube] BFL1E77hTHQ: Downloading video info webpage
[youtube] BFL1E77hTHQ: Extracting video information
[youtube] BFL1E77hTHQ: Downloading MPD manifest
[download] Destination: 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.webm
[download] 100% of 4.81MiB in 00:07
[ffmpeg] Destination: 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.mp3
Deleting original file 1More Quad Driver In-Ear Headphones
Reviewed-BFL1E77hTHQ.webm (pass -k to keep)
$ ls -lh *mp3
-rw-r--r--  1 taylor  staff   4.0M Jan 31 18:22 1More Quad
Driver In-Ear Headphones Reviewed-BFL1E77hTHQ.mp3

That’s easy enough, and the output is delightfully small: 4MB total. The problem is,
there’s the same awkward naming issue, so the addition of -o
output-filename
definitely will be a win. But, really, youtube-dl makes
these tasks trivially easy, as long as you’re willing to figure out all
of its command-line options.

Writing a Wrapper Script

Instead of worrying about the obscure command-line flag notation, let’s
just write a script that does the heavy lifting for you. I’m going to
call it ytdl for «youtube download», and by default, it’ll accept
just a URL and output an MP4 format video file that has the same name as
the YouTube shortcut (for example, the above video would become BFL1E77hTHQ.mp4).

Add a second parameter, and that becomes the output filename. Specify the
-a flag, and it saves audio output only, in MP3 format instead.

Let’s start with a usage block if the user forgets to specify anything
or just needs a simple reminder:


if [ $# -eq 0 ] ; then
  echo "Usage: $(basename $0) {-a} YouTubeURL {outputfile}"
  echo "   where -a extracts the audio portion in MP3 format"
  exit 1
fi

That’s easy enough. The script is also going to use some predefined combinations
of flags to make it easier to write:


youtubedl="/usr/local/bin/youtube-dl"
audioflags="-x --audio-format mp3"
videoflags="-f mp4"
flags=$videoflags       # default set of command flags
audioonly=0             # default is audio + video

If the user specifies the -a flag,
audioonly will be set to true (that is, 1),
and the default flags will switch from video to audio:


if [ "$1" = "-a" ] ; then
  audioonly=1
  flags=$audioflags
  shift
fi

You’ll recall that the shift command moves all the parameters
«down» one to the left, so $2 becomes
$1 and so on. It’s an easy way to
process and discard parameters in a script, of course.

The biggest block of code creates a default output filename from the
YouTube URL:


if [ $# -eq 1 ] ; then
  # no output filename specified
  outfile=$(echo "$1" | cut -d= -f2)
  if [ $audioonly -eq 1 ] ; then
    outfile="$outfile.mp3"
  else
    outfile="$outfile.mp4"
  fi
else
  outfile="$2"
fi

This isn’t the most robust code, because it assumes that the URL
specified is in a format like the examples used herein,
youtube-yadda-yadaa?value=shortcode. It extracts the shortcode and simply
appends an appropriate filename suffix. There are better ways to do this,
but that’s okay, this’ll work for now. Just realize that your
output format might be a bit weird if you have a very different type of
YouTube URL or a URL from another site.

And, finally, the actual invocation of the
youtube-dl command:


$youtubedl $flags -o "$outfile" "$1"

That’s it! Now you can download a video as simply as:


$ ytdl 'https://www.youtube.com/watch?v=5yXDzg_QDGw' wiper.mp4

And an audio portion with:


$ ytdl -a 'https://www.youtube.com/watch?v=5yXDzg_QDGw'

Nice, eh?

I’ve way overrun my space for this column, but this is such a fun and
simple script atop a terrific, powerful program, that it’s worth it,
right? And now you know how to make YouTube work for you, rather than
vice versa!

YouTube on the Big Screen

YouTube on the Big Screen

Image

Shawn Powers
Wed, 09/20/2017 – 10:32

For years I’ve been jealous of folks with iOS devices who could just send
their phone screens to their Apple TV devices. It seems like the Android
screen-mirroring protocols never work right for me. My Sony Xperia has
multiple types of screen mirroring, and none of them seem to work on my
smart TVs or Roku devices.

YouTube is a completely different story. It doesn’t matter if I’m on a
laptop, iPhone, Android device or Chromebook, I can «cast» the video
to any of my Roku devices or smart TVs without any problems at all. It
works and works well. The great part about casting is you can shut off
the connection from the sending device, and it keeps playing! Because 95%
of the stuff I want to display on the TV from my phone is YouTube videos,
I couldn’t be happier. Plus, I can check email on my phone while the
family watches the latest «Bad Lip Reading» video on the big screen! Take
that Apple TV!

Nativ Vita

Nativ Vita

Image

James Gray
Mon, 08/21/2017 – 08:38

The motto «open to anything» underpins Nativ’s development philosophy
on all of its audio solutions, including its new Nativ Vita, «the world’s
first High-Resolution Music Player» and touchscreen control center that is
designed to function as the central access point for one’s entire music
collection.

This philosophy is evident in Nativ Vita’s Linux and open-source
internals, offering advantages like support for virtually any music service—even lesser-known and regional services like Jango Radio, KKBox and Paradise
Radio—and extensibility far beyond pure audio applications. Naturally, Nativ Vita
supports mainstream music services like Apple Music, SoundCloud, Vevo, Spotify,
TIDAL, Pandora and Amazon Music, among others.

Nativ Vita can store up to 4TB of
music on its internal hard disk drives or SSDs and can access remote files on a PC,
NAS or smartphone. Wireless streaming to multi-room speaker systems is achieved
utilizing popular solutions like SONOS and Bluesound and to high-end headphones
via Bluetooth aptX. A high-end digital output stage with myriad outputs ranging
from AES/EBU to USB Audio Class 2.0 connect the Vita to an amplifier or USB DAC
for best-in-class sound performance.

The Post-TV Age?

The most basic cable package from Charter (Spectrum?) costs me more than $70
per month, and that’s without any equipment other than a single cable
card. It’s very clear why people have been cutting the cord with cable
TV companies. But, what options exist? Do the alternatives
actually cost less? Are the alternatives as good? more>>

The Post-TV Age?

The Post-TV Age?

Image

Shawn Powers
Tue, 08/15/2017 – 09:33

The most basic cable package from Charter (Spectrum?) costs me more than $70
per month, and that’s without any equipment other than a single cable
card. It’s very clear why people have been cutting the cord with cable
TV companies. But, what options exist? Do the alternatives
actually cost less? Are the alternatives as good? I’ve been trying to
figure that out for a few months now, and the results? It depends.

The idea of cord cutting isn’t new. For years, people have been
severing their ties with cable companies in order to save money. The
ever-persistent question is this: how do the options compare?

Real Time or On Demand?

When replacing cable TV, there are two main types of media in
question. Services like Netflix, Amazon Prime and Hulu are great, but
they don’t provide live television. In fact, depending on the show and
service, you might need to wait until the next day or even the end of
a season before your desired shows are available. You usually get the
advantage of no commercials, but the waiting often is unbearable if
you’re into television shows that end with cliffhangers.

It is interesting though, now that Netflix and Amazon have been so successful with
their streaming services, they’re beginning to get their own exclusive
shows. This means that not only are the shows not delayed, but they’re also actually
not available at all via cable TV! Admittedly that phenomenon is fairly
new (only the last few years), but it makes the case for streaming far
stronger. Why pay $70 per month and still not get to watch
Jessica Jones?

Also, many individual stations are starting to offer their own
streaming options, so the days of paying for cable so you can see a
particular HBO show are over. Broadcast networks are starting to offer
streaming options too, so if you’re just looking for the ability to watch
particular television shows, even paying for multiple online accounts
is cheaper than paying for cable—usually.

All Those Cable Channels…

Some of the biggest hurdles for cord-cutters are cable-only channels. I
have a relative who watches only shows on the History Channel. And my
mother-in-law couldn’t live without watching movies on the Hallmark
Channel. And everyone I know in real life is addicted to HGTV and its
tiny house program. Those channels aren’t big enough to support a full
streaming platform (or are owned by actual cable companies, so they won’t
offer a non-cable alternative). So what’s a cord-cutter to do?

Until recently, not much. Now, however, there are three really good options
for streaming cable television stations, and one is almost really good. Those
options aren’t exactly cheap, and they’re mostly US-only, but they’re
far less expensive than cable TV. The three options each have their quirks,
but any of them are worth looking into if you have reliable internet
speeds that aren’t dependent on cable TV bundling. Currently, the three main
options are Sling TV, PlayStation Vue and DirecTV Now.

Streaming Cable: Sling TV

Sling TV has been around the longest and is owned by Blockbuster
(yes, that Blockbuster!), who in turn is a subsidiary of Dish Network. It
has a large lineup of cable stations and several tiers of options that
include packages like premium cable channels. Depending on promotions and
where you live, the packages range from $20–$40 per month. If you live
in a big city, you also might get local broadcast stations (NBC, ABC,
CBS, PBS, FOX), but for most of the country, you get those channels
only «on demand», which means recordings of popular shows the next day.

Figure 1. Sling TV has been around a long time, but the lack of DVR and
video glitches make it less than stellar in my experience.

The technology details of Sling TV are a little confusing. If you
subscribe to the lowest tier, you can stream only one channel per account
at a time. That means if you are watching TV in your living room, you
can’t watch something else on your phone. If you subscribe to a
higher-priced tier, you can have up to three streams at once. Also,
although the streams
usually are good quality, my anecdotal experience shows that there are
a few more artifacts and glitches with Sling TV than with the other options,
but nothing that makes it a showstopper. (I get glitches with my cable
television too, so nothing is perfect.)

There’s a free trial with Sling TV, so it’s worth checking out. Just
be sure to cancel it before your credit card auto-renews at the end of the
trial, unless you decide to keep it. Also, because it’s been around for a
long time, Sling TV has apps on multiple platforms. Xbox users can install
Sling TV, along with Android TV and Roku users. Like most streaming
services, Roku does a great job of staying vendor-neutral, which means
it usually can provide services regardless of who is providing
them.

PlayStation Vue

PlayStation Vue is a bit more of a surprise, since Sony PlayStation
is synonymous with gaming rather than television. Its offerings
are impressive, however. The lineups are similar to Sling TV, but
the breakdowns are a little different. The lowest-price service is around
$30 per month, with other tiers available that add more channels. Sony
gives you a price break if you’re not in one of the cities that has local
channels available, so for me in rural Michigan, it’s cheaper than if I
lived in Chicago. (That means I don’t get local channels though, which
is frustrating.)

Figure 2. PlayStation Vue is remarkable, until it’s not. The video
quality is amazing, and the DVR is superb. The geolocation frustrations
along with PS4 console problems make it difficult to love.

Although the slightly higher price seems frustrating, the technology included
might make up for it. Not only can you stream to five devices simultaneously,
but it also provides «Cloud DVR», which automatically stores recorded
content for you. All you need to do is mark a program as a favorite,
and all episodes are saved for 30 days. It’s not possible to schedule a
timed event, but the DVR feature is extremely nice, and it provides a far
better experience than the live-only Sling TV.

The video quality with PlayStation Vue is
shockingly good. Whether
watching on a mobile device, a Roku or a PlayStation system, the video is
far more reliable in my anecdotal trials. The five streams means people can
watch TV in multiple rooms, and since Vue allows for individual profiles,
different family members can have their own DVR’d shows. The only really
big issue I’ve had with PlayStation Vue is that it’s not possible to
watch streams from the same account on two different PlayStation 4
consoles. I have a console in my office and a PlayStation Pro in the
living room, and it’s not possible to watch Vue on both devices. That is
particularly frustrating, because watching on multiple Roku units works
fine, but not on the actual Sony hardware! There’s also some frustration
with geolocation. Sony often thinks I’m not home, so it limits what I can
watch. I would understand if my IP address changed, but I have a static
IP address and I’m always connecting from home! (See the notice in Figure
2.)

DirecTV Now

DirecTV Now is the new kid on the block when it comes to cable TV
streaming. The packages are similar to the other services I mentioned, with some
initial low-priced options available to entice users away. (Note: with all
these services being contract-free, the potential for moving in order to
save a few bucks is very legitimate!) DirecTV Now has similar limitations
regarding live broadcast stations (that is, at the time of this writing there aren’t
any available), but DirecTV Now has the additional limitation that even
on-demand content from CBS isn’t available. The kerfuffle that DirecTV and
CBS have been having extends to the streaming service as well.

Figure 3. DirecTV Now is the new kid on the block. The $35/month is a trial
cost and likely will increase before this article is published.

I haven’t personally used the DirecTV Now service, because none of my
devices currently are supported. (Apple TV is its main device, and you
can get one free if you pre-pay for three months of service.) I have friends
who’ve used it though, and they say the quality is very good. Like Sling
TV, however, it doesn’t currently have any DVR capability.

Since DirecTV Now is new, it’s not fair to criticize its lack of
hardware support yet. Roku streaming is slated for Q1 2017,
and it’s possible other non-competitors will get apps as well. As is
usually the case, Roku likely will be one of the premiere ways to watch
streaming cable TV service, because its compatibility will allow for
service-hopping without hardware reinvestment.

USTVnow, the Sort of Option

USTVnow is a service designed for US citizens living outside
the US and, therefore, unable to get US television. It’s a streaming
service that provides live network channels (ABC, CBS, NBC, PBS, FOX)
for free, and for a monthly fee, it adds a few cable channels (28 total)
and HD streaming as well. There is also some DVR service included with
the premium packages. Any time I’ve tried to use USTVnow inside the
US, it’s worked perfectly, so there aren’t any apparent geographical
restrictions. Honestly, on paper, it’s the best thing going.

Figure 4. I want to love USTVnow, and perhaps now that there is a paid
service, the reliability will improve. I just hope it’s able to keep
providing live broadcast channels in the US.

Unfortunately, the times I’ve used USTVnow, I’ve had lots of
glitches. Usually it’s during busy times (Super Bowl party, for instance)
that the service glitches, but since those are the times I want it to work
the most, it’s been a frustrating service. The pricing is competitive,
however, especially since the SD free tier is really free and provides
live broadcast stations. As with most services, Roku seems to be the
best way, apart from a browser, to consume USTVnow.

I want to love USTVnow. I have no idea how it’s able to provide
service in the US when the other options struggle to provide broadcast
stations. Hopefully, it’s not a loophole that will be closed, because
for some folks, it’s the only way to get broadcast channels at all,
even if they do live in the US.

Rabbit Ears

Yes, obviously using an antenna is a great way to get local television. In
fact, you can head over to http://antennaweb.org and see what
channels are available in your area and what sort of antenna you’ll
need. The site even will tell you what direction to point your antenna for
the best signal. If you’re just looking for some old-fashioned television,
an antenna is often a good option. Plus, apart from the hardware, it’s
totally free.

Figure 5. «Up to 0 channels» is a sad thing to see; I hope your
location is better.

The problem is, even though I live in a (small) city, I get exactly
zero channels from my location. That is due to geography, because I live
on the side of a hill, but nonetheless, I can’t get any channels using
even a rooftop antenna. Even if you can, however, it’s worth considering
whether that sort of system is acceptable for you. I don’t want to switch my
input source on the television every time I want to watch TV. And TiVo has
spoiled me; I want to pause live TV. It’s possible to get something like
an HD Homerun device from Silicon Dust and convert your antenna signal
into a digital stream, but integrating that into your entertainment system
is often challenging. Plus, I had so much frustration with my HD Homerun
setup in our last house that I opted to just buy a cable TV subscription.

So OTA (over the air) channels are worth checking out, and for some
people, they are more than enough. For me, however, even if I could get
a good signal, I want more.

What about the Parade?!

If you live in a big city and can get local channels via services like
Sling TV or PlayStation Vue, things like watching the Thanksgiving Day
parade are possible. For me, the only way I can watch live events is
with the not-always-reliable USTVnow. And even those channels aren’t
local, so I can’t ever watch the local news. My big issue used to be how
to watch the Olympics, but thankfully, many streaming options
are available now. Still, watching the Thanksgiving Day parade is something I’ve done
my whole life, and without some way to see local channels, all the cable
channels in the world don’t help.

Because I have thousands of dollars invested in my TiVo infrastructure
(lifetime Roamio subscription and four TiVo Minis), I’m still paying for
the lowest tier of cable TV. I find that we almost never switch over
to the TiVo, however, so in the next few months, I might bite the bullet
and cancel cable TV altogether. For most folks, services like Sling TV,
PlayStation Vue and DirecTV Now provide more than enough service at a
fraction of the cost. So if you live in a big city or can live without
live broadcast channels, I urge you to give them a try. Each is available
with a free trial, and if you sort through the various pros and cons,
coming up with a satisfactory service is pretty easy.

If you’ve cut the cord (many of you I’ve spoken with already
have done so), I’d love to hear about your specific solution. Do you just
switch sources on your TV and use rabbit ears? Do you strictly Netflix
and chill? Have you sold your television and reverted to books? (I’m
often tempted.) Please let me know. I’d love to follow up with some
alternatives for folks like myself who are still struggling to cut
the cord.

Analyzing Videos for Fun and Profit

Analyzing Videos for Fun and Profit

Image

Joey Bernard
Wed, 07/05/2017 – 05:46

People’s phones and all of the various sensors that may be built in to them
is a
source of scientific data logging that almost everyone carries around.
Although the selection of sensors varies from phone to phone,
they almost all have a camera. In this article, I take a
look at a piece of software called Tracker that can be used to analyze
videos you take of experiments.

You can download Tracker directly
from the project page.
A lot of good documentation is available at the main website, including
examples of how you might be able to use it from the community of other
users. Tracker is written in Java, however, so you also need to
have a JVM installed on your system before you can use it. For example,
on a Debian-based system, you can install a very good JVM with the command:


sudo apt-get install openjdk-8-jre

You then can download the relevant installer for your system and run
it from a terminal window. You probably will need to make the installer
executable with a command like this:


chmod +x Tracker-4.95-linux-64bit-installer.run

Don’t forget to use the sudo command so that you have the correct
permissions to do the installation.

Once it’s installed, you should have a new entry in your applications
menu system. Starting Tracker will give you a new empty project for
beginning
your video analysis.

Figure 1. When you start Tracker, you get a new empty project.

Although you could start analyzing your own videos immediately, you may want
to use simpler videos while learning how Tracker
works. When you ran the initial installer for Tracker, it should have
asked you whether you also wanted to install example files. Assuming you
said yes, you now can load one of those within Tracker. When you click
on the menu item File→Open File, you’ll see a new window where
you can select either a movie file or a Tracker file.

Figure 2. The open file dialog box allows you to open movie files or
Tracker files.

To begin with, let’s look at one of the Tracker files from the
experiments folder. In Figure 3, I have loaded the experiment
file named BallToss.trk. The main window displays the
movie that is being analyzed as part of the experiment. The pane in the
bottom right-hand side shows a table of x and y coordinates for a series
of time units. A similar table is generated for each tracked object within
the movie. In this example experiment, the only tracked object is the
ball. The top right-hand pane contains the associated plot for the data
stored in the table. This way, you can have a visual representation of
the tracked motion.

Figure 3. Loading a Tracker file opens all of the parts of a previous
analysis.

So, what can Tracker actually track? At the bottom of the movie display is
a set of controls. If you click on the green arrow, the movie will start to
play. As it does, Tracker actually registers the movement of the tracked
object and also updates the data panes on the right-hand side.

Figure 4. As the movie progresses, Tracker updates the data panes on
the right-hand side for the tracked object.

Although these panes do give you lots of raw data, there really isn’t any
analysis being done yet. Clicking the View→Data Tool menu item pops
open a new window where you can use this raw data to figure out what is
happening in the video.

Figure 5. The Data Tool window provides a set of analysis tools to
look at the raw data pulled from the video.

The Measure and Analyze buttons at the top of the plot window provide
a set of different sections that you can display. This gives you several
different analysis options for your data. Clicking the Measure
button gives you the options Coordinates, Slope and Area. When you
select one or more of those options, values are displayed
at the bottom of the plot representing each of the selected options.

When you click the Analyze button, you get a drop-down with the
Statistics, Curve Fits and Fourier Spectrum options. Each of
those options actually opens a new pane in the Data Tool window. The
exception is the Fourier Spectrum option. This option actually opens
a new window where a Fourier analysis is done on the raw data from the
tracked object.

Figure 6. Tracker also can do a Fourier analysis of the observed
motion.

The Statistics option gives the data displayed in the top right
pane. This is the set of descriptive statistics—that is, the maximum,
minimum, mean and standard deviation, among other values.

Selecting the Curve Fits option gives you the pane at the bottom of
the plot window. Here you can select what type of curve is being fitted
to your raw data. You can use a number of default functions
to try to fit your data. In this case, the linear function is the
obvious choice for a fitting function. You can see the function being
used, x=A*t+B in this case, along with the calculated values for the
parameters A and B. If you are tracking an object that has a really odd
motion, you can click the Fit Builder button to pop up a new window
where you define a new fitting function.

Figure 7. You define your own fitting functions as part of the data
analysis.

What do you do as part of a new project? Let’s say you want to analyze
the pendulum video from the sample video folder. You can set some
calibration items within the video by either selecting the relevant
buttons at the top of the window or selecting the items under the menu
entry Track→New→Calibration Tools. You can set up items like a calibration
stick or a reference set of axes.

Figure 8. You can set up calibration tools within your video to be
analyzed.

One way to do the analysis is to step through the video, frame by frame,
selecting the object to be tracked within each frame. This may be the only
way to collect the raw data, but humans are lazy. If the object being
tracked is relatively consistent across the duration of the video clip
in question, you can try using the autotracker. Clicking the autotracker
button will pop up a new window where you can control what is being
tracked.

Figure 9. The autotracker tries to follow an object
from frame to frame automatically.

Tracker helpfully displays reminder information on how to
use the software. In this case, it reminds you that you need to
press Ctrl, Shift and left-click the mouse button on the object of
interest. If you then click the search button within the autotracker
window, it will move through each frame, looking for the object in
question. Once it is done, you should have a full set of data from the
tracked object. From the plot in Figure 10, you can see right away that
the pendulum follows the expected motion. You also can track multiple
objects by creating a new track for each object.

Figure 10. The autotracker can generate all of your raw data
automatically.

Now that you’ve taken a quick look at Tracker and the kind of analysis
you can do with it, you should be comfortable enough to start
experimenting with it. Don’t forget to share any interesting ideas you come
up with on the community page and add to a great resource for citizen
science.