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.

-Robbie

Slowing down the transcoders and Season 4 is online!

As you may have noticed, I had to slow down the transcoders.

Yes, they operate super fast and can transcode all our back episodes in a very short time as previously reported.

However… they cost a lot of money! Le gasp!

As you can imagine, Category5 TV back episodes take up a lot of space on the web. Over a terabyte as a matter of fact. So transcoding, uploading and distributing all 300+ episodes all in one fell swoop was a bad idea from a cost perspective.

So I slowed things down to a more manageable price point so I can space the cost out over multiple months.

Okay, all that said, exciting news this weekend: Category5 TV SEASON 4 is now entirely transcoded and available for on-demand viewing at http://www.category5.tv/episodes-season-4.php!

It is my dream that one day all 7 seasons (and beyond) of Category5 TV will be available for on-demand viewing, and this brings us just a little bit closer to this goal.

Many of the episode content will be dated (as we’re talking episodes which are 3 or 4 years old), but there is still some excellent information in there, such as understanding how to safely dispose of a computer to avoid your private data being compromized, enhancing photographs with the GIMP, how to create panoramic photographs using a standard digital camera, creating mosaic images from hundreds or thousands of photographs, and even our popular web development series in its entirety.

Enjoy these “new” old episodes! Now, to begin tackling Season 3!

-Robbie

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