{"id":41,"date":"2006-12-01T20:07:43","date_gmt":"2006-12-01T19:07:43","guid":{"rendered":"http:\/\/stuphi.co.uk\/wordpress\/?page_id=41"},"modified":"2009-03-26T12:47:23","modified_gmt":"2009-03-26T11:47:23","slug":"video-encoding-recipies","status":"publish","type":"page","link":"https:\/\/stuphi.co.uk\/wordpress\/?page_id=41","title":{"rendered":"Video Encoding Recipies"},"content":{"rendered":"<p>On this page I will try and pull together a number of recipies for encoding video into different formats.<\/p>\n<h2>3GP for Mobile Phones<\/h2>\n<p>This method requires three steps. Now assume we have a file called <code>movie.mpeg<\/code> and we want to convert it to <code>movie.3GP<\/code>. The steps required would be<\/p>\n<p><code>mencoder movie.mpeg -nosound -ovc lavc \\<br \/>\n-lavcopts vcodec=mpeg4 \\<br \/>\n-vop expand=176:144,scale=176:-2 \\<br \/>\n-o movie.avi -ofps 12<\/code><\/p>\n<p>This will extract the video, scale it and reduce the frame rate. Now we need to extract the sound.<\/p>\n<p><code>mplayer -vo null -ao pcm -af \\<br \/>\nresample=8000,volume=+4db:sc movie.mpeg<\/code><\/p>\n<p>An output file called <code>audiodump.wav<\/code> will be created that has the audio that we require. Finally we need to combine these two files together.<\/p>\n<p><code>ffmpeg -i movie.avi -i audiodump.wav \\<br \/>\n-b 48 -ac 1 -ab 12 -map 0.0 -map 1.0 movie.3GP<\/code><\/p>\n<p>I have been told that this can be done in one command as follows<\/p>\n<p><code>ffmpeg -i movie.mpeg -vcodec mpeg4 -r 15 -b 128k -s qcif \\<br \/>\n-acodec amr_nb -ar 8000 -ac 1 -ab 13 -f 3gp -y output.3gp <\/code><\/p>\n<h2>AVI File for inport to Kino<\/h2>\n<p><code>mencoder -oac mp3lame -ovc xvid -of avi -xvidencopts bitrate=1350 \\<br \/>\n-o output.avi input.flv<\/code><\/p>\n<h2>MP4 for iPod Video<\/h2>\n<p>For this to work, faac and xvid need to be configured in ffmpeg.<br \/>\nFor a 4:3 video, use:<\/p>\n<p><code>ffmpeg -i foo.avi -f mov -b 1800 -maxrate 2500 \\<br \/>\n       -vcodec xvid -qmin 3 -qmax 5 -s 320x240 \\<br \/>\n       -acodec aac -ab 128 \\<br \/>\n       foo.ipod.mov<\/code><\/p>\n<p>For 16:9 video, use:<\/p>\n<p><code>ffmpeg -i foo.avi -f mov -b 1800 -maxrate 2500 \\<br \/>\n       -vcodec xvid -qmin 3 -qmax 5 \\<br \/>\n       -s 320x180 -padtop 30 -padbottom 30 \\<br \/>\n       -acodec aac -ab 128 \\<br \/>\n       foo.ipod.mov<\/code><\/p>\n<h2>Rotate video<\/h2>\n<p>This one comes from the Hampshire Linux User Group mailing list. This is used to rotate a video by 90 degrees.<\/p>\n<p><code>mencoder -oac copy -ovc lavc -lavcopts \\<br \/>\n      vcodec=mjpeg -vop rotate=1 00250.avi -o 00250_rot.avi<\/code><\/p>\n<h2>Join some AVI files together<\/h2>\n<p><code>mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...<\/code><\/p>\n<h2>Create a DVD from a bunch of avi&#8217;s<\/h2>\n<p><code>movie-to-dvd -r 720x576 -d letterbox -f auto -a 16:9 \\<br \/>\n      -A 16:9 -q low -Q auto -o DVD -O \"-aid 0\" -M *.avi<\/code><\/p>\n<p>That will create a bunch of VOB&#8217;s in a sudirectory called DVD. However, I am currently having a few problems with this on damaged mpeg files where the audio goes out of sync with the video. I am currently playing with ffmpeg to see if I can come up with a set of options to replace this command, and fix the audio. The following has worked best so far.<\/p>\n<p><code>ffmpeg -i input.mpg -target pal-dvd -b 3000000 -aspect 16:9 \\<br \/>\n-vcodec mpeg2video -acodec copy -map 0:0 -map 0:2 -vsync 0 -y output.vob<\/code><\/p>\n<p><code>cd DVD && movie-make-title-simple -o title -m pal -n none<\/code><\/p>\n<p>That will do some stuff to create the title<\/p>\n<p><code>movie-title -o title.vob -t title prog1.vob prog2.vob prog3.vob<\/code><\/p>\n<p>Actually create the title VOB and prepare the xml file for dvdauthor.<\/p>\n<p><code>dvdauthor -o disk1 -x title.vob-dvdauthor.xml<\/code><\/p>\n<p>That will bunch the whole lot up ready to burn to a disk.<\/p>\n<p><code>growisofs -speed 1 -dvd-compat -Z \/dev\/scd0 -dvd-video disk1\/<\/code><\/p>\n<p>Burn baby, burn!<\/p>\n<p>This process still needs some tweaking as the menus are not working properly yet. I expected that I would have a still picture for each button, but all I have is blank squares with a play button above. <\/p>\n<h2>And some more<\/h2>\n<p>The above are recipies that I have actually used, and recorded here for future reference. Here is a link to some more that may be usefull, but I have not actually tried myself.<\/p>\n<p><a href=\"http:\/\/streaming411.com\/wiki\/index.php?title=Encoding_prerecorded_video\">http:\/\/streaming411.com\/wiki\/index.php?title=Encoding_prerecorded_video<\/a><\/p>\n<h2>Archiving MythTV Recordings<\/h2>\n<p>I have decided to have a go at archiving some of my MythTV recordings. This has proven to be a little more problematical than first expected, as the OOTB solutions just did not quite do the job.<\/p>\n<p>First use the edit function in MythTV and set up the cut points to remove adverts etc., then log into Mysql, and select the <code>mythconverg<\/code> database. Then run the following query:<\/p>\n<p><code>select chanid,starttime,title from recorded;<\/code><\/p>\n<p>This will list all the recorded programs, and the other information that is needed for the next step. Now run <code>mythtranscode<\/code> as follows:<\/p>\n<p><code>mythtranscode --chanid 1519 --starttime 2007-11-08-18-55-00 \\<br \/>\n--mpeg2 --honorcutlist -o A\\ really\\ cool\\ film.mpg<\/code><\/p>\n<p>Note that the start time required by mythtranscode is in a slightly different format to that stored in the Mysql database.<\/p>\n<p>Once I have done this, I then use the recipe mentioned further up the page to record this file as a DVD.<\/p>\n<p><a href=\"http:\/\/wiki.flexion.org\/DVBRipping.html\">Another way<\/a><br \/>\n<a href=\"http:\/\/ffmpeg.mplayerhq.hu\/compat.html\">Windows Media Player compatible files<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>On this page I will try and pull together a number of recipies for encoding video into different formats. 3GP for Mobile Phones This method requires three steps. Now assume we have a file called movie.mpeg and we want to &hellip; <a href=\"https:\/\/stuphi.co.uk\/wordpress\/?page_id=41\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/41"}],"collection":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":4,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/41\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/41\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}