Wednesday, February 27, 2013

OLPC Video Editor: Research on ogg file splicing

Had some late night energy after this busy day of work (maybe it was those 2 cups of green tea and tasty California orange?!)... so I spent some time researching what technology I should be using to edit my ogg (theora) video files in the OLPC XO activity I am going to write.

First off, I think I've decided to write my own, new video editing activity for the OLPC instead of modifying the existing "Camera" app. It's very cool, and I had some thoughts about how to integrate my editing code into there... but I think it could cramp the UI and also it might just be easier to have my own codebase for this. Then I can make this application do just one major task: allow kids to view and seek to a start and end point in any of the video clips in their Journal, and then mark those start and end points into some sort of timeline. And from there, run some sort of command-line (or Python-accessible) splicing library that will edit these clips together, and save them out as a new .ogg file.

I've found a couple of possible options. You might wonder why I am not just porting Pitivi (Gnome editor, based on GStreamer) to the OLPC XO laptop. I took a look into it and it's really cool... but it's probably not the best fit for the XO laptop. Yes, it's a great tool and it definitely edits cleanly and like a standard non-linear editing program that anyone has used (eg iMovie, Windows Movie Maker)... but it's not specifically made with 6 year olds in mind. Certainly not with 6 year olds in mind from countries that have never seen iMovie (or even a computer before this). It's also got stuff like an "Import Clips" and "Save Movie" button which is find for a normal operating system with a regular file system, but doesn't really line up well with the XO's "Journal" directory concept. That needs to be well-integrated, or the learning curve will be too steep and I don't think it's going to get as much use as it could get.

Given what my friend Jen said about OLPC's most popular apps, simplicity in UI design is king... and paramount to whether or not your Activity is a success or a failure. If it's too complicated, if there is too much text on screen... then (most) kids will get frustrated and not use it... in my opinion. I want a lot of kids to use my application, so I need to be particularly focused on simplicity in UI design.

All that said about UI design and the necessity to keep it simple, and keep it obvious... I still need to figure out what algorithm/library/API to use to actually decode, splice, and re-encode the ogg (theora) video files. It needs to be fast, not take up too much memory, and ideally I'd like to just give it a list of in and out points (specified by the UI) and the corresponding ogg filename. Those files will then be spliced in order (I will have to allow users to re-order the clips somehow). So focusing on the actual editing part first (since I am gonna have to get that working before I even think about the UI)... I found some useful details.

GStreamer (already available on XOs) has a plugin called Gnonlin (As in G-NonLinear Editor)... YES. This is excellent news, and in fact it's what Pitivi uses under-the-hood. That said, the code looks kinda complicated. In fact all the GStreamer code seems kinda complicated. I am gonna have to read some more, and hopefully there are some useful tutorials online or good documentation of the library and how to interface with it. In any case, this looks super powerful and useful.

Some Gnonlin links:
Some other alternatives that I need to read about more, as they might be simpler if they can do what I want:
Yet another (possibly awesome) alternative is to convert the ogg files to mpeg (I think that's necessary for this) and then splice and concatenate using ffmpeg. Now this looks pretty darn easy from a programmatic side. I don't suspect they have Python access, but I can always just subprocess the conversion from the GTK app and subprocess.Popen() will make the UI wait for the subprocess to finish, which is exactly what I want. I'm not sure if XO machines already include ffmpeg or if I'd have to somehow bundle it along with my activity if I went this route. Or maybe use something like PyFFMpeg.

1 comment:

Jennifer Martino said...

Not entirely sure what this says. .. other than the most important point - the international olpc community is getting a video editing activity! !! So very useful and important!!!! Nunavut will be thrilled :)