Format Video Length in HH:MM:SS from Command Line
In my experimentation with audio and video manipulation, I've found that most tools prefer to handle time in HH:MM:SS (hour:minute:second) format. I always presumed that using seconds would be easier but I'm barely a novice media tool user, much less a tool creator.
When I wrote the Create Short Preview from Video post, I calculated the video length in seconds with the following command:
length=$(ffprobe $sourcefile -show_format 2>&1 | sed -n 's/duration=//p' | awk '{print int($0)}')]
That was helpful in detecting if a video was long enough to generate a preview for, but I then needed to get that length in HH:MM:SS format:
formattedlength=$(printf "%02d:%02d:%02d\n" $(($length/3600)) $(($length%3600/60)) $(($length%60)))
In the end you need to evaluate loads of individual statements to get your final HH:MM:SS format!
![7 Essential JavaScript Functions]()
I remember the early days of JavaScript where you needed a simple function for just about everything because the browser vendors implemented features differently, and not just edge features, basic features, like addEventListener
and attachEvent
. Times have changed but there are still a few functions each developer should...
![Facebook Open Graph META Tags]()
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
![Create a Sprited Navigation Menu Using CSS and MooTools]()
CSS sprites are all the rage these days. And why shouldn't be? They're easy to implement, have great upside, and usually take little effort to create. Dave Shea wrote an epic CSS sprites navigation post titled CSS Sprites2 - It's JavaScript Time.
![Adding Events to Adding Events in MooTools]()
Note: This post has been updated.
One of my huge web peeves is when an element has click events attached to it but the element doesn't sport the "pointer" cursor. I mean how the hell is the user supposed to know they can/should click on...