Entries Tagged 'media' ↓
June 27th, 2007 — code, media, ruby, rails, rmagick
One really cool thing I like about the ImageMagick library (and more importantly, the RMagick library for a ruby-geek like me) is it’s ability to do pretty much anything imaginable with graphics. And that’s just what I needed for my upcoming release of my pending open-source graphics plugin (yet to be publicly named).
For a client of ours, I needed to generate an animated gif pulled from frames of a movie. This way, a small version of the movie could be displayed on the site without loading the flash player and giving the viewer a quick look at the contents.
Well, RMagick’s ImageList class is just what I needed to do this job.
I also already have a system set in place to handle creating thumbnails on the fly and I didn’t want to modify those processes based on the process, I’d rather just call the correct methods and let the system do the work. Luckily, those are already in place for me and ImageList’s handle what they need to do.
I am pretty familiar with the functions in attachment_fu, so for this post I will use some of technoweenie’s code to demonstrate the point. (However, this functionality will be built into my future plugin too… oooo I can’t wait to release it! Just have to finish it up and test the heck out of it;)
So, let’s get started
First thing we have to do is make sure we have an flv. This is because we will be using the excellent flvtool2 executable written in ruby.
Using and open3 in the ruby library and yaml, we can capture the output and grab the duration of the flv file itself:
def get_movie_information(file)
stdin, stdout, stderr = Open3.popen3("flvtool2 -P #{file}")
YAML.load(stdout).to_a[0]
end
We capture the stdout, stdin and stderr using the Open3 library and capture it into a yaml structure. Pretty cool, ey?
Since flvtool2 outputs the file first and the data associated with that in it’s own structure, we have to grab that data. I’m not really interested in the file, so we’ll “discard” that information (you can keep it, if necessary) and just grab the data we want.
To do this, I had to “convert” the hash into an array with the super-slick to_a method on a hash.
def create_screenshot(flv, nf)
info = get_movie_information(flv)
num = (info[1]["duration"] / 10).round * 10
a = build_screenshot_images(flv, nf, num)
list = Magick::ImageList.new(*a)
list.delay = 30
filename = "#{File.dirname(nf)}/#{File.basename(nf, File.extname(nf))}.gif"
list.write(filename)
a.each {|a| FileUtils.rm a.to_s }
filename
end
The only thing here that should be a little fuzzy is the method build_screenshot_images. I’ll get to that.
For the time being, you can just assume that it creates the frames and returns a list of the frames of the movie.
After that, I am calculating the number of frames in the movie that we should pull for the movie and setting that as the number of frames. Then, after creating the files in the build_screenshot_images method, we create a new imagelist and put all those files into the list.
Then, we set a delay on it and write it all back to one image. Of course, there is some cleanup involved and that’s removing all the old frames in that directory so we have a clean directory with the thumbs and the movie itself.
Pretty easy, right?
Following is the build_screenshot images method I kept talking about above:
def build_screenshot_images(flv, nf, num=3)
a = []; b = []
info = get_movie_information(flv)
(num <= 10) ? (num-1).times {|p| b << p.to_i % 10} : num.times {|t| b << t*(info[1]["duration"]/(num-1)).floor}
num.times do |i|
filename = "#{File.dirname(nf)}/#{File.basename(nf, File.extname(nf))}#{i}#{File.extname(nf)}"
system "ffmpeg -i #{flv} -an -ss #{b[i].nil? ? 0 : b[i]}.#{(((rand * 10) / 10)*100).round}00 -an -r 1 -vframes 1 -f image2 #{filename}"
a << filename
end
a
end
Have fun and looking forward to the upcoming plugin release.
Oh, and if you have any questions or problems, lemme know. I’m always around to help
April 15th, 2007 — life, events, media
pow wowTonight.
The gymcats are done with their season. By 0.05 of a point spread behind OSU. Give it up for OSU, they did a damn good job, but so did the Gymcats. And furthermore, the gymcats were the highest scoring team in the nation that did not make it to the finals. How does that work out?
Gymnastics works like this. The top two teams from each regional goes to the finals. Also, the top two individual scorers go to the finals too. So, four of the gymcats are going to the finals, but the team is not. How is that fair at all? It is not the best teams that go, it’s the top teams in each region.
Sigh.
In other news, I got a sweeeet shot at this pow wow! Check it out!
April 13th, 2007 — Uncategorized, journalism, media
When I speak up…
and I am there, I get yelled at for causing a disruption and told I can’t “speak” unless I am not
when I am not, I get told I am complaining and that I should only “talk” when I am there.
So much for transparency
April 13th, 2007 — Uncategorized, journalism, media
Hm. So, today’s paper (I’m just looking online) is actually not nearly as hideous as yesterday’s. I am only looking at the front page, so it’s just front page stuff today.
1) The teaser, finally something comes of it. Move the fu*king page numbers up away from the line, push them down a font size and for the LOVE of god stop capitalizing EVERYTHING. But other than that, they look pretty good.
The photo provides a nice feel to the page. Without it, it would be pretty shitty. I would have shot from another angle, but that’s a personal thing. It looks good to me.
There are no headlinees that stick out to me today. It seems like there are two big stories here that could have used larger treatment. The lead story and the NPR story are both interesting to the reader and I’m left just kinda wandering around the page. Sad.
The blue in the Wet And Wild box is a bit much. The photo itself stands alone, why clutter it up?
Other than the things mentioned and a few things I left out ’cause they are tiny, today’s front page design is not too bad. I’m still disgusted at the teasers, but they are getting better than the first several concepts.
- antagonist
April 12th, 2007 — journalism, media

The Antagonist
In an attempt to use my knowledge as constructive criticism, I am just going to review today’s Arizona Daily Wildcat
design
The first thing I see today is the gross teaser. There is nothing there to draw my eye. I can’t even read the life from Wild life (a signature of Wildlife) because of the black teaser. If you are going to do a teaser this dark, why not modify the Wildlife icon slightly. Give it a white stroke, or hell, change the colors. Or, if you are really daring, cut the teaser a little short so the Wildlife logo will stick out. Also, I am not fond of the font on the teaser. Try something more simple, I think the complexity of the font really makes it difficult to actually read the content.
Also, the Arizona Daily Wildcat header bleeds over on top of it. It looks like a mistake, might not be though.
3 Things
The color behind 3 things looks good today. I’m also glad that you put quotes around “Blood Diamond,” that’s easy to forget.
Okay, I’ll be the first to say it if no one else has, the pull-quotes we have used for our “style” this semester are gross. It looks like a font you’d use in a newsletter and or at the gymboree. So have the pink ones, those are even worse.
Wild-life
Cool looking color. What ever happened to the ‘cat using full-color on _Wild_life?
I won’t go further into detail than that for now
Sports
Please, lose the consistent cutouts, If you are going to have more than one photo, at least make the cutout smaller, or… choose on that is in focus.
Fun feature with Taryne.
Lose the red in sports
Photo
The front photo is way too dark to be a draw. And you were taking a photo of a fair, right? All I see is some dude at a control panel. I had to read the subhead to understand what was going on. This is the front page, remember that’s real estate that could be going to an ad, and an expensive one at that. Get a ride, someone trying to operate it. Something with color, the sky people smiling, someone setting up a booth. This says to me nerd at a control panel that’s really dark.
That’s not even close to the story at all, unless I’m reading the wrong story. On the front page!?!?
Did I mention he has red/brown skin?
That’s all I have time for now, I’ll try to read more in the paper when get more time.
Ideas are there. Use ‘em or lose em