/RoughDraft

A Fun PowerShell Module for Multimedia (using FFMpeg)

Primary LanguagePowerShellMIT LicenseMIT


A Fun PowerShell Module for Multimedia

Commands

RoughDraft is a fun PowerShell Module for Multimedia.

It provides pipeline-aware command to create, convert, query, edit, and join multimedia files.

RoughDraft -Media Commands

The core of RoughDraft are the -Media commands:

Name Description
Convert-Media Converts media between formats
Edit-Media Edits media files
Get-Media Gets media metadata
Join-Media Joins media files
New-Media Creates media files
Recieve-Media Receives media from devices
Set-Media Sets media metadata
Show-Media Shows media files
Split-Media Splits media files
Send-Media Broadcasts media

These commands are built atop of FFMpeg

All Media Commands are Extensible. See the list of extensions

Examples

Convert-Media

# Converts a Movie.mkv to MP4
Convert-Media .\Movie.mkv mp4 

# Converts an .mp4 file to an .mp3
Convert-Media .\Movie.mp4 .\Soundtrack.mp3 

# Get rid of flac files
Convert-Media .\Song.flac .mp3

# Convert all .flac files to .mp3
Get-ChildItem -Path $home\Music -Recurse |
    Where-Object Extension -eq '.flac' |
    Convert-Media .mp3

Edit-Media

# Adds a sepia effect to an .mp4
Edit-Media .\Movie.mp4 -Sepia

# Increases the audio by 4 decibals.
Edit-Media .\Song.mp3 -AudioGain 4db

Get-Media

# Get metadata about an mp3
Get-Media .\Song.mp3 

# Detect silences within a song
Get-Media .\Song.mp3 -SilenceDetect

# Gets metadata about a movie.
Get-Media .\Movie.mp4        

Join-Media

# Make a timelapse from a directory of pictures
dir *.jpg | Join-Media -OutputPath .\Timelapse.mp4 -Timelapse 

# Join an audio and video file
Join-Media -InputPath .\Silent.mp4, .\Soundtrack.mp3 -OutputPath .\Movie.mp4 

# Join mp3s into an album
dir *.mp3 | Join-Media -Output ..\Album.mp3 

# Join various video files into a longer movie
dir | Where-Object Extension -in '.mkv', '.mp4' | Join-Media -Output ..\Movie.mp4 

New-Media

# Create a red jpg
New-Media -Color Red -OutputPath .\Red.jpg 

# Create a 15 second cyan mp4 at 1080p
New-Media -Color Cyan -OutputPath .\Cyan.mp4 -Duration '00:00:05' -Resolution '1920x1080'

# Create an RGB test source
New-Media -TestSource rgbtestsrc -OutputPath .\rgbtestsrc.mp4 -Duration '00:00:10'  

Set-Media

# Set metadata about a video
Set-Media .\Movie.mp4 -Property @{title='My Movie'}

# Sets metadata about a music file.
Set-Media .\Song.mp3 -Property @{title='My Song';artist='me';'lyrics-eng' = 'My Lyrics'}

# Sets album artwork
Set-Media .\Song.mp3 -AlbumArt .\Cover.jpg

Additional RoughDraft commands:

Name Description
Get-FFMpeg Gets FFMpeg
Get-FFPlay Gets FFPlay
Get-FFProbe Gets FFProbe
Get-FFProbe Uses FFProbe directly
Get-RoughDraftExtension Gets RoughDraftExtensions
Use-FFMpeg Uses FFMpeg directly
Use-FFPlay Uses FFPlay directly
Use-FFProbe Uses FFProbe directly

Additional examples:

# List available codecs
Get-FFMpeg -ListCodec         

# List available codecs
Get-FFMpeg -ListCaptureDevice 

# List available filters
Get-FFMpeg -ListFilter

# Get information about a filter 
Get-FFMpeg -FilterName

RoughDraft Extensions

RoughDraft uses Extensions to make complex media scenarios easier work with. There are currently 106 extensions:

DisplayName Synopsis Extends
AlbumArt Sets album artwork Set-Media
AmplifyPixel AmplifyPixel extension Edit-Media,Show-Media
AudioCrusher Audio Crusher Edit-Media,Show-Media
AudioExpression Evaluates Audio Expressions Show-Media,Edit-Media,New-Media
AudioFrequencyExpression Apply expressions to audio frequencies Edit-Media,Show-Media
AudioGain Increases audio volume Edit-Media,Show-Media
BilateralSmooth Bilateral Smooth Edit-Media,Show-Media
BlackDetect Detect black periods in a video. Get-Media
BlackFrame Detects black frames. Get-Media
BlendFrame BlendFrame Extension Join-Media,Show-Media,Edit-Media
BlendVideo BlendVideo Extension Join-Media
Blur Blurs Video Edit-Media,Show-Media
CaptureDevice Gets capture devices Get-FFMpeg
Chorus chorus Edit-Media,Show-Media
Codecs Lists codecs Get-FFMpeg
ColorContrast ColorContrast Extension Edit-Media,Show-Media
ColorExpression Color Expression Join-Media,Show-Media,Edit-Media
ColorHold ColorHold Extension Edit-Media,Show-Media
Colorize Colorize a video stream Edit-Media,Show-Media
ColorScope Colorscope extension Edit-Media,Show-Media
ColorSource Generates a color Show-Media,New-Media
Convolve convolve Join-Media
Crop Crop Extension Receive-Media,Send-Media,Edit-Media,Show-Media
CropDetect Auto-detect the crop size. Get-Media
CrossFade acrossfade Join-Media
DataScope Datascope effect Edit-Media
Deconvolve deconvolve Join-Media
DirectShow DirectShow Extension Receive-Media,Send-Media,Show-Media
DrawSubtitle Draw subtitles on top of input video Edit-Media,Convert-Media
DrawText Draws Text on Video Edit-Media,Show-Media
Echo Adds echoes to audio Edit-Media,Show-Media
EdgeDetect EdgeDetect Extension Edit-Media,Show-Media
Emboss Embosses video or images Edit-Media
Erosion Erode Video Edit-Media,Show-Media
Exposure Exposure Extension Edit-Media,Show-Media
ExtractSubtitle Extract Subtitle Extension Convert-Media
FadeIn Fades in video Edit-Media
FillBorder Fill Borders. Edit-Media,Show-Media
FilterInput Gets filter details Get-FFMpeg
FiniteEqualizer Finite Equalizer Edit-Media,Show-Media
Flanger Audio Flanger. Edit-Media,Show-Media
FlipHorizontal Flips video horizontally Edit-Media,Show-Media
FlipVertical Flips video vertically Edit-Media,Show-Media
FrameBuffer FrameBuffer Extension Receive-Media,Send-Media,Show-Media
FrameStep FrameStep Effect Edit-Media,Show-Media
GifPalette Gif Palette Extension Convert-Media
Histogram Histogram Extension Edit-Media,Show-Media
Hue Hue Extension Edit-Media,Show-Media
Hysteresis Hysteresis Join-Media
LagFun Slowly update darker pixels. Edit-Media,Show-Media
Life Generates life Show-Media,New-Media
LimitPixel Limits Pixel values Edit-Media,Show-Media
ListFilters Lists filters Get-FFMpeg
ListProtocols Lists protocols Get-FFMpeg
Mandelbrot Generates fractals Show-Media,New-Media
MedianPixel Picks median pixels Edit-Media,Show-Media
Mirror Mirror Extension Edit-Media,Show-Media
MixAudio Mix Audio Join-Media
MixVideo Mix Video Join-Media
Monochrome Make video monochrome Edit-Media
NoAudio Removes Audio Split-Media
NoLogo delogo Edit-Media,Show-Media
Overlay overlay Join-Media
Phaser Audio Phaser Edit-Media,Show-Media
PitchFactor Adjust Pitch by a factor Edit-Media,Show-Media
Pixelate Pixelate effect Edit-Media
Playlist Creates a playlist Join-Media
Pulsator Pulsator Effect Edit-Media,Show-Media
RandomizeFrame RandomizeFrame extensions Edit-Media,Show-Media
Rate Adjusts the rate of media. Edit-Media,Show-Media
Resize Simple video resize. Edit-Media,Convert-Media,Show-Media
ReverseAudio Reverses audio Edit-Media
ReverseVideo Reverses video Edit-Media
Rotate Rotates a video Edit-Media,Convert-Media,Show-Media
Scale Scales video. Edit-Media,Show-Media
ScrollVideo Scrolls video Edit-Media,Show-Media
Sepia Applies a Sepia Filter Edit-Media
ShowFrequency Show Frequencies Show-Media,Edit-Media,New-Media
ShowScale Show the tonal scale of the audio Show-Media,Edit-Media,New-Media
ShowSpectrum Shows the audio spectrum Show-Media,Edit-Media,New-Media
ShowVectorScope Shows a Vector Scope of the Audio Show-Media,Edit-Media,New-Media
ShowVolume Shows the volume of an audio stream. Show-Media,Edit-Media,New-Media
ShowWaveform Shows audio waveform. Show-Media,Edit-Media,New-Media
ShuffleFrames Shuffles frames in video Edit-Media
Sierpinski Generates a Sierpinski fractal Show-Media,New-Media
SilenceDetect Detects silence in an audio stream Get-Media
SilenceRemove Detects silence in an audio stream Edit-Media
Sine Generates a sine wave New-Media
Skew Skew Extension Edit-Media,Show-Media
SubFrequencyCut Cut subwoofer frequencies Edit-Media,Show-Media
Subtitler Creates subtitles. New-Media
SuperEqualizer Audio 18 band Superequalizer Edit-Media,Show-Media
SuperFrequencyCut Cut super frequencies. Edit-Media,Show-Media
Tempo Adjust audio tempo. Edit-Media,Show-Media
TestSource Generates test sources Show-Media,New-Media
Tile Tile Extension Edit-Media
TimeMix Mix successive video frames. Edit-Media,Show-Media
Tremolo Tremolo effect Edit-Media,Show-Media
Vibrato Vibrato effect Edit-Media,Show-Media
VideoExpression Evaluates Video Expressions Edit-Media,Show-Media
VideoForLinux VideoForLinux Extension Receive-Media,Send-Media,Show-Media
Vignette Applies a vignette filter Edit-Media,Show-Media
VolumeLevel Gets VolumeLevels Get-Media
Watermark Watermarks a video Edit-Media
YouTubeDL Youtube Downloader Get-Media
ZoomPan Zoom and Pan Edit-Media,Show-Media

Extending RoughDraft

RoughDraft is built extensibly. This is so that complex FFMpeg operations can be abstracted into small amounts of code.

You can see the current set of extensions with:

Get-RoughDraftExtension

Extension Scripts

Extensions are simple scripts files named with the regular expression \.(rd|RoughDraft)\.(ext|extension)\.ps1$.

They can exist in any module that adds the tag "RoughDraft".

Extensions should include the following attributes above their parameter block:

# It's an extension
[Runtime.CompilerServices.Extension()]
# that extends Edit-Media            
# (Change this to indicate which command you'd like to extend)
# (Add additional Cmdlet attributes one to extend more commands)
[Management.Automation.Cmdlet("Edit","Media")] 
# that is inherited (this is the default).
# (an extension that is 'Inherited' will return control to the main function when it is done.)
# (an extension that is 'NotInherited' will run and return directly)
[ComponentModel.Inheritance("Inherited")]
param(
# At least one parameter of the extension should be mandatory.
[switch]
$MyEditExtension
)

Commands that can be extended:

The following commands can currently be extended:

  • Convert-Media
  • Edit-Media
  • Get-FFMpeg
  • Get-Media
  • Join-Media
  • New-Media
  • Recieve-Media
  • Set-Media
  • Send-Media
  • Show-Media
  • Split-Media