video tools


Published on

LUG@IITD workshop

Published in: Education
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

video tools

  1. 1. <ul><li>Linux Video Tools </li></ul>
  2. 2. Elements of a video The video container holds it all together 4 The caption format defines when captions are displayed 3 The audio codec defines how waveforms are compressed 2 The video codec defines how the pixels are compressed 1
  3. 3. Technology Overview <ul><li>Codecs & formats </li></ul><ul><ul><li>Container – Can hold multiple types of video </li></ul></ul><ul><ul><li>Format – the contents of the file (how the bits are arranged). </li></ul></ul><ul><ul><li>Codec – the encoder that created the contents of the files (arranger of bits). </li></ul></ul><ul><li>Multiple encoders can write files in the same format. (DivX, Xvid -> mpeg4) </li></ul>
  4. 4. Common video codecs (*) As far as we know Source: Wikipedia No YouTube, Google Video MPEG WG H.263 HDTV broadcast Free Software hippies Blu-Ray Microsoft world domination YouTube HD, iTunes, Blu-Ray Movie pirates DVD VCD Popular usage Yes* On2, Theora No Microsoft VC-1 Yes* BBC Dirac No Microsoft WMV No MPEG WG MPEG-2 No MPEG WG MPEG-1 No MPEG WG H.264 No MPEG WG MPEG-4 ASP Patent-free? Inventor Codec name
  5. 5. Video encoders Source:,, Wikipedia Adobe Premiere ffmpeg H.263 none none Windows Media Encoder, Compressor, Squeeze Windows Media Encoder, Expression Encoder Adobe Media Encoder, Apple Compressor, On2 Flix Pro, Sorenson Squeeze, Telestream DivX, 3ivX Compressor, Sonic, TMPGEnc QuickTime Non-OSS tools oggenc, Thusnelda Theora none VC-1 dirac-research, Schroedinger Dirac none WMV ffmpeg, mpeg2enc MPEG-2 ffmpeg, MP1E MPEG-1 x264 H.264 ffmpeg, Xvid MPEG-4 ASP OSS tools Codec name
  6. 6. Overview of caption formats Source: Wikipedia DVD Stored as images DVD-Forum DVD Analog TV (Europe) custom BBC et. al. Teletext Analog TV (US + Canada) pseudo-ASCII Electronic Industries Alliance Line 21 UTF-8 (multiple) (multiple) UTF-8 windows-1252 Encoding Windows Media Player MSDN page SAMI MP4 files, iTunes Store QuickTime (SMIL 1.0 only) AVI files, “fansubbing” AVI files, “fansubbing” Popular usage ISO 14966-17 MPEG-4 Timed Text A forum post from 2004 SubRip W3C Recommendation SMIL Some Word document floating around the net Advanced SubStation Alpha Spec Caption format
  7. 7. Overview of container formats (*) Seriously, some guys in Russia. They contributed it to the public domain, so technically you own it. Source: Wikipedia ffmpeg, MP4Box, mp4creator MPEG-LA .MP4, .M4V MPEG-4 ffmpeg Apple .MOV QuickTime ffmpeg, oggmux .OGG Ogg ffmpeg (in progress) Microsoft .ASF, .WMV Advanced Systems Format ffmpeg, AVIMux-GUI Microsoft .AVI Audio/Video Interchange ffmpeg, mkvtoolnix Some guys in Russia* .MKV Matroska ffmpeg Adobe .FLV Flash Video OSS tools Owner Extension Container Name
  8. 8. Common audio codecs (*) As far as we know Source: Wikipedia No iPod, iTunes Store videos MPEG WG AAC Blu-Ray DVD Free Software hippies Microsoft world domination Music VCD, DVD, digital TV Ringtones, VoIP Popular usage No DTS Inc. DTS No Dolby AC3 Yes* Vorbis No MPEG WG MP2 No 3GPP AMR No Microsoft WMA No MPEG WG MP3 Patent-free? Owner Codec name
  9. 9. Audio encoders Sources:, Wikipedia iTunes, Nero FAAC AAC DTS, Inc. Dolby none Windows Media Encoder iTunes Audio Transcoder, Easy CD-DA Extractor 3GPP reference encoder Non-OSS tools none DTS ffmpeg, Aften AC3 ffmpeg, aoTuV Vorbis TwoLAME MP2 ffmpeg, RetroCode AMR ffmpeg WMA LAME MP3 OSS tools Codec name
  10. 10. Encoding / Transcoding <ul><li>Reasons to Transcode </li></ul><ul><ul><li>Create a DVD compatible video stream </li></ul></ul><ul><ul><li>Compress an existing video </li></ul></ul><ul><ul><li>Reduce the size or bitrate of a video </li></ul></ul><ul><ul><li>Change the format so you can edit it. </li></ul></ul><ul><li>Transcoding is slow. It easily take ten times as long to transcode a video as to watch it. </li></ul><ul><li>Thousands of options and plugins needed. </li></ul><ul><li>Vcdgear, transcode and ffmpeg are common tools </li></ul>
  11. 11. Transcoding Example <ul><li>To convert a mpeg video into DV format for kino </li></ul><ul><li>transcode </li></ul><ul><li>-i 'funny_dog_show.mpg' </li></ul><ul><li>-y mov -F dv -Z720x480 </li></ul><ul><li>-o </li></ul>
  12. 12. Transcoding Example <ul><li>-i input-file </li></ul><ul><li>-y mov – Select the video output module. In this case the quicktime (mov) container. </li></ul><ul><li>-F dv – Select the format for use in the container. (And audio codec if applicable – only 1 codec for dv.) </li></ul><ul><li>-Z720x480 – Resize the video to the given amount (kino is fussy about this) </li></ul><ul><li>-o output-file </li></ul>
  13. 13. Transcoding Example <ul><li>Time to process a 1 hour television show: 2 hours. (AMD Athlon(tm) XP 2400+) </li></ul><ul><li>Size of input: 877M </li></ul><ul><li>Size of output: 13G </li></ul>
  14. 14. Video Editing <ul><li>Editing tasks </li></ul><ul><li>Cutting a clip out of a television show </li></ul><ul><li>Making DVD from a camcorder tape </li></ul>
  15. 15. Editors <ul><li>kino </li></ul><ul><li>lve </li></ul><ul><li>lives </li></ul><ul><li>cinerama </li></ul><ul><li>Avidemix2 </li></ul><ul><li>ffmpeg can be used for some editing as well! </li></ul>
  16. 16. Video editing -- Kino
  17. 17. Video editing -- Kino <ul><li>Works well for DV (camcorder files) </li></ul><ul><li>Very limited input support otherwise (annoying) </li></ul><ul><li>Works fast enough to not be annoying </li></ul><ul><li>Vi like keyboard controls. </li></ul><ul><li>Simple edits – No complex transitions or sound editing. </li></ul><ul><li>Good choice for home Camcorder to DVD projects </li></ul>
  18. 18. Video editing -- Lve
  19. 19. Video editing -- Lve <ul><li>Fast </li></ul><ul><li>Works well with mpeg files </li></ul><ul><li>Better input / output support </li></ul><ul><li>No documentation to speak of </li></ul><ul><li>Suggest avidmux2 instead. Does more and is documented. </li></ul>
  20. 20. Video editing -- Lives
  21. 21. Video editing -- Lives <ul><li>Appears to be full featured. </li></ul><ul><li>Very slow open speed. </li></ul><ul><li>Does not import the whole file by default. </li></ul><ul><li>Sound does work with my system. (ALSA only?) </li></ul>
  22. 22. Video editing -- cinelerra
  23. 23. Video editing -- cinelerra <ul><li>Supposed to be a professional class editing system. </li></ul><ul><li>Documentation 186 page manual </li></ul><ul><li>Never could figure it out. </li></ul>
  24. 24. Video editing -- avidemix2
  25. 25. Video editing -- avidemix2 <ul><li>Fast </li></ul><ul><li>Full set of features </li></ul><ul><li>Find black feature – Commercial Skip </li></ul><ul><li>Scripting features </li></ul>
  26. 26. ffmpeg the wonder tool
  27. 27. Flv to mpg conversion <ul><li>convert .flv to .mpg using ffmpeg which you download using clive </li></ul><ul><li>First you need to download your .flv file to a folder and you need to Open a terminal window and go in to the .flv file folder and type the following command </li></ul><ul><li>ffmpeg -i jokes.flv -ab 56 -ar 22050 -b 500 -s 320×240 jokes.mpg </li></ul>
  28. 28. DAT to MPG Converter
  29. 29. Converting and encoding video <ul><li>jokes.flv is the file you want to convert, so the name must be the same as the source file.You can name jokes.mpg whatever you want as long as it has the .mpg extension. </li></ul><ul><li>-b bitrate: set the video bitrate in kbit/s (default = 200 kb/s) </li></ul><ul><li>-ab bitrate: set the audio bitrate in kbit/s (default = 64) </li></ul><ul><li>-ar sample rate: set the audio samplerate in Hz (default = 44100 Hz) </li></ul><ul><li>-s size: set frame size. The format is WxH. (default 160×128 ) </li></ul>
  30. 30. Converting and encoding video <ul><li>by selecting a format as one of the options (”vcd”, “svcd”, “dvd”, “dv”, “pal-vcd”, “ntsc-svcd”, all the format options (bitrate, codecs, buffer sizes) are then set automatically. </li></ul><ul><ul><li>$ ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg </li></ul></ul><ul><li>same example but use high quality, ntsc vcd format </li></ul><ul><ul><li>$ ffmpeg -i myfile.avi -hq -target ntsc-vcd /tmp/vcd.mpg </li></ul></ul><ul><li>same example but dvd quality </li></ul><ul><ul><li>$ ffmpeg -i myfile.avi -target ntsc-dvd /tmp/dvd.mpg </li></ul></ul><ul><li>same example use same quality as source </li></ul><ul><ul><li>$ ffmpeg -1 myfile.avi -sameq -target vcd /tmp/vcd.mpg </li></ul></ul><ul><li>converting a file for VCD format using a and b frames for MPEG 2 </li></ul><ul><ul><li>$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 /home/user/Video/vcd.mpg </li></ul></ul>
  31. 31. <ul><li>same conversion, but start at 0 seconds and convert only first 45 minutes. #use -ss for start position and -t for duration </li></ul><ul><ul><li>$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 -ss 00:00:00 -t 00:45:00 /home/user/Video/vcd.mpg (useful to extract songs!) </li></ul></ul><ul><li>converting a file to mpeg using mencoder (poorer quality than ffmpeg I think, but that’s on my system - and it really depends on the file and the codec you’re using). </li></ul><ul><ul><li>$ mencoder -oac copy -ovc lavc -of mpeg -o output_file.mpg your_file.wmv </li></ul></ul><ul><li>Using ffmpeg, it’s possible to rip the audio from any video file (it can convert) directly to an mp3 file like this: </li></ul><ul><ul><li>$ ffmpeg -i video.mpg -f mp3 audio_track.mp3 </li></ul></ul><ul><ul><li>video.mp3 is your input file and audio_track.mp3 is your output mp3 file. It works great! </li></ul></ul>
  32. 32. <ul><li>Converting MOV to FLV using FFMPEG </li></ul><ul><ul><li>ffmpeg -i movie1.flv </li></ul></ul><ul><li>Converting Mpeg to FLV using FFMPEG </li></ul><ul><ul><li>ffmpeg -i movie1.mpeg movie1.flv </li></ul></ul><ul><li>Converting AVI to FLV using FFMPEG video resolution to 500×500 </li></ul><ul><ul><li>ffmpeg -i movie1.avi -s 500×500 movie1.flv </li></ul></ul><ul><li>Converting 3GP to FLV using FFMPEG </li></ul><ul><ul><li>ffmpeg -i movie1.3gp -sameq -an movie1.flv </li></ul></ul><ul><li>This will convert movie1.3gp file to movie1.flv and will keep the original file settings and will disable the audio content </li></ul>
  33. 33. Audio tips and tricks
  34. 34. Extracting audio from video and more! <ul><li>mplayer -ao pcm &quot;$1&quot; -ao pcm:file=temp.wav (for mp4 files can be done with faad!). </li></ul><ul><li>temp.wav is your audio out which you can convert to any format you want using suitable encoder. (lame for mp3). </li></ul><ul><li>Soundconverter is a good GUI tool for ripping CDs and converting files. </li></ul><ul><li>kid3-qt can be used for tagging the files. </li></ul><ul><li>Amarok is a good media player for managing your collection! </li></ul><ul><li>Mp3report to get collection details! </li></ul><ul><li>You can install goldwave 4.26 over wine too provided you have the mfc42.dll </li></ul>
  35. 35. <ul><li>For the conversion you need the following tools installed: </li></ul><ul><ul><li>mplayer (with faad2 support compiled in!) </li></ul></ul><ul><ul><li>faad2 </li></ul></ul><ul><ul><li>for mp3: lame </li></ul></ul><ul><ul><li>for ogg: oggenc (vorbis-tools) </li></ul></ul>
  36. 36. Converting rate and zip
  37. 39. ffmpeg for audio 1 <ul><li>Converting aac to mp3 using FFMPEG with MetaData </li></ul><ul><ul><li>ffmpeg -i audio1.aac -ar 22050 -ab 32 -map_meta_data audio1.mp3:audio1.aac audio1.mp3 </li></ul></ul><ul><li>This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz and will copy the meta data from .aac file to .mp3 file </li></ul><ul><li>Converting WMV to MP3 using FFMPEG </li></ul><ul><ul><li>ffmpeg -i audio1.wmv audio1.mp3 </li></ul></ul><ul><li>This will convert audio1.wmv file to audio1.mp3 </li></ul>
  38. 40. ffmpeg for audio 2 <ul><li>Converting WMV to FLV using FFMPEG </li></ul><ul><ul><li>ffmpeg -i audio1.wmv audio1.flv </li></ul></ul><ul><li>This will convert audio1.wmv file to audio1.flv, this will generate only audio content </li></ul><ul><li>Converting AMR to MP3 using FFMPEG </li></ul><ul><ul><li>ffmpeg -i audio1.amr -ar 22050 audio1.mp3 </li></ul></ul><ul><li>This will convert audio1.amr file to audio1.mp3 having audio rate 22.05 Khz </li></ul><ul><li>Converting aac to mp3 using FFMPEG </li></ul><ul><ul><li>ffmpeg -i audio1.aac -ar 22050 -ab 32 audio1.mp3 </li></ul></ul><ul><li>This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz </li></ul>
  39. 41. Mp3 to flv + making slideshow! <ul><li>ffmpeg -y -i /home/song.mp3 -f flv -acodec mp3 -ab 64 -ac 1 /home/song.flv </li></ul><ul><li>Just puts the mp3 as flv file </li></ul><ul><li>I have two pics, pic1.jpg and pic2. jpg, and two audio clips, Boat_Of_Car_1.mp3 (5 seconds long) and Boat_Of_Car_2.mpr (6 seconds long). </li></ul><ul><li>ffmpeg/ffmpeg -y -loop_input -i jpgs/pic1.jpg -t 5 -i Boat_Of_Car_1.mp3 pic1.mpg </li></ul><ul><li>ffmpeg/ffmpeg -y -loop_input -i jpgs/pic2.jpg -t 6 -i Boat_Of_Car_2.mp3 pic2.mpg </li></ul><ul><li>cat pic[12].mpg>pic.mpg </li></ul><ul><li>ffmpeg/ffmpeg -y -s 600x450 -i pic.mpg -s 600x450 -f flv p.flv </li></ul><ul><li>p.flv is a video of pic1.jpg and pic2.jpg with Boat_Of_Car_1.mp3 and Boat_Of_Car_2.mp3 as background audio. </li></ul>
  40. 42. DVDs on Linux
  41. 43. DVD Structure <ul><li>Top level is a menu (a video clip with other information added) </li></ul><ul><li>Disk is divided into titles </li></ul><ul><li>Titles are divided into chapters </li></ul><ul><li>To display slides you need to turn a picture into short video clip. </li></ul>
  42. 44. Basic Tools for Making DVDs <ul><li>tovid – Convert video to DVD mpeg stream </li></ul><ul><li>makemenu – Create top level menu </li></ul><ul><li>makexml – Create xml file describing the video </li></ul><ul><li>dvdauthor – Create DVD file set </li></ul><ul><li>mkisofs – Create DVD image </li></ul>
  43. 45. Creating a DVD file <ul><li>tovid -dvd -in raw/video.avi </li></ul><ul><li>-out dvd/video1.mpg </li></ul><ul><li>Uses mpeg2enc to transcode the file </li></ul><ul><li>Takes 2 hours to do an hour video </li></ul>
  44. 46. Creating the menu <ul><li>makemenu “1: Birth” </li></ul><ul><li>“ 2: Growing up” </li></ul><ul><li>-background pict.png </li></ul><ul><li>-out menu.mpg </li></ul><ul><li>Generates the short “menu” video and other meta data for a DVD menu </li></ul>
  45. 47. Make the DVD description <ul><li>makexml -dvd -menu menu.mpg -chapters 5 </li></ul><ul><li>video1.mpg video2.mpg </li></ul><ul><li>dvd </li></ul><ul><li>dvdauthor uses a complex xml file to describe the DVD. This program creates it from simple input. </li></ul>
  46. 48. Make the DVD file system <ul><li>dvdauthor -x dvd.xml </li></ul><ul><li>Creates a file system containing the files which make up the DVD </li></ul><ul><li>To test use vlc: </li></ul><ul><ul><li>vlc dvd://`pwd` </li></ul></ul>
  47. 49. Make the DVD image <ul><li>mkisofs --dvd-video </li></ul><ul><li>-o ../dvd.iso . </li></ul><ul><li>Creates a burnable image of the DVD. </li></ul><ul><li>Do put output file in same directory as the input. </li></ul><ul><li>You can test the image too: </li></ul><ul><ul><li>vlc dvd://`pwd`/../dvd.iso </li></ul></ul>
  48. 50. Interactive DVD Creation
  49. 51. Interactive DVD Creation <ul><li>Handles menu creation </li></ul><ul><li>Adding clips to the DVD </li></ul><ul><li>Multiple Menus </li></ul><ul><li>Background images for menus </li></ul><ul><li>Front end to dvdauthor </li></ul>