Taking screenshots of the uploaded video using the FFMPEG Plugin 

Hey, now its time to take photos from your uploaded videos…I hope that sounds good

 

Anyways,It will be a simple job if you have achieved success in integrating the mencoder into the app.

 

So,lets start talking about the FFMPEG encoder.The FFMPEG encoder works similar to the Mencoder utility.But,the only difference is that it provides more control over the video.It provides the image capturing facilty which techies generally call screenshots.

Using the FFMPEG utility we can generate screenshots of various sizes and also develop thumbnails for our rails app.

 

In order to download the FFMPEG utilty,check the following link

 

http://www.free-codecs.com/ffmpegGUI_download.htm

or

http://www.videohelp.com/tools/ffmpeg

 

Then u just have to copy the files from the unzipped folder into the mplayer folder in the public directory of our application.

 

For the documentation with respect to the usage of the ffmpeg codec please visit the following site:

 

http://ffmpeg.mplayerhq.hu/documentation.html

The following function takes the responsibility of generating the screenshots of the uploaded video

def self.grab_screenshot_from_video(path,name,video_id)

      memdir = RAILS_ROOT+’/public/mplayer/’

      opdir = RAILS_ROOT + “/#{video_id}/”+name

      jpgdir =RAILS_ROOT + “/#{video_id}/”+name

      #conversion to mencoder format

      system “#{memdir}ffmpeg -i #{opdir}.flv -s 320×240 -vframes 1 -f image2 -an #{jpgdir}.jpg”

   end

 

The grab_screenshot_from_video takes the path of the generated video as the input and passes the video to the FFMPEG commandline utility to generate an image of size 320×240 and then saves the image in the jppdir.

 

NOTE:

 Here I have placed the FFMPEG utilty in the mplayer directory in thr public folder of our app.

Please do read at the following section reagarding the compatibility and testing of the FFMPEG encoderhttp://ffmpeg.mplayerhq.hu/compat.html

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • blogmarks
  • Book.mark.hu
  • co.mments
  • Technorati
  • YahooMyWeb
  • IndianPad
  • DZone