
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
media_trim
Trims an audio or video file using ffmpeg
.
ffmpeg
, including mp3
, mp4
, mkv
, and many more.trim
command.You need a working Ruby environment to install this program. I describe how to set that up here.
The trim
command is provided by the media_trim
Ruby gem.
Install it like this:
$ gem install media_trim
Add this line to your application’s Gemfile
:
gem 'media_trim'
Then execute:
$ bundle
Add the following to your application’s .gemspec
:
spec.add_dependency 'media_trim'
Then execute:
$ bundle
trim [OPTIONS] dir/file.ext start [[to|for] end]
start
and end
timecodes have the format [HH:[MM:]]SS[.XXX]
.
Note that decimal seconds may be specified, but frames may not;
this is consistent with how ffmpeg
parses timecodes.end
defaults to the end of the audio/video fileWhen run as a command, output files are named by adding a trim.
prefix to the media file name,
e.g. dir/trim.file.ext
.
By default, the trim
command does not overwrite pre-existing output files.
When trimming is complete, the trim
command displays the trimmed file,
unless the -q
option is specified.
OPTIONS
are:
-d
Enable debug output.-h
Display help information.-f
Overwrite output file if present.-v
Verbose output.-V
Do not view the trimmed file when complete.Crop dir/file.mp4
from 15.0 seconds to the end of the video, save to demo/trim.demo.mp4
:
$ trim demo/demo.mp4 15
Crop dir/file.mkv from 3 minutes, 25 seconds to 9 minutes, 35 seconds, save to demo/trim.demo.mp4
:
$ trim demo/demo.mp4 3:25 9:35
Same as the previous example, using optional to
syntax:
$ trim demo/demo.mp4 3:25 to 9:35
Save as the previous example, but specify the duration instead of the end time by using the for
keyword:
$ trim demo/demo.mp4 3:25 for 6:10
Need a way to figure out the start and stop times to trim a video? DJV is an excellent video viewer.
After checking out this git repository, install dependencies by typing:
$ bin/setup
You should do the above before running Visual Studio Code.
$ bundle exec rake test
The following will allow you to experiment:
$ bin/console
To install this gem onto your local machine, type:
$ bundle exec rake install
To create a git tag for the new version, push git commits and tags, and push the new version of the gem to https://rubygems.org, type:
$ bundle exec rake release
Bug reports and pull requests are welcome at https://github.com/mslinn/trim.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that media_trim demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.