Friday, 23 October 2009

I use the rather tempremental cinelerra-cv for my video editing.
cinelerra-cv has problems with many video containers, but apparently less so with mov.

I also wanted to de interlace and scale the video for youTube.
The following command takes a video and does the above:

mencoder -ovc lavc -oac lavc -of lavf -lavcopts vcodec=mpeg4:vrc_buf_size=1835:vrc_maxrate=10000:vbitrate=8000:vqmin=1:keyint=25:aspect=16/9:abitrate=224:acodec=mp2:vstrict=0:dc=10:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp -lavfopts format=mov -vf yadif,hqdn3d,harddup,scale=1280:720 -ofps 25 -o output.mov input.mpg


I got most of the command from:
http://www.coswellproductions.com/wordpress/2007/05/16/more-cinelerra-and-mencoder-fun/

Tuesday, 8 September 2009

Replace Spaces in Filenames

As noted in the previous post spaces in file names break many scripts so here is a quick script to replace all spaces in file names with an _
#!/bin/bash
find | while read FN;do mv "$FN" "`echo $FN | sed -e 's/ /_/g'`";done

Audio Conversion with ffmpeg

I was looking to convert a set of arbitrary audio files to mp3 so I could play them on my mp3 player. My first thought was mencoder but unfortunately I could find no way to encode from an audio stream without a container, mplayer kept saying video was required.

After some searching ffmpeg was suggested:

ffmpeg -i name_file.aac -vn -acodec libmp3lame name_file.mp3
ffmpeg -i name_file.aac -vn -acodec libmp3lame -aq 6 name_file.mp3
ffmpeg -i name_file.aac -vn -acodec libmp3lame -ar 44100 -ac 2 -ab 128000 name_file.mp3

This results in the following script to convert all files in the current directory with the given extension to mp3:
#!/bin/bash
for i in *.$1; do ffmpeg -i $i -vn -acodec libmp3lame $i.mp3 done;
Note that the file names cannot contain spaces or the script will break.