Ter­mi­nal Me­dia tools........................

Nick Peers dis­cov­ers how the Ter­mi­nal can do more than sim­ply let you play back your col­lec­tion of video, mu­sic and im­age files…

Linux Format - - CONTENTS - Nick Peers has an un­healthy ob­ses­sion with dig­i­tal me­dia, not helped by his de­ter­mi­na­tion to drown in a sea of DVDs, Blu-rays and CDs as he at­tempts to amass the ul­ti­mate dig­i­tal me­dia col­lec­tion.

Nick Peers ex­plains how you can man­han­dle all your me­dia from the end­less, soul-con­sum­ing black­ness of the ter­mi­nal.

Mul­ti­me­dia plays a key role in com­put­ing, and you don’t need to be logged into the desk­top to be able to en­joy your col­lec­tion of mu­sic and video files, and pho­togrphs. The com­mand line also pro­vides ac­cess to a host of tools that en­able you to rip, en­code, con­vert and tweak your me­dia files.

Let’s start by mak­ing sure Ubuntu has full mul­ti­me­dia sup­port. Even if you ticked the box to in­stall third-party soft­ware dur­ing the in­stall process you’re still miss­ing sev­eral key el­e­ments. First, let’s in­stall all of those “re­stricted” ex­tras, not just the few added at the in­stall stage. Open the Ter­mi­nal and type the fol­low­ing: $ sudo apt-get in­stall ubuntu-re­stricted-ex­tras

This will in­stall sev­eral ad­di­tional pack­ages, while the libav­codec-ffm­peg56 pack­age will be re­placed by libav­codec-ffm­peg-ex­tra56, which com­prises a wider se­lec­tion of GStreamer plug­ins (see https://gstreamer. freedesk­top.org) for me­dia stream­ing, play­back, edit­ing and pro­cess­ing. You’ll be prompted to in­stall Mi­cro­soft TrueType fonts – press Tab fol­lowed by En­ter, then select Yes with the cur­sor keys be­fore hit­ting En­ter again.

This com­mand adds sup­port for play­ing en­crypted DVDs: $ sudo apt-get in­stall lib­dvd-pkg

When in­stalled, type: $ sudo dpkg-re­con­fig­ure lib­dvd-pkg

This com­pletes the process. If you’re look­ing to play Blu-rays on your PC, check out the box ( see­top-right).

Me­dia play­back

There are plenty of choices when it comes to play­ing me­dia on your PC, and VLC is the ob­vi­ous choice for, par­tic­u­larly if you want to play com­mer­cial discs. In­stall it with sudo apt-get in­stall vlc , then you have a choice of run­ning it from the desk­top or di­rectly from the com­mand line, which will open a win­dow on the desk­top with your me­dia play­ing. You can con­trol VLC com­pletely from the com­mand line – type vlc --help for a list of com­mands, but for ba­sic play­back pur­poses it dis­tils down to typ­ing vlc fol­lowed by the source, which can be to a me­dia file ( file:///path/file ), DVD ( dvd:// [de­vice] ) or Blu-ray ( blu­ray://[de­vice] ) – for ex­am­ple: $ vlc dvd:///dev/sr0

You can also stream me­dia over the in­ter­net ( http:// host[:port]/file and sub­sti­tute http with ftp or MMS if nec­es­sary) and via a UDP stream­ing server: $ vlc udp://[[<source ad­dress>]@[<bind ad­dress>][:<bind port>]]

Play from the com­mand line

If you want a mu­sic player that comes with a com­mand-line in­ter­face (per­fect for re­mote ac­cess or us­ing out­side of the desk­top), then there are sev­eral choices. Let’s start with a tool

for play­ing a wide range of mu­sic for­mats (FLAC, OGG, MP3 and so on) direct from the com­mand line called SoX: $ sudo apt in­stall sox lib­sox-fmt-all The lib­sox-fmt-all li­brary in­cludes sup­port for pro­pri­etary for­mats such as MP3. Once in­stalled, browse to the folder con­tain­ing your mu­sic and in­voke it us­ing the play com­mand: $ play *.mp3

Use Ctrl+C to jump to the next track, or press it twice to stop play­back. Type play --help to see a full list of avail­able op­tions, in­clud­ing a wide range of ef­fects and fil­ters, such as: $ play *.flac bass +2 gain +1 re­verb If you’d like a more in­ter­ac­tive player, then try cmus ( sudo apt in­stall cmus ). Once launched, af­ter a short pause you’ll be shown a two-pane win­dow. The app is con­trolled in a sim­i­lar way to the Vi text edi­tor – for ex­am­ple, to load your Mu­sic folder into the pro­gram, type: :add ~/Mu­sic You can then browse for tracks and playlists - type man cmus for a de­tailed user guide. You can also plug in ex­tra fea­tures via ex­ten­sion scripts – see https://github.com/ cmus/cmus/wiki for more de­tails.

The power of FFm­peg

Things nat­u­rally get more com­pli­cated when you look to con­vert au­dio and video, whether that’s switch­ing be­tween for­mats (say .avi to .mp4), recording a live stream or some­thing more com­plex, such as em­bed­ding sub­ti­tles into a file. One of the best-known tools for the job is FFm­peg ( sudo apt in­stall ffm­peg ). It recog­nises a wide range of for­mats and comes with tools ( ff­server, ff­play and ff­probe) for transcod­ing, stream­ing and play­ing me­dia, too.

We’re going to scratch its very large sur­face by look­ing at some ba­sic real-world uses. First up – to con­vert a file from MKV to MP4 format: $ ffm­peg -i in­put­file.mkv -vcodec copy -acodec copy out­put­file.mp4

You can take this fur­ther and quickly con­vert (or re­mux as it’s known) a folder full of files: $ for i in *mkv; do ffm­peg -i “$i” -vcodec copy -acodec copy “$i.mp4”; done

This ba­sic ex­am­ple changes the file type (which is also known as the con­tainer), but doesn’t change its codecs (the au­dio and video con­tent). It’s al­most in­stan­ta­neous be­cause there’s no de­cod­ing, con­vert­ing and then re-en­cod­ing of the video or au­dio streams: they sim­ply switch from one codec to another.

If you want to con­vert a video’s codec as well as its con­tainer (type ffm­peg -codecs for a full list of sup­ported codecs), you’d as­sume the fol­low­ing syn­tax would work: $ ffm­peg -i in­put­file.wmv -vcodec h264 -acodec aac out­put­file.mkv

In fact, you’re likely to get a string of er­rors: “too many chan­nels” in­di­cates there are multiple video and/or au­dio streams, but FFm­peg will at least try to choose the correct ones (a process called stream map­ping). How­ever, the next er­ror will be the killer – be­cause you’ll need to spec­ify cer­tain pa­ram­e­ters for the en­coder you picked un­der -vcodec .

Th­ese pa­ram­e­ters can be de­ter­mined by typ­ing the fol­low­ing com­mand: $ ffm­peg -h en­coder=h264

This pro­duces a long, com­plex list – for a guide to en­cod­ing in com­mon for­mats such as H.264, VP8/9 and AAC, read through the En­cod­ing sec­tion at https://trac. ffm­peg.org/wiki.

More tools

Let’s fin­ish by look­ing at some niche tools. First up is ff­probe, which is in­stalled along­side FFm­peg. It’s a handy way to view the meta­data at­tached to a spe­cific me­dia file: $ ff­probe file.mp3

Next, there’s nor­mal­ize, a tool that ba­si­cally en­sures all your mu­sic tracks have a stan­dard vol­ume level, per­fect for playlists where you don’t want to be con­stantly yank­ing the vol­ume con­trol up and down: $ sudo apt in­stall nor­mal­ize-au­dio

Now browse to a folder of files and type the fol­low­ing: $ nor­mal­ize-au­dio -bv *.mp3

This scans all the files in the di­rec­tory to com­pute a stan­dard de­vi­a­tion be­tween the tracks (ex­treme de­vi­a­tions are ig­nored), then it ap­plies an ad­just­ment to all the tracks – in­clud­ing those with ex­treme de­vi­a­tions – to bring them all into line with each other. If you don’t need the ver­bose out­put, use -b in­stead of -bv .

Fi­nally, exiftool ( sudo apt in­stall li­bim­age-exiftool-perl ) dis­plays meta­data for a range of me­dia for­mats, but it’s also ca­pa­ble of writ­ing meta­data to many pop­u­lar im­age for­mats too, in­clud­ing JPG, TIF, GIF and PNG. Go to https://linux.die. net/man/1/exiftool for a de­tailed guide to us­ing it.

You’ll have most suc­cess play­ing older Blu-ray movies through VLC – launch it from the com­mand line.

The CMus mu­sic player works in a sim­i­lar way to the Vi text edi­tor. Re­mem­ber to pref­ace com­mands with the colon (:) sym­bol.

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.