Convert video to several JPG images on Linux without ffmpeg.

I admit… I do love PHP in the command line. Does that make me a bad person? ūüėČ

Here’s a tiny little script that I wrote to create many JPG screenshots of a video file. I use this each week to create a bunch of stills from our broadcast so I can use them as thumbnails and so-on. I didn’t want it to depend on ffmpeg since I don’t have that on any of my modern systems.

It requires just three packages: mplayer mediainfo php-5

Save it as whatever.php and run it like this: php whatever.php file.wmv

It will create a folder called file-Screenshots/ and will save one picture per 10 seconds for any video source. Just change “file.wmv” to the name of your video. Include the path if it’s not in the current folder.

Hope it helps you out.


Find the version number of all WordPress installations on your Linux server.

I have a lot of customers running WordPress on our shared hosting servers, and sometimes they neglect to update their WordPress installs. [Rolls Eyes]

I need to know which of these sites are using an obsolete version of WordPress so I may contact the customer and warn them that they need to update their software.

So here’s a helpful little Linux command I whipped up and ran as root to go through my /home folder searching for all WordPress versions. I only had to run it as root because I am checking through¬†all users’¬†folders, not just my own. If you only want to check your own user, you don’t need root access.

I ran this command from my /home folder on the Linux server:

find . -name 'version.php' -exec grep '$wp_version =' {} /dev/null \; > /tmp/wordpress-versions.log


  • find . -name ‘version.php’
    Search through the current folder, recursively, for any file named version.php. This is where WordPress stores the WordPress version number.
  • -exec
    Execute a command with each found item.
  • grep ‘$wp_version =’ {}
    Look within the found version.php file(s) in a loop for the term $wp_version = and output the result.
  • /dev/null
    Trick grep into thinking there is a second file, forcing it to precede the output with the filename provided by find
  • \;
    Close the find command.
  • > /tmp/wordpress-versions.log
    Save the results to a log file in /tmp. You can tail -f this file while scanning, or simply open or cat it when you’re done. Leave this portion out of the command if you’d rather have it output directly to your screen.

Preventing rsync from doubling–or even tripling–your S3 fees.

Using rsync to upload files to Amazon S3 over s3fs? ¬†You might be paying double–or even triple–the S3 fees.

I was observing the file upload progress on the transcoder server this morning, curious how it was moving along, and I noticed something: the currently uploading file had an odd name.

My file, CAT5TV-265-Writing-Without-Distractions-With-Free-Software-HD.m4v was being uploaded as .CAT5TV-265-Writing-Without-Distractions-With-Free-Software-HD.m4v.f100q3.

I use rsync to upload the files to the S3 folder over S3FS on Debian, because it offers good bandwidth control.  I can restrict how much of our upstream bandwidth is dedicated to the upload and prevent it from slowing down our other services.

Noticing the filename this morning, and understanding the way rsync works, I know the random filename gets renamed the instant the upload is complete.

In a normal disk-to-disk operation, or when rsync’ing over something such as SSH, that’s fine, because a mv this that doesn’t use any resources, and certainly doesn’t cost anything: it’s a simple rename operation. So why did my antennae go up this morning? Because I also know how S3FS works.

A rename operation over S3FS means the file is first downloaded to a file in /tmp, renamed, and then re-uploaded.  So what rsync is effectively doing is:

  1. Uploading the file to S3 with a random filename, with bandwidth restrictions.
  2. Downloading the file to /tmp with no bandwidth restrictions.
  3. Renaming the /tmp file.
  4. Re-uploading the file to S3 with no bandwidth restrictions.
  5. Deleting the temp files.

Fortunately, this is 2013 and not 2002. ¬†The developers of rsync realized at some point that¬†direct uploading may be desired in some cases. ¬†I don’t think they had S3FS in mind, but it certainly fits the bill.

The option is –inplace.

Here is what the manpage says about —inplace:

This option changes how rsync transfers a file when its data needs to be updated: instead of the default method of creating a new copy of the file and moving it into place when it is complete, rsync instead writes the update data directly  to  the destination file.

It’s that simple! ¬†Adding –inplace to your rsync command will¬†cut your Amazon S3 transfer fees by as much as 2/3 for future rsync transactions!

I’m glad I caught this before the transcoders transferred all 314 episodes of Category5 Technology TV to S3. ¬†I just saved us a boatload of cash.

Happy coding!

– Robbie