Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Research on Audio and Video Streaming

2,885 views

Published on

Research on Audio and Video Streaming by Anil Kumar at Nyros Technologies,Kakinada.

Published in: Technology, Business
  • ppt presentation for streaming video from s60 smart phones
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Research on Audio and Video Streaming

  1. 1. Audio and Video Streaming Using FFMpeg - Anil Kumar Email: anilkumar@nyros.in
  2. 2.  Index  Streaming  What we can  Requirements  How to process  In how many formats one file can be created?  Conversions  Web based converting  Mobile compatable converting  iPod compatable Converting  How to split videos and uses of splitting  Thumbnails creation from the video and images to video creation  Players to run the videos  Programming support  Summary  Reference sites
  3. 3. Streaming: In the 1990s middle days or before 1990s watching video and listen music online is very difficult, that means spending more hours to listen or watching video files, if there is a slow computer or dial –up internet connection then a word called “buffering” is at the status bar for the hours of time. And those videos are not cleared. So, for this purpose we need to convert those video files into streaming. To do the streaming files we can use the ffmpeg software. It will convert the input file to relevant file. The ultimate goal of streaming is reduce the bitrate per second, reduce the audio frequency, reduce the resolution of video file then the file size can be reduced, at that converted video can be play in the browser less time compare to original file. To do the streaming we use ffmpeg software. We can download from the website http://www.ffmpeg.org . What is ffmpeg? It is computer program that can record, convert and stream digital audio and video in many formats. It is command line tool this is composed of collection libraries. It includes audio and video codec libraries. It is started by Fabric Bellard, and it is maintained by Michel Niedermayer. Present version of ffmpeg is .5, it is developed under Linux, but it can be compiled in many of operating system. We can see the all features of latest version of ffmpeg .05 is at http:// www.videohelp.com/tools/ffmpeg
  4. 4. What we can What we can do with using of ffmpeg software. The followings things we can create by using ffmpeg software.  Process of converting the input file into flv format.  Web based video conversion  iPod based video conversion  Mobile based video conversion  Resolution and quality of videos can be reduced based on bandwidth  Creating thumbnails from the input file.  Number of ways a file can be converted  Reverse conversion to generate original file format  Splitting of videos
  5. 5. Requirements: We have different file formats files including mpg, mov, mp4, avi, dat and so on. To run these files in the browser we should have different types of players according to the specific format. And if the file is more in size and is with high resolution then we have to run the same file format in the web browser by installing all plugin to run them. Example: MPG format - Windows Media Player Plugin Mov format – Quick Player plugin We can convert the flv files to different required file types, create thumbnail images from the video file and also we can create video file from the list of images. If you find difficulty in using many plugin and installing them to run the available file formats better to go with single format FLV (convert files to flv) and install flash plugin. These files are less in file size by reduced file resolution, frames and the bit rate of audio.
  6. 6. How many ways one file can be converted? Any input video file can be converted into flv format. Other than this format we can convert a file into: 3. flv - mov 4. avi –mov 5. flv – mpeg 6. avi – mpeg 7. flv – mpg 8. mpg - flv 9. mpg – 3gp 10. 3gp – avi 11. Flv to dvd format and vcd format conversion 12. Mpg – mp4 13. Flv – mp4 14. Mpg –dat 15. Dat – mpg 16. Flv – mp3 17. Mp3 –wav
  7. 7. Conversions 1) Web based conversions Web based conversion can be made and the process involved in the conversion is explained with an example. Conversion of file into flv file format. FFMPEG.exe -i inputfile.xxx [parameters] outputfile.flv To convert video files to FLV, the most important parameters are: -b, it's the average bitrate. see also -maxrate -bufsize. -r, frame rate. use -re to read input at native frame rate. -s, frame size. i.e.: -s 320x200. -maxrate, use this instead of -b for low bit rate video. -minrate, set the minimum bitrate. Set maxrate=minrate=b to have a constant bitrate. -bufsize, set (in KByte/s) the size of the buffer used to control the average bandwidth. -sameq, convert video using the same per macroblock quantization of source.
  8. 8. -pass n, to launch the first pass setting use -pass 1, and for the second -pass2. -g, distance beetween keyframes. -i_qfactor, use it to set a difference in quantization beetween p frame and keyframe -qscale, to set a fixed macrobloc quantization (range:0-32, 0 better quality, 32 worst) -qmin, minimum quantization (max MB quality), try a value higher than 3-4 for low bitrate -qmax, maximum quantization (min MB quality), default 32. -me, motion extimation. Default is "epzs", try the "full" value for a little more quality. -deinterlace, deinterlace the source probably using Bob technique. -ar, audio frequency (5500, 11000, 22000, 44000 samples/s) -ab, audio bitrate in kbit (160, 128, 96, 80, 64, 48, 32, 24, 16) -ac, number of channels (1-2) -acodec copy, leave the audio tags untouched.
  9. 9. The any input file can be converted into flv format from the following command. Ffmpeg - i video.mov –b 600k –r 24 –ar 22050 –ab 96k video.flv Here i is the input file. -b 600k is bitrate of 600 kilobits/sec compromise between quality and bandwidth. -r 24 selects 24 video frames per second. -ar 22050 selects the audio sample rate of 22050 Hz. (this rate is sufficient for the voice) -ab 96k audio bitrate 96 kilobits/sec Without reducing the quality of input file then following command will be work Ffmpeg - i video.mov -sameq -f flv video.flv In this we can convert the mov file to flv, the converted file will have the same quality as of the original file is having but the only thing is that the file size couldn’t be reduced.
  10. 10. 2) Mobile based video conversion One video file can be converted into mobile compatable file i.e. 3gp format supported by the mobiles. The following command will convert the video file into 3gp file format with following attributes ffmpeg -i video.mpg -vcodec h263 -s qcif -r 15 -b 100k -acodec libfaac -ac 1 -ar 32000 -ab 64k video.3gp H.263 video codec QCIF video resolution (176×144) 15fps 100 kb/s video bitrate AAC audio codec (through libfaac) 1 audio channel 32000 Hz audio sampling frequency 64 kb/s audio bitrate
  11. 11. 3) iPod compatable video conversion The following command will be convert the flv file into mp4 file format ffmpeg -i Video.flv -ar 22050 -ab 32 -s 128×96 video1.mp4 –i input file name -ar 22050 is selects audio sample rate of 22050 Hz.( that is sufficient for the voice) -ab 32 is audio bit rate 32 kilobits/sec -s output dimensions (W X H).
  12. 12. Resolution and quality of videos can be reduced based on bandwidth Basing on the bandwidth we can reduce the quality of video file as well as the resolution of video can also be reduced. For the iPhone: The supported bitrates for streaming are: 100 Kbps to 1.6 Mbps The suggested bitrates for streaming are*: Low – 96 Kbps video, 64 Kbps audio Medium – 256 Kbps video, 64 Kbps audio High – 800 Kbps video, 64 Kbps audio The iPhone screen size is: 480×320 We can maintain the quality of video with two options as -qmin, minimum quantization (max MB quality), try a value higher than 3-4 for low bitrate -qmax, maximum quantization (min MB quality), default 32.
  13. 13. How to create thumbnails from the video file Ffmpeg –i video.avi –r 0.1 –sameq –f image2 video%02.jpg -i is the input file -r is for every five seconds will be one fifth (1/5) or 0.2, so to grab ever 0.2 frame, this code will be used. Specified frame to create thumbnails: Ffmpeg –i video.mpg –an –ss 00:00:03 –t 00:00:01 –r1 –y –s 320X240 video%d.jpg -ss record the start time -t record the end time -i input file name -an disable audio -r fps -y overwrite file -s output dimensions
  14. 14. Create multiple thumbnails at specified time interval Ffmpeg –i video.mpg –an –ss 00:01:03 –t 00:00:30 –r 1 – y –s 320X240 %d.jpg This command will create thumbnails of dimensions 320X240, and from 00:01:00 to 00:00:30 in this time interval, 30 thumbnails will be created.
  15. 15. Conversion Process for various file formats FLV-MOV: Ffmpeg -i video.flv -vcodec mpeg4 -r 30 -b 6000 video.mov -i input file name -vcodec is video codec that is mpeg4 -r 30 is selects 30 frames per second -b 6000 video bit rate 6000 kilobits/sec FLV – MPG: Ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320×240 video.mpg -b bitrate: set the video bitrate in kbit/s (default = 200 kb/s) -ab bitrate: set the audio bitrate in kbit/s (default = 64) -ar sample rate: set the audio samplerate in Hz (default = 44100 Hz) -s size: set frame size. The format is WxH (default 160×128 )
  16. 16. Conversion Process for various file formats FLV – VCD or DVD format conversion: This command will convert the video.flv file into vcd file format. ffmpeg -i video.flv -target ntsc-vcd vcd.mpg This command will convert the video.flv file into DVD file format. ffmpeg -i video.flv -target ntsc-dvd dvd.mpg AVI – MPEG conversion: ffmpeg -i video.avi -vcodec mpeg4 -r 30 -b 6000 video.mpeg -i is input file - vcodec is video codec -r 30 is fps -b 6000 is bitrate of video that is 6000 kilobits per second 3gp – AVI format conversion The following command will convert into 3gp format to avi file format. ffmpeg -i output.3gp -f avi -acodec libfaac output.avi -i is input file name -f is output file format -acodec is audio codec library that is libfaac
  17. 17. How to convert wav file to mp3 The following command will convert the wav file to mp3 file ffmpeg -i AVSEQ008.wav -acodec libfaac -ab 192k audio.mp3 -i input file -acodec audio codec that is libfaac -ab audio bitrate that is 192 kilobits per sec The following command will convert total video file into audio file ffmpeg -i AVSEQ01.mpg -f mp3 audio_track.mp3 It converts the AVSEQ01.mpg file to mp3 file that is audio_track.mp3 Mp3 – WAV file format: The following command will convert the file which is type mp3 to wav format file. ffmpeg -i audio.mp3 -acodec libfaac -ab 192k audio.wav -i is input file name -acodec is audio codec library that is libfaac -ab 192k is audio bit rate 192 kilobits per second.
  18. 18. How to convert wav file to mp3 The following command will convert the wav file to mp3 file ffmpeg -i AVSEQ008.wav -acodec libfaac -ab 192k audio.mp3 -i input file -acodec audio codec that is libfaac -ab audio bitrate that is 192 kilobits per sec The following command will convert total video file into audio file ffmpeg -i AVSEQ01.mpg -f mp3 audio_track.mp3 It converts the AVSEQ01.mpg file to mp3 file that is audio_track.mp3 Mp3 – WAV file format: The following command will convert the file which is type mp3 to wav format file. ffmpeg -i audio.mp3 -acodec libfaac -ab 192k audio.wav -i is input file name -acodec is audio codec library that is libfaac -ab 192k is audio bit rate 192 kilobits per second.
  19. 19. Reverse conversion The files that are converted above can be reconverted to their original format in one single step. The only thing that is required to do is to rearrange the input and output file format vice versa and you can get your original file back with the same quality and resolution it had.
  20. 20. Splitting of videos Before splitting the video file we have to know the input file time duration to cut the video at certain time intervals. To know the time duration of file run the following command: ffmpeg -i video.mpg 2> input_file.txt This input_file.txt files having the total information of that video.mpg file. Php code to get the duration from that file: $handle = @fopen ('input_file.txt','r'); if ($handle) { While (! feof ($handle)) { $buffer. = fgets ($handle, 4096); } fclose ($handle); } $duration_pos= strpos ($buffer,'Duration'); $duration_pos1= substr ($buffer, $duration_pos,18); $str=explode (" ", $duration_pos1);
  21. 21. Splitting of videos Once we have the total time duration of the file, and then split the video file with following command: ffmpeg -i vcd1.mpg -ss 00:00:10 -t 00:00:30 out1.mpg -ss is starting time of the video file -t is ending time of video file That particular time interval video can be stored in to out1.mpg file. ffmpeg –i video.flv -acodec libfaac -ss 00:00:00 -t 00:03:00 -ar 22050 -ab 32 -f flv -s 400x250 video1.flv From this command we can split the flv files also. acodec is audio codec that is libfacc ss is starting time t is ending time ar audio sample rate 22050 Hz ab audio bit rate that is 32 kilobits per second f flv is output file format that is flv. S is dimensions of output file.
  22. 22. Converting images into slideshow video file The following command will convert the list of images into one video file. ffmpeg -b 1800k -r 1 -i image_%d.jpg -f flv video1800.flv -b is bitrate per second Here that video having 1800 kilo bits per second. The set of images that are image_1.jpg, image_2.jpg, image_3.jpg, . . . image_n.jpg,
  23. 23. Commercial and free flash players Flow Player JW FLV Player WP Audio Player (Wordpress Audio Player) Embedr (http://embedr.com/): We can add embed tag at the website or blogs. XSPF Web Music Player (is a flash-based web application that uses xspf playlists format to play mp3 songs. XSPF is the XML Shareable Playlists Format.) MC Media Player (is a Flash-based media player for embedding video, audio and still images in web pages. It is free to use for both non-profit and commercial websites.) MC Classic (A multi-format player that includes a playlists menu with unlimited folders. Great for displaying all your files in a single interface. Supports FLV, H.264 (mov, mp4), MP3, JPG, PNG, GIF, SWF.) MC Altair (A single-file video player designed to be both easy to set up and extremely customizable. Supports FLV and H.264 (progressive download and RTMP streaming).)
  24. 24. Commercial website media players Moyea Web Player Pro (http://www.moyeasoft.com/download.html): It is the commercial media player for the web. It has the nice feature that we can insert the ads to video file. Moyea Web Player Pro accepts flash video (FLV and MP4, MOV, 3GP, 3G2 with H.264 codec), and offers a free video converter to ensure you can add videos in all formats to website. Any FLV Player (http://www.any-flv-player.com): Rave Player (http:// www.wimpyplayer.com/products/wimpy_rave.html) Audio MP3, AAC, M4A Video FLV, MPEG-4, MP4, SWF, 3GP
  25. 25. Commercial website media players Flow player: We can place the multiple players in the page We can splash the images. Alternate the embedding tag We can customize the tool tip texts. Streaming plugin detection It will check user's connection speed and serves the video accordingly. A faster speed means better video quality and larger file size. Click on the splash and you can see the calculated bandwidth below the video. For the commercial versions we can change the flow player logo at the player. JavaScript with YouTube play list look. YouTube video through their API. Download from http://flowplayer.org/download/index.html
  26. 26. Commercial website media players JW flv player: JW flv player can handle the FLV, MP4, MP3, AAC, JPG, PNG and GIF It also supports RTMP, HTTP, live streaming, various playlists formats, a wide range of settings and an extensive JavaScript API. Video in FLV and MP4 format. Audio in MP3 and AAC (Advanced audio coding) format. Images in JPG, GIF and PNG format. Download from http://www.longtailvideo.com/players/jw-flv-player/
  27. 27. Requirements to run the ffmpeg in the php environment To run this command in the php we can use three syntax that is: System() Shell_exec() Exec() To run these command in the php, the server should not run in the safe mode. Check the server information like http:// localhost/phpinfo.php file, and the safe_mode should be off. If it is ON then in the php.ini file we have to set it to off. Syntax: System( $command); Shell_exec($command); Exec ($command);
  28. 28. Summary Present days, video are the best way to conversate and learn things in a easiest way. . To run the videos in the websites, we have to convert files into one single format i.e. flv format files. So to do that we have open source software, using this software we can convert the video file compatible to use within web, mobiles and also iPod’s . Run the command in the command prompt or using any programming support to run those commands. We can the get the relevant file format that we can want. There are many players in which video files could be run and all vary according the supporting file formats. To make it easier one can go with FLV file formats which can be easily run in browser having simple flash plugin. Thus, File format, quality, resolution, thumbnails, bit rate of audio’s everything that is a part of video can be customized according to one’s need.
  29. 29. Reference Sites The conversion of videos and audio using ffmpeg http://www.mygnulinux.com/?p=56 The conversion of video conversion with ffmpeg commands http://www.phpro.org/tutorials/Video-Conversion-With-FFMPEG.html Converting of audio and video using ffmpeg http://www.hiteshagrawal.com/ffmpeg/converting-audiovideos-using-ffmpeg Converting of avi file to 3gp format videos http://goinggnu.wordpress.com/2007/02/13/convert-avi-to-3gp-using-ffmpeg/ How to convert videos file http://en.linuxreviews.org/HOWTO_Convert_video_files Tutorials of ffmpeg http://atomized.org/index.php?s=ffmpeg Converting video files to flv using ffmpeg http://www.bala-krishna.com/convert-video-files-to-flv-using-ffmpeg-command Converting videos to 3gp format video files http://davidar.890m.com/2009/02/28/converting-videos-to-3gp-in-ubuntu-intrepid-810-with-ffmpeg/ Converting avi files to 3gp format http://goinggnu.wordpress.com/2007/02/13/convert-avi-to-3gp-using-ffmpeg/ Splitting of videos http://ubuntuforums.org/archive/index.php/t-480343.html
  30. 30. Thank You

×