I am using Ffmpeg to record video in a rails app. I want to give the user a minimum and maximum time limit. What is the best flag to use to set this restraint?
Time restraints with Ffmpeg
102 views Asked by AntonioMarquis AtThere are 2 answers
Glyoko
On
That's a bit beyond the scope of the basic validation that Paperclip does. Paperclip tries to gives you enough validations to cover 95% of your use cases, but for anything that's just a bit less than typical, you'll have to write your own logic. I don't believe there is a custom validation built-in for checking the length of videos. (However, there is a validates_attachment_size validation method you can use for validating the filesize of the asset. In a pinch, this might suffice.)
If you want to do some deeper validations on paperclip attachments, you should look into some different tools to write your own validation methods with. I'd take a look at streamio-ffmpeg if you're dealing with video.
Using that gem you could write a custom validation something like this:
class YourModel < ActiveRecord::Base
has_attached_file :your_media
validate :duration_in_range
private
def duration_in_range
# See https://github.com/streamio/streamio-ffmpeg#usage
unless FFMPEG::Movie.new(your_media.path).duration.in?(MIN_TIME..MAX_TIME)
errors.add(:your_media, "Video duration must be within #{MIN_TIME} and #{MAX_TIME} seconds")
end
end
end
Related Questions in RUBY-ON-RAILS
- How to display legend box in tooltip text for amCharts 5 in Rails application?
- how to integrate cashfree payment gateway in ruby on rails project
- RSpec Capybara throwing Selenium error when trying to click a button with browser confirm
- rails minitest not picking up fixture properly, instance variable not percolating
- Duplicate GET requests - Rails & Heroku
- How to stub out current_user in JWT model for Rspec?
- NameError in Home#index
- Verifying Google Identity OAuth2 token with Ruby
- Error WebMock::NetConnectNotAllowedError in testing with stub using minitest in rails (using Faraday)
- why is mission_control-jobs erroring with load path error?
- Rescuing validation errors from a polymorphic association
- New error on random number assigned to local variable , Rails
- How to fix error in model with gem lockbox
- Images uploaded via Active Storage not displaying in Active Admin or on certain devices
- controller test_methods generating two errors intermittently
Related Questions in RUBY
- how to integrate cashfree payment gateway in ruby on rails project
- RSpec Capybara throwing Selenium error when trying to click a button with browser confirm
- Duplicate GET requests - Rails & Heroku
- convert csv file with json data inside to a column, rows table in 2nd csv file
- Installing dependencies from a gemspec file
- Verifying Google Identity OAuth2 token with Ruby
- Java code of AES/GCM/NoPadding encryption algorithm with authentication tag
- How to fix error in model with gem lockbox
- Cannot install Ruby Gem on Window
- use logstash filter ,aes gcm encrypted in ruby,but cannot decrypted in java
- In Rails 7, what is the right ActiveRecord callback to use if I need to prevent (or rollback) persistance on error?
- How can I go through an array and still remove elements from it
- Nokogiri only returning 5 results
- How do I get the fullscreen mode in firefox?
- undefined group option when using branch reset group regex in Ruby
Related Questions in FFMPEG
- I need an azure product that executes my intensive ffmpeg command then dies, and i only get charged for the delta. Any Tips?
- Converting MP3/MP4 to WAV in the Frontend Using ffmpegwasm with Next.js Results in Module Not Found Error
- Get remote MKV file metadata using nodejs
- After using ffmpeg to remove some streams in mkv file, it takes much longer to open the media file in potplayer in Windows
- Implementing trim and fade filters with ffmpeg - MP3
- Merge Azure mp4 blobs via API (Preferred Azure)
- Overlaying frame number with ffmpeg
- Merge (concat) all video file present in '43. DP (Part1)' and put it into '43. DP (Part1)' and give name merged (concat) file to folder name
- I get an error when republishing the image I shot with ros2 run ffmpeg
- libav audio latency / cannot set audio_buffer_size
- An error occurred after encoding with h264_nvenc
- ffmpeg - excerpt from a large video file, preserving its additional streams
- Babel Loader error when using ffmpeg.wasm in CRA react app
- define the input FPS of a stream using ffmpeg-python
- NodeJS stream MKV as MP4 video
Related Questions in PAPERCLIP
- ActiveAdmin obscuring error messages in forms
- Mapping of filenames to paths using Ruby on Rails' paperclip
- paperclip detect p8 files with wrong content type
- Rails and Paperclip: Unable to upload images using Cloudfront
- Rails 5, Paperclip GEM Upload Multiple Images In one Action
- Webp image cropping in paperclip
- Rails-7 ArgumentError Unknown key: :on. Valid keys are: :if, :unless, :prepend | mongoid-paperclip
- Can we update existing xlsx file store in database in Ruby On Rails
- rails - how to specify the column to where kt-paperclip gem should calculate the checksum
- How does Paperclip Gem use <attachment>_updated_at and what is its significance?
- Paperclip: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint
- amazon s3 version paperclip The specified key does not exist
- Webp image upload issue in paperclip gem in ruby on rails
- Not able to check if file exists on S3(Failed to open TCP connection to 169.254.169.254:80)
- Retrieve S3 URL of a file uploaded using Paperclip Rails from Node.js
Related Questions in PAPERCLIP-VALIDATION
- Webp image upload issue in paperclip gem in ruby on rails
- Rails - Paperclip ROLLBACK due to associations
- Paperclip content size validation is not working
- Not able to upload the different files in paperclip with type application/*
- Why some of the MP4 file's mime-type are application/octet-stream instead of video/mp4?
- Upload file and detect language from the uploaded content / filename with Paperclip for Ruby on Rails
- Dynamic size styling in paperclip
- ImageMagick installation in Docker Alpine
- Paperclip failed to upload msg file type
- Paperclip: Cannot attach XLS (But DOC works)
- Time restraints with Ffmpeg
- Retroactively change paperclip size validation -> previous images now invalid
- Is it possible to upload .mov files using Paperclip?
- Uploading base64 through Paperclip
- paperclip 5.1 content-type validation too strict
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
In
ffmpeguse the-t(or-to) option to set the duration. Example for 120 seconds:or
See FFmpeg Documentation.