Previously on my blog: In my TiVo2Podcast stuff I automated the process of putting chapters around commercials, but had to call out to a small C++ app I wrote to put the chapters in using libmp4v2.
A few weeks ago I was looking at some ruby gems for a project I was working on and stumbled across ffi, a foreign function interface gem for ruby, or as its docs put it: “a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code.” As long as you know the function signatures that you need, its pretty trivial to make the calls from Ruby. You do need to be aware of memory management stuff sometimes, but overall its pretty easy, especially for basic use. If you’re only going to be working in Ruby and need access to a C library, this is much easier than mucking with swig, that’s for sure.
The mind-blowing part for me is that the authors of the gem have made it smart enough to know what flavor of ruby vm and platform the code is running in and it does the right thing, no matter if its JRuby or on Windows or whatever. While I haven’t had a chance to use it yet, I suspect this property will be useful with JRuby at work in the future.
Continue reading FFI for Ruby and an mp4v2 example
It’s been a long time since I’ve put a new version of TiVo2Podcast out there for people to play with. I’ve made a lot of changes and tightened things up alot. There’s still a lot of things I want to do but haven’t gotten to, but I did finally put up a public git repository in case others wanted to join in the fun.
The major changes in this release:
- Commercials are detected and chapters are added around them.
- Added “clean up” functionality so that you can deleted unneeded files and the database and rss feeds can reflect that.
- Increased the wait time for locating the tivo from 2 seconds to 5.
- Fixed problem created by quotes in the show description.
- Attempt to avoid re-encoding dupes by checking the program id.
- Lost of behind the scenes refactoring.
The first item I consider a major enhancement, so I put it in italics. To make that work, you’ll need to get wine, comskip, and build a helper app. The documentation is in the hastily wrote README. (A reminder, this is intended for PERSONAL USE ONLY, do not set up podcast feeds and violate the ethics (and also the laws) of copyright left and right.)
As always, this has run daily for months and months on linux. It should work on other UNIXes just fine. On Windows, I have no idea.