Split, cut, or sample a video file on the command line

There are many reasons to cut or split a video file. For example, one may want to cut a long video into multiple parts to upload to YouTube. I first ran into this and this, which suggests:

 <pre class="src src-sh">ffmpeg -ss 00:00:00 -t 00:01:00 -vcodec copy -acodec copy -i in.avi out.avi

## -ss: start position ## -t: end position ## can re-encode with other codecs

However, for some reason my out file is almost as large as my in file, even though I’m only sampling 1 minute out of the 2 hour segment. This lead me to the mencoder solution:

 <pre class="src src-sh">mencoder -ss 00:00:00 -endpos 00:00:01 -ovc copy -oac copy in.avi -o out.avi

The file size of my out file is more reasonable, and the speed is incredibly fast since I am not re-encoding.

Creative Commons: Share, Remix, Reuse – Legally

I recently wrote about the GNU Public License (GPL). All of my software that I write on my own will most likely be licensed by GPL so others can use and modify it freely. I really think this benefits society.

What about content, such as text, image, audio, or video? Analogous to the GPL, there are the Creative Commons (CC) licenses. CC is plural in that there are many licenses available, depending on how the author wants to share his or her work. The core right is to be able to redistribute a work for non-commercial purposes without modification. I believe the most popular variant is the Attribution-NonCommercial-ShareAlike 3.0 Unported, of which my Super Nerdy Cool blog is licensed with. I should remember to always post communicate the license of all my work (such as presentations, lecture notes, etc.). Examples of how to attribute can be found here

Now, onto some resources.

  1. Images: the noun project compfight (searching Flickr) and Cadyou.
  2. Audio: FreeSound, Free Music Archive, and opsound.
  3. Video: Blip TV.

Create a video slideshow from images automatically

On a Mac, creating a video slideshow with some pictures is easy with iPhoto and iMovie. I haven’t found similar programs on the Linux side (yet). I mean, there are many photo manager apps such as F-Spot and Shotwell that can create a quick slideshow from the selected pictures, but they don’t export the slideshow into a video format that can be played anywhere (platform-indepedent). Also, they don’t have nice transitions between pictures. digiKam supposedly supports these features, but I think they’ve been taken out.

I found dvd-slideshow that lets me create a video slideshow with transitions from the command line. On ubuntu, install by

 <pre class="src src-sh">sudo apt-get install dvd-slideshow

Suppose I copy all the pictures I want in a directory. Run the following commands to create a vob (dvd) file:

 <pre class="src src-sh">dir2slideshow -t 5 -c 1 -n <span style="color: #ffa07a;">"Title"</span> -r /path/to/pics/ <span style="color: #ff4500;">## </span><span style="color: #ff4500;">title should be ascii only ## generate some files (txt file contains instructions)</span>

dvd-slideshow -n Name.Of.VOB.file -a /path/to/mp3/song Title.txt ## select name of out file, add audio to be played, and point to txt file with instructions ## for multiple audio files, add multiple -a /path/to/song; songs do not repeat, so add multiple -a if you want songs to repeat

## let’s convert to avi: mencoder out.vob -ofps 30 -ovc xvid -oac mp3lame -lameopts abr:br=128 -srate 48000 -vf scale -zoom -xy 720 -xvidencopts fixed_quant=4 -o out.avi

UPDATE 12/24/2010: dvd-slideshow-editor

My example above is very basic. You can actually modify the generated text file to modify the way the picture is presented (cropping and ken burn effects). You can also create a dvd-menu for your dvd. See this post for one person’s overview. See the wiki for a more complete overview.

Note that there are many GUI frontends to dvd-slideshow, the simplest of which is probably dvd-slideshow-editor. To install on Ubuntu,

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n
## now download the python script of dvd-slideshow-editor.

I can imagine using this program to add ken burn effects to my slideshow.

WordPress: post via email using Postie

WordPress’s default “post by email” setting is pretty weak, mainly because it doesn’t handle attachments (think posterous, among other things. Postie is quite powerful as it can handle different attachments and can handle my LaTeX and source code content. Note to self: use the development version!

Setting up is quite easy – you only need to install php5-imap to use imap with ssl. If the postie filters is activated, deactivate it or remove the two examples in there. This should remove the “(post via postie)” message in the subject line and “Bookmark this category” line in the gets appended to the beginning of the post.

Images

In the “Image” section in Postie’s settings, set the Image Template to custom and set the template to blank. This way, if I want a gallery (wordpress feature since v2.5), I can add in this line in the post/email

[ gallery link="files" ]
## without the spaces in beginning and end, or use NextGen gallery
[ imagebrowser id=x ]
## need to know id of post

See this site for an overview. I can also use the NextGen gallery. When I have time, I want to hack postie so that the line gets appended by default if there are image attachments.

Embedding other sites’ video and audio

Install WordPress Video Plugin. See this site for the syntax.

Audio and Video attachments

Add “mpeg” in the audio list as mp3 files have that description. Install audio player and use the audio template

## audio
LeftSquareBracket audio:{FILELINK} RightSquareBracket
## video: simple_link
[[%7BFILELINK%7D][{FILENAME}]]

Audio player will play mp3 files. Video doesn’t really play, but I don’t plan to host any videos.

I will use posterous (my other blog) for more multimedia intensive blogging (since this is more of a technical blog).

Note: other attachments get attached as files!

Check email

Set up crontab -e:

*/10 * * * * /usr/bin/wget -O /dev/null http://my.server.com/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1

for checking every 10 minutes.

Posting options

See this site for other options, such as categories, tags, delay, etc.

I will write a template email and use emacs to email and post. Weblogger is a little weak in that doesn’t handle attachments and does not support tagging and categories (as of now).

Issues

  1. LaTeX: Need to use double backslashes to get things correctly.
  2. What else? Good enough for now.

vcasmo: video/presentation + picture/slides together!

I was reading this blog post on Revolutions Computing’s blog and discovered the vcasmo service, a way to post a presentation or video with the slides right next to it. This is DEFINITELY something I will use. Often times I watch talks or presentation videos online and most of the time the videos are either focused on the speaker and the projected slides or on the presentation slides with voice-over from the speaker. This method of presentation highlights both the presentation slides and what the speaker has to say, making me feel that I didn’t miss much from not being at the talk physically. Here is the embedded talk that made me discover vcasmo:

youtube alternative: vimeo and blip.tv

a few months back, i uploaded a slideshow onto youtube. got an email from them that there is copyrighted material (the songs). then, youtube stripped the audio. this is rediculous. i googled for other alternatives and found a site that compared different services. vimeo and blip.tv seemed to be the best. i uploaded my video to vimeo and it’s still great. i chose vimeo because i’ve seen other bloggers (emacs, linux, etc) use vimeo. i usually agree with whatever this crowd uses.

note: i didn’t go for hulu or dailymotion or veoh because they offer ads and quality aint so great. i wanted something comparable to youtube.