FFmpeg Toolbox

A set of wrapper functions to run FFmpeg directly from Matlab
8,1K download
Aggiornato 13 lug 2018

Visualizza la licenza

FFmpeg (http://ffmpeg.org/) is a complete, cross-platform solution to record, convert and stream audio and video. FFmpeg Toolbox is aimed to bring FFmpeg features to Matlab. While FFmpeg supports a vast number of multimedia formats and codecs, FFmpeg Toolbox brings a selected few (MP3, AAC, mpeg4, x264, animated GIF) closer to the user with its output option parameters.
INSTALLATION
To use this toolbox, FFmpeg binaries must already be downloaded and made available on the PC. (E.g., in Windows, ffmpeg.exe must be available). In MATLAB, run the toolbox setup m-file (ffmpegsetup.m) and follow its instructions. Note that if a newer version of FFmpeg is placed elsewhere on the PC, you must rerun ffmpegsetup to specify which ffmpeg executable is used with the toolbox.
Example 1. Convert an AVI movie file to MP4 with AAC audio codec and x264 video codec:
ffmpegtranscode('input.avi', 'output.mp4', 'AudioCodec', 'aac', 'VideoCodec', 'x264');

Example 2. To create animated GIF of a running sinusoid:

t = linspace(0,1,1001);
phi = linspace(0,2*pi,21);
figure;
for n = 1:numel(phi)
plot(t,sin(2*pi*t+phi(n)))
print('-dpng',sprintf('test%02d.png',n)); % create an intermediate PNG file
end
ffmpegimages2video('test%02d.png','sinedemo.gif','InputFrameRate',5,...
'VideoCodec','gif','DeleteSource','on');

Example 3: Overlay a transparent mask to a video

videofile = 'video.mp4';
maskfile = 'mask.png'; % same size as video.mp4 frame
filtgraph = [ffmpegfilter.head ffmpegfilter.overlay ffmpegfilter.tail];
filtgraph(1).link(filtgraph(2),'0:v'); % video.mp4 as the main
filtgraph(1).link(filtgraph(2),'1:v',true); % mask.png as overlayed
filtgraph(2).link(filtgraph(3));
ffmpegcombine({'videofile.mp4' 'maskfile'},'output.mp4',filtgraph);

TOOLBOX FUNCTION AND CLASS LIST:

Toolbox Setup
ffmpegsetup - Run this first to use this toolbox

FFmpeg feature list functions
ffmpegcodecs - Gets supported video codecs
ffmpegcolor - Convert color expression from MATLAB to FFmpeg
ffmpegcolors - Gets FFmpeg color names and their RGB values
ffmpegformats - Gets multimedia file formats
ffmpegpixfmts - Gets supported video pixel formats

FFmpeg wrapper functions
ffmpegextract - Extract a stream from a media file
ffmpegimage2video - Create video file from a series of images
ffmpeginfo - Retrieves media file information
ffmpegtranscode - Transcode media file (supports croping & scaling)
ffmpegcombine - Marge multiple media files with a filtergraph

FFmpeg filtergraph generator functions
ffmpegfiltersvideotform - To apply a series of spatial transformations
ffmpegfilterspalette - To generate and apply 256-color palette

FFmpeg filters (ffmpegfilter package)
ffmpegfilter.crop - Crop video
ffmpegfilter.hflip - Flip video horizontally
ffmpegfilter.histeq - Apply global color histogram equalization
ffmpegfilter.null - Pass through
ffmpegfilter.overlay - Overlay a video on top of another
ffmpegfilter.pad - Pad video
ffmpegfilter.palettegen - Generate a 256-color palette for a video
ffmpegfilter.paletteuse - Use a palette to reduce colors in video
ffmpegfilter.rotate - Rotate video
ffmpegfilter.scale - Scale or resize video
ffmpegfilter.setdar - Change display-aspect-ratio (DAR) setting
ffmpegfilter.setsar - Change sample-aspect-ratio (SAR) setting
ffmpegfilter.split - Split into several identical outputs
ffmpegfilter.transpose - Transpose rows of video with columns
ffmpegfilter.vflip - Flip video vertically

ffmpegfilter.head - Start of filtergraph (one per filtergraph)
ffmpegfilter.tail - End of filtergraph (one per filtergraph)
ffmpegfilter.base - Base class for all ffmpegfilter classes

Low-level FFmpeg wrapper functions
ffmpegexecargs - Run FFmpeg with custom option structs
ffmpegexec - Run FFmpeg with custom argument string

Cita come

Kesh Ikuma (2024). FFmpeg Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/42296-ffmpeg-toolbox), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2013a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
2.2.1.1

Unchecked "Package as a toolbox"

2.2.1.0

Fixed the bug in private/gif_processing.m

2.2.0.0

(r8) Added missing files (private/isfullpath.m, private/rel2fullname.m, & private/relfile.m)
- Added ffmpegfilter.setdar & ffmpegfilter.setsar classes
- Fixed an issue with incorrect interaction between OutputFrameRate and Range options
- Other misc. small bug fixes

2.1.0.0

Added ffmpegcombine function, which let you marge media files using a filter graph

2.0.2.0

Fixed a bug in PixelFormat option handling
Edited the Description

1.4.0.0

Fixed a couple bugs: Range option handling and default progress display function

1.3.0.0

Major Release
- added animated GIF support
- added ffmpegimage2video function to convert images to video
- added ffmpegfiltergraph function and +ffmpegfilter class package to construct FFmpeg filter command with a linked ffmpeg filter objects.

1.2.0.0

Added VideoFlip option to ffmpegtranscode

1.1.0.0

bug fix

1.0.0.0