Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8972797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:18:13+00:00 2026-06-15T18:18:13+00:00

I want to upload files and convert thumbnails for it. My code is: require

  • 0

I want to upload files and convert thumbnails for it.

My code is:

require 'streamio-ffmpeg'
module CarrierWave
  module FFMPEG
    module ClassMethods
      def resample(bitrate)
        process :resample => bitrate
      end

      def gen_video_thumb(width, height)
        process :gen_video_thumb => [width, height]
      end
    end

    #def is_video?
    #  ::FFMPEG::Movie.new(File.open(store_path)).frame_rate != nil
    #end

    def gen_video_thumb(width, height)
      directory = File.dirname(current_path)
      tmpfile = File.join(directory, "tmpfile")

      FileUtils.move(current_path, tmpfile)
      file = ::FFMPEG::Movie.new(tmpfile)
      file.transcode(current_path, "-ss 00:00:01 -an -r 1 -vframes 1 -s #{width}x#{height}")

      FileUtils.rm(tmpfile)
    end

    def resample(bitrate)
      directory = File.dirname(current_path)
      tmpfile = File.join(directory, "tmpfile")

      File.move(current_path, tmpfile)

      file = ::FFMPEG::Movie.new(tmpfile)
      file.transcode(current_path, :audio_bitrate => bitrate)

      File.delete(tmpfile)
    end
  end
end

My Uploader have

  version :thumb do
    process :resize_to_fill => [100, 70], :if=> :image?
    process :gen_video_thumb => [100, 70], :if=> :video? do
      process :convert => 'png'
    end
  end

and functions are.

  protected

  def image?(new_file)
    ::FFMPEG::Movie.new(new_file.file.path).frame_rate == nil
  end

  def video?(new_file)
    ::FFMPEG::Movie.new(new_file.file.path).frame_rate != nil
  end

But the problem is that, video is uploaded, video thubmail is generated very good. But it do not have a png extension. If i upload a mp4 file, its thumbnail also have a mp4 extension. but that is an image can be viewed in browser.

How to correct the extension issue? Can any one point out the issue in the code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:18:15+00:00Added an answer on June 15, 2026 at 6:18 pm

    I recently solved this by overriding the full_filename method for the :thumb version

    version :thumb do
      # do your processing
      process :whatever
    
      # redefine the name for this version
      def full_filename(for_file=file)
        super.chomp('mp4') + 'png'
      end
    end
    

    I called super to get the default :thumb filename, then changed the extension from mp4 to png, but you could do anything.

    For more info, the carrierwave wiki has a good article on How to: Customize your version file names. Check out the other wiki pages for lots of ideas.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert pdfs to image files within appengine. Ideally I would upload
I want to upload files to FTPS and SFTP. My code is currently using
I want to upload files directly to IIS7 (in this case I am using
i want to upload two files. here is the script <? ini_set('memory_limit', 400M); ini_set('file_uploads',
I want to upload some files of size 35MB on to the blob container.
i have the form, and i want to upload two files. here is the
I want users to be able to upload files via FTP to my site
I would like to upload files just like google mail does. I would want
I have a ftp client that allows users to upload files. I want determine
I want to upload video (basically large files) without using Flash Plugin. It would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.