An implementation of FFmpeg for audio playback of almost any media format
When building, the FFmpeg libraries are dynamically linked by default, which means that you'll need a local installation of these libraries in order for the external to work.
Includes the following features:
-
play/pause and seek functionality.
-
changing the speed of playback.
-
reading and iterating through m3u playlists.
-
It reads pseudo m3u playlists. Each line in the m3u should be just the file name, preceded by a path relative to the location of the m3u if they don't reside in the same folder.
-
The m3u reader can also read nested m3u's. For example, an m3u could consist of the following three lines:
disc1.m3u disc2.m3u disc3.m3u
-
-
opening files from http urls.
-
retrieving metadata.
Creation args
- numeric list
-
The channel layout. Defaults to stereo if no args given.
-
Numbers specified represent the bits of an audio channel bit-mask. A full list of available channels can be found here: https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/channel_layout.h
-
Inlets
-
bang - Play/pause the currently loaded track.
- Sends a 1 or 0 through the last outlet to indicate whether it's playing or paused.
float - (Re)start playback of a given track number
- Zero will stop playback.
anything - Look for matching metadata
- If metadata is found, it will be sent through the right-most outlet.
- A file must be successfully opened for any of the above to work
- signal - Change the playback speed.
-
speed can be a factor between 16 and 1/16th.
-
speed can also be altered by sending the message [ speed $1 ( to the 1st inlet.
-
Outlets
-
signal - Left channel
-
signal - Right channel
- The number of signal outlets there are depends on the number of creation args given, with the default being 2 signals for stereo.
-
list - Outputs various messages including information regarding whether a file was successfully opened, whether a track is currently playing, track metadata, etc.
Messages
-
[ print $.. ( or [ info $.. ( - Prints metadata info.
-
If no args given, it will print general info. Otherwise, it will print custom info.
-
metadata needs to be surrounded with percent signs.
- Example [ print %artist% - %title% (
-
-
[ send $.. ( - Sends metadata info through the
last outlet. -
[ open $1 ( - Attempts to open a file.
- Sends a 1 or 0 through the last outlet to indicate success or failure.
-
[ seek $1 ( - Seek to a track position.
-
[ speed $1 ( - Set the playback speed.
-
[ play $1 ( - Set playback state to either playing or paused.
- Acts as a toggle when no args are given.
- When an arg is given, state is forced to playing(1) or paused(0).
-
[ interp $1 ( - Change the interpolation algorithm.
- Options include:
- Sinc (good | medium | fast)
- Zero-order hold
- Linear (the default)
- Options include:
-
[ stop ( - An alias for [ 0 (.
-
[ pos ( - Returns the track position.
-
Any unrecognized message is assumed to be a metadata term. If there is a match, the metadata will be sent through the last outlet.
Update - March 16 2022:
ffplay~ now uses Secret Rabbit Code for resampling, which makes playback speed transitions much smoother. Playback speed can also be manipulated with signals via the 2nd inlet.
ffplay~ is now available through deken. It is part of a larger library called quilt. Searching either "quilt" or "ffplay~" should give a result.
The FFmpeg libraries are still separate, but can be either easily downloaded or easily installed via a package manager.
For Windows users, the FFmpeg libraries can be downloaded here: https://github.com/myQwil/pd-quilt/releases/download/v0.7.7/ffmpeg.v4.4.1.Windows-amd64-32.zip.
For Linux and macOS users, A README file is included, which lists the dependencies for those platforms.