Rough Guide to Bitrate Calulations for Video Encoding

Want a video to be a particular size?

((Size (mb) x 8192) / length of video (secs)) – audio bitrate (k) = video bitrate required

Example in bash with file size of 13.79mb, audio bitrate of 128k and length of 180 seconds:

What to know the size of a video when using a particular bitrate?

((Video bitrate (k) + Audio bitrate (k))  x length (secs)) / 8192 = Size (mb)

Example in bash, with video bitrate of 500, Audio bitrate of 128, length of video 180 seconds:

You can put these into a variable:

ffmpeg – Create Movie from a Single Image and A Sound file

You see these on youtube a lot, and sound file being played back with a fixed image. This is how to create one using ffmpeg

The -shortest option ensures the video is created the same length as the sound file (the shortest of the two inputs, as the image file will loop forever!

The -loop 1 option (which replaces loop_input) ensures the image file is continuously looped.

one can play around with audio codecs, video outputs and aspect ratios until you have what you want (you can always use -t for time in seconds for testing)

Bash – Sort Files in All Sub-Directories by Extension

I try to be organised, and put everything in folders where they belong, but, especially at work, this all stops being important after a couple of years, and becomes more difficult to find things especially when backed up. This one liner can resolve all of that by moving each file type to a directory of its own, retaining any duplicate files for further inspection. It may be best to keep a backup of all the original file locations where files of many types come together to make a whole.

Here is my one liner, which needs to be placed in the top directory. One can add as many different file extensions as needed into the variable array EXTS. I have used txt and jpg as example extensions.

Continue reading

Mplayer – neat and tidy on the CLI

How long have I been using mplayer? Years. Why has it never bothered me to sort this out before? Don’t know. Ageism, autism, or general grumpiness sent me off in search of a solution, and how easy was it.

Every time I have run mplayer from the cli I got three lines written out before the “action”:

mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

The very simple fix to this is to add an entry to your ~/.mplayer/config file

lirc=no

That’s it, no more extra lines. Remember to comment out “lirc=no” if you want to use a remote control, though 🙂

get_iplayer – Command Line Downloader for BBC iplayer

get_iplayer

My favourite program of the moment which exceeds the delivery of the iPlayer on Windows in just about every way!

To get the best out of it, download the latest version (and everything else you need) from here, and also make sure you have the following installed to make the most of the features available:

flvstreamer
ffmpeg
mplayer

(If you must install on Windows, there is an installer which takes care of everything for you)

flvstreamer is especially useful for getting higher quality versions of programmes, but you may have to fiddle about with the location of the file and its permissions to get things working correctly.

Ok, here are the commands I use the most:

get_iplayer
(this gathers a full index of programmes available)

get_iplayer keyword
(gathers index but also finds matches for “keyword” of your choice, e.g. Dr Who or Casualty)

Running the two above will show you the index number for the programme. Use this as follows:

get_iplayer –info 123
(will provide detailed info about the programme, including the various versions and qualities available)

get_iplayer -get 123
(will download the default version, usually iPhone – mov quality)

get_iplayer -get 123 modes=flashhigh flvstreamer=’/usr/bin/flvstreamer’
(will download a higher quality version in mp4 format using flvstreamer, my binary is located in /usr/bin/)

Finally

get_iplayer –update
(simply checks for any updates to get_iplayer and installs them)

Further commands, help and information here

Fixing USB Remountable Devices in Minimal CLI Installations

 Keep meaning to log this here, as I seem to have to do it every time I do a command line installation. For some reason, USB devices – flash drives, USB hard drives etc, refuse to mount, even with Thunar and volman installed. A repair is required to the PolicyKIt.conf as follows:

sudo nano /etc/PolicyKit/PolicyKit.conf

and add the following lines in between the <config> tags:

<match action=”org.freedesktop.hal.storage.mount-removable”>
<return result=”yes” />
</match>

You will possibly need a reboot to get this working right.

Now your USB devices should automount correctly