------------------------------------------------------------------------------- Video Handling, including DVD ripping ------------------------------------------------------------------------------- Video Codecs Here is my complete video codec installation commands From DangerMouse - Home of AutoTen http://dnmouse.org/forum/viewtopic.php?f=3&t=12 # Repos rpm -ivh http://rpm.livna.org/livna-release.rpm rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm # Packages yum -y install xine-ui gstreamer-plugins-bad-extras \ gstreamer-ffmpeg gstreamer-plugins-ugly gstreamer-plugins-bad yum -y install totem totem-mozplugin totem-nautilus totem-pl-parser \ totem-xine mozplugger gecko-mediaplayer xmms xmms-faad2 \ libmad libid3tag libdvdread libdvdnav libquicktime vlc \ ffmpeg wget libdvdcss yum -y install xine-lib-extras-freeworld xmms-mp3 # Extra Codecs wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20100303.tar.bz2 tar -jxvf all-20100303.tar.bz2 mkdir -p /usr/local/lib/codecs cp all-20100303/* /usr/local/lib/codecs ln -sf /usr/local/lib/codecs /usr/lib/codecs && ln -sf /usr/local/lib/codecs /usr/local/lib/win32 && ln -sf /usr/local/lib/codecs /usr/lib/win32 rm -f all-20100303.tar.bz2 rm -rf all-20100303 ------------------------------------------------------------------------------- DVD to VOB (decrypted) vobcopy decrypt and copy all the "vob's" into a single decrypted version. Suggestion: vobcopy -f -F 64 -l -t title Title info: vobcopy -I The -m mirror option will generate a decrypted copy of all the files on the DVD. dvdbackup An older cousin of vobcopy wine DVDDecryptor (only works with physical disks) DVD/MKV file Conversion Handbreak Scan DVD for title... HandBrakeCLI -i /media/VIDEO_DVD -t 0 Rip Movies Simply (longest title -L) HandBrakeCLI -i /media/VIDEO_DVD -L \ -2 -S 700 -o "Title.avi" Rip Movies (xvid) HandBrakeCLI -i /media/VIDEO_DVD -L \ -2 -e xvid -E ac3 -m -X 720 -S 700 -o "Title.avi" Rip Movies (divx) HandBrakeCLI -i /media/VIDEO_DVD -L \ -2 -e ffmpeg -E ac3 -m -X 720 -S 700 -o "Title.avi" Rip TV Epsiode (xvid) HandBrakeCLI -i /media/VIDEO_DVD -t ## \ --deinterlace="slower" --denoise="weak" --detelecine \ -e xvid -E ac3 -X 720 -m -S 350 -o "Title.avi" #Higher quality (longer to create - does not play on Dad's DVD) # HandBrakeCLI -i /media/VIDEO_DVD -L \ # -2 -e x264 -T -E ac3 -m -d -9 -7 0:1 -S 700 -o "Title.avi" Do a whole disk of TV epsiodes... s=1; d=4; e=12; S=175; # season, disc, epsiode size f=1; l=5; # first/last tiles on this disk image="Earl DVD Images/MY NAME IS EARL S$s DISC $d"; ls "$image/VIDEO_TS/" for i in `seq $f $l`; do j=$(( $i - $f + $e )); echo "====== Season $s Disk $d Title $i Episode $j ======"; HandBrakeCLI -i "$image/VIDEO_TS/VTS_01_$i.VOB" \ --deinterlace=slower --denoise=weak --detelecine \ -e ffmpeg -E lame -m -X 720 -S $S -o earl_s0${s}e0$j.avi; done Do TV epsiode files... for i in *.mkv; do echo "====== $i ======"; j=`expr "$i" : '\(.*\)\.[^.]*$'` HandBrakeCLI -i "$i" \ --deinterlace=slower --denoise=weak --detelecine \ -e ffmpeg -E lame -m -X 720 -m -o "$j.avi" done Two pass makes only a slight difference, though it takes twice as long. output format -f (avi, mp4, ogm, mkv) Video Codec -e x264 -T for small size quality (DVD players do not play) -e ffmpeg old, and default (as per normal DVD format) Magic Source (-x options) -x keyint=300:keyint-min=30:bframes=6:ref=3:mixed-refs=1:subq=5:me=umh: no-fast-pskip=1:trellis=0:no-dct-decimate=1:vbv-maxrate=4900: vbv-bufsize=3000 Audio codec (-E) ac3 passthru aac+ac3 ?? lame Bitrates (rough guide) 1400-1500: Lots of fast special effects, camera movement etc 1000-1200: Should be fine with most movies 700-800: Bad source DVD movie 650: B/W Movie 400: VCD 300: Bad Source VCD Movie chapter marks -m Recommend for movies 90 minutes long 700 MB, for longer ones (up to 3 hours) 1400 MB The longer films should be split on chapter boundarys into two files. And you can remove the last one or two chapters to junk credits. -c 1-N Sugessted that instead of deinterlacing (-d) use --detelecine which compares sections and merges the to re-create original frames (much better than deinterlacing). This only works if needed. You can enable BOTH, and only what needs it uses it. DVD to DVD DVDShrink (for linux?) K9Copy & dvd95 shrink entire dual-layer DVD to single layer DVD ------------------------------------------------------------------------------- FFMpeg simple conversion ffmpeg -i input.mp4 output.avi if you get a "timebase not supported" add -r 24 or -b 1200 ffmpeg -i input.mp4 -r 24 output.avi to see what codecs type ffmpeg -codec EG: ffmpeg -codec | grey EV or ffmpeg -codec | grey EA NOTE input settings are separate to output settings ffmpeg -ss 10:00 -t 25 -i INPUT.mp4 \ -r 24 -b 1200kb -vcodec msmpeg4v2 \ -ab 128kb -acodec libfaac \ OUTPUT.avi For high quality mpeg-1/mpeg-2 add -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2 also try things like -bf 2 -flags qprd -flags mv0 -flags skiprd Problem... encoding 6 channel(s) is not allowed in mp2 ffmpeg -i temp_audio.ogg -i temp_video.avi \ -f avi -vcodec mpeg4 -b 950k -g 300 -bf 2 \ -acodec mp2 -ab 64k -vtag divx \ OUTPUT.avi ------------------------------------------------------------------------------- Mencoder for Video to Video format conversions For quick sample to make sure it is right... (especially useful for -vf cropdetect ) just 25 seconds -ss 5:00 -endpos 25 or to a specific mark (junk sections) -ss 5:00 -endpos 8:00 Example Output PNG frames of a segment of video mencoder 631.avi -vo png -ss 12 -endpos 8 For Crop detect use mencoder -ss 0:30 -endpos 25 -vf cropdetect \ -oac mp3lame -lameopts fast:preset=standard \ -ovc lavc -lavcopts vcodec=mpeg4 \ -o /dev/null dvd://1 You sould see something like.. -vf crop=1216:544:62:88 Scaling... if movie widescreen (16:9 ratio) or fullscreen (4:3) Theater 2.39 720:301 1280:535 ? ? 720:306 1280:544 Theater 1.85 720:389 1280:692 HDTV (16:9) 1.79 720:405 1280:720 TV (4:3) 1.33 720:540 1280:920 640:480 Example, croping and scaling a raw vob DVD file... that had obviously been previously cropped -vf crop=crop=1216:544:62:88,scale=720:-2 See http://quadpoint.org/projects/simplerip#audio_and_video_bitrates for a determination of bitrate to use to get a specific size. Basic mencoder -oac mp3lame -lameopts fast:preset=standard \ -ovc xvid -xvidencopts fixed_quant=4 -vf pp=lb \ -vf crop=1216:544:62:88 -of avi \ -o OUT.avi IN.mp4 From FLV convertion guide (flash video to AVI) DivX format -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1200 \ or -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200:vhq \ -ffourcc DX50 -vf pp=lb \ DivX multippass... for i in 1 2; do mencoder \ -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200:vhq:vpass=$i \ -ffourcc DX50 -vf pp=lb \ ... done XVid format (prefered) -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc xvid -xvidencopts bitrate=800:autoaspect -vf pp=lb \ or -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc xvid -xvidencopts fixed_quant=4 -vf pp=lb RMVB to AVI Make sure you can play the RVMB with mplayer. That ensures you have the codecs needed. Suggestion (fixed bitrate)... mencoder -oac mp3lame -lameopts fast:br=128 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1200 \ -ofps 25 -of avi -o out.avi in.rmvb Suggestion (for Xvid prefered) mencoder -oac mp3lame -lameopts fast:preset=standard \ -ovc xvid -xvidencopts fixed_quant=4 -vf pp=lb -of avi \ -o movie.avi movie.rmvb Alternative (faster) Adjust lame-audio and video-bitrate according to http://quadpoint.org/projects/simplerip#audio_and_video_bitrates mencoder -oac mp3lame -lameopts br=128 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq -ffourcc XVID \ -of avi -o movie.avi movie.rmvb MKV to AVI Use the latest 'snapshot' of HandBrakeCLI, as above (may fail). OR directly using... for i in *.mkv; do \ echo "============ $i ==============" j=`expr "$i" : '\(.*\)\.[^.]*$'` [ -f "$j.avi" ] && continue; mencoder -oac mp3lame -lameopts aq=2:vbr=4 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq -ffourcc XVID \ -vf scale=720:-3 -ofps 24 -of avi -o "$j.avi" "$i" done Older for i in *.mkv; do \ echo "============ $i ==============" j=`expr "$i" : '\(.*\)\.[^.]*$'` [ -f "$j.avi" ] && continue; mencoder -oac mp3lame -lameopts br=128 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=900:vhq -ffourcc XVID \ -ofps 25 -of avi -o "$j.avi" "$i" done OLD METHOD -- stuffs up badly mencoder -oac mp3lame -lameopts br=128 \ -ovc xvid -xvidencopts bitrate=900:autoaspect -vf pp=lb \ -ofps 25 -of avi -vf scale=720:-2 -o "$i.avi" "$i" Extract the uncompressed audio stream to audio.wav. mplayer input.mkv -ao pcm:fast:file=audio.wav -vc null -vo null Encode AVI using mencoder as usual plus -audiofile audio.wav. mencoder input.mkv \ -ffourcc divx \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=400 \ -audiofile audio.wav \ -oac mp3lame -lameopts vbr=3 \ -o output.avi Remove the intermediate file audio.wav. rm -f audio.wav VOB to AVI cat *.vob | mencoder -oac mp3lame -lameopts br=128 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq \ -vf pp=lb,crop=720:432:0:72,scale=704:304 \ -o output.avi - From http://www.brad-x.com/2007/05/19/yet-another-linuxnix-video-h264-howto for high-quality MP4 file with 6 channel surround audio and video stored in anamorphic widescreen. Detailed guide -- to look at http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-dvd-mpeg4.html http://gentoo-wiki.com/HOWTO_Backup_a_DVD http://gentoo-wiki.com/HOWTO_Create_a_DVD:Encode ------------------------------------------------------------------------------- Concatenating AVI's From http://www.arsgeek.com/2006/08/07/how-to-join-multiple-avi-or-mpg-files/ First simply 'cat' the avi's together... cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi > b_all.avi However this may cause a time sync breakdown. So it needs to be recoded mencoder -forceidx -oac copy -ovc copy b_all.avi -o b_final.avi Or do it all together mencoder -oac copy -ovc copy b?.avi -o b_final.avi For MPEG's you need to include the output format... mencoder -oac copy -ovc copy -of mpeg parts_?.mpg -o all.mpg The "avimerge" program from "transcode" package is specifically designed for this. avimerge -i b? -o b_final.avi Another suggestion is "Jfuse" from http://www.jfuse.com which joins all types of media files. -------------------------------------------------------------------------------