-
Importing, Uploading, Thumbnailing
Posted on June 15th, 2009 No commentsLast week was a busy week for me on the programming end of things… sorry about the lack of a blog post!
I decided to temporarily halt work on the video “collection” concept (grouping similiar videos together isn’t as important as the videos themselves!) and focus back on the workflow for uploading a video. I’m happy to say things looks and flow much better now. Let me walk you though what happens.
- Visit the Add Video page
- Give the video a title
- Choose to Upload a file or Import a file on the server. Importing works best for really large files, where it might make sense to ftp or scp them over manually before bringing them into the software.
- I use Mediainfo to read some metadata about the video file, like duration, codecs, etc and store those back on the Video model.
- Then, I generate 3 thumbnails at the beginning, middle and end of the video. They are also stored in 2 smaller versions (like thumbnail, and preview).
- Presto! Upload complete.
The thumbnail functionality is finished, such that you can manually specific a timecode anywhere in the video to generate a new thumbnail.
I have run into a few bumps with really high quality files, the thumbnail generation takes longer than the web-browser is willing to wait so the browser times out. The process continues on in the background, but its still not the cleanest implementation.
Next on my list of things to work on is video conversion.
Oh yea, here are some screenshots of the current interface:
-
acts-as-timecode
Posted on June 3rd, 2009 No commentsIn a few places I need to store the length of a video. To keep things simple and fast, I’m using an :integer, and storing the length in seconds of the video file. This is all well and good when it comes to indexing and sorting in the database, when it comes to user interaction its really junky. No one wants to know that a video 421 seconds long is 7 minutes, and 1 second long… and I didn’t want people to have to convert 3 hours, 45 minutes, and 10 seconds into a huge integer.
At first I implemented it up quick and dirty in the edit code of controller for the portion of code that needed this conversion, however as I started to build out a few other items I realized I was going to be needing the same feature so I moved it to a plugin.
You should note, this is my first time authoring a plugin and my first time trying to make it into a gem. It works for me, so I would hope it can work for you too. Its pretty straight-forward to setup and use. Here’s my model:
class Video < ActiveRecord::Base
acts_as_timecode :column => :duration
end
Now I can use this cool new timecode field in my views and controllers. For example, in my edit.html.erb I use <%= f.text_field :timecode %>. which generates a textbox with the video duration in it, looking like 00:34:12 or however long the video is. Hitting the save button works as expected, updating the duration field in my database to the correct seconds value (2052 in this case). Because I don’t always like to type leading zeros, the timecode field can take the following formats: HH:MM:SS:FF, HH:MM:SS, MM:SS, SS. The frame implementation isn’t very useful, but it will round your frames to the nearest second value, based on the :fps configuration setting (defaulted at 30).
At some point I might expand it, but it will depend on what I need it to do.
You can check it out on GitHub: http://github.com/bamnet/acts-as-timecode/







