VICE - Video, audio and Image Converter for Erlang/Elixir

Copyright (c) 2014-2016 Grégoire Lejeune, 2016 Botsunit, 2017-2018 G-Corp

Version: 0.1.0

Authors: Gregoire Lejeune (gregoire.lejeune@gmail.com).

All ContributorsBuild StatusHex.pm

VICE

VICE is a fork and rewrite of erlffmpeg.

Install

cmake, ffmpeg|libav, libopencv-dev, imagemagick, SoX

Example


1> vice:start().
...
2> {async, Worker} = vice:convert("test/erlang.mp4", "erlang.webm").
...
3> vice:status(Worker).
{running, 9.131803868645973}
3> vice:status(Worker).
{running, 22.89698605488079}
...

Common options

TypeNameDescriptionValueExample
globalcgroupExecute encoder in the given cgroup.string() | binary(){cgroup, "cpu:/erlang.vice"}
globalcgexecPath to the cgexec executable.string() | binary(){cgexec, "/usr/bin/cgexec"}
globaltypeAllow you to force the input type.video | audio | image{cgexec, "/usr/bin/cgexec"}

Video

For video conversion, VICE use FFmpeg.

Options

TypeNameDescriptionValueExample
globalpresetUse a given preset file.string() | atom(){preset, hls1080p}
globalglobal_paramsGlobal parameters.[{atom(), term()}][{framerate, 25}, {bitrate, 3950}]
globalyesOverwrite output files without asking.true | false{yes, true}
globalfix_sub_durationFix subtitles durations. For each subtitle, wait for the next packet in the same stream and adjust the duration of the first to avoid overlap.true | false{fix_sub_duration, true}
globalcanvas_sizeSet the size of the canvas used to render subtitles.integer(){canvas_size, 10}
globalfilter_complexDefine a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs.Filtergraph :: string() | binary() | proplist(){filter_complex, [{"acrossfade", "d=10"}, {"c1", "exp"}, {"c2", "exp"}]}
globalfilter_complex_scriptThis option is similar to filter_complex, the only difference is that its argument is the name of the file from which a complex filtergraph description is to be read. Script :: file:filename_all(){filter_complex_script, "filter.script"}
globalallowed_extensionsList of file extensions that dash or hls is allowed to access.Extensions :: string() | binary(){allowed_extensions, "vtt,aac,ts,key"}
inputinput_positionSeeks in this input file to position.position :: string() | binary(){input_position, "00:01:02.123"}
inputinput_eof_positionLike the input_position option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF. .position :: string() | binary(){input_eof_position, "-0:32:01.123"}
inputinput_formatForce input format.Format :: string(){input_format, "mp4"}
inputinput_durationLimit the duration of data read from the input file.position :: string() | binary(){input_duration, "0:32:01.123"}
inputdecoderSelect a decoder for one or more streams.[Stream :: string(), Codec :: string()]{decoder, ["a", "pcm_s161e"]}
inputitoffsetSet the input time offset.position :: string() | binary(){itoffset, "+12.345"}
inputinput_frame_rateSet frame rate (Hz value, fraction or abbreviation).[Stream :: string(), FPS :: integer()] | FPS :: integer(){input_frame_rate, 25}
inputinput_frame_sizeSet frame size.[Stream :: string(), Size :: integer()] | Size :: integer(){input_frame_size, ["v", 1]}
inputinput_pixel_formatSet pixel format.[Stream :: string(), Format :: string()] | Format :: string() | binary(){input_pixel_format, "rgb24"}
inputinput_sws_flagsSet SwScaler flags.Flags :: string() | binary(){input_sws_flags, "gauss"}
inputinput_audio_frequencySet the audio sampling frequency.[Stream :: string(), Freq :: integer()] | Freq :: integer(){input_audio_frequency, ["a:1", 22050]}
inputinput_audio_channelsSet the number of audio channels.[Stream :: string(), Channels :: integer()] | Channels :: integer(){input_audio_channels, 6}
inputinput_acodecSet the audio codec.Codec :: string() | binary(){input_acodec, "pcm_s24le"}
inputguess_layout_maxIf some input channel layout is not known, try to guess only if it corresponds to at most the specified number of channels.Channels :: integer(){guess_layout_max, 2}
inputinput_vcodecSet the video codec.Codec :: string() | binary(){input_vcodec, "libxvid"}
inputinput_scodecSet the subtitle codec.Codec :: string() | binary(){input_scodec, "srt"}
inputmuxdelaySet the maximum demux-decode delay. Delay :: float() | integer(){muxdelay, 0.1}
inputmuxpreloadSet the initial demux-decode delay.Delay :: float() | integer(){muxpreload, 0.1}
inputaccurate_seekThis option enables or disables accurate seeking in input files with the output_position option.true | false{accurate_seek, false}
outputoutput_formatForce output format.Format :: string(){output_format, "mp4"}
outputoutput_durationLimit the duration of data read from the output file.position :: string() | binary(){output_duration, "0:32:01.123}
outputoutput_positionSeeks in this output file to position.position :: string() | binary(){output_position, "00:01:02.123}
outputoutput_eof_positionLike the output_position option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF. .position :: string() | binary(){output_eof_position, "-0:32:01.123}
outputencoderSelect a encoder for one or more streams.[Stream :: string(), Codec :: string()] | Codec :: string(){encoder, ["a", "pcm_s161e"]}
outputbitrateSet bitrate.[Stream :: string(), Bitrate :: string()] | [Stream :: string(), Number :: integer(), Bitrate :: string()] | Bitrate :: string() | integer(){bitrate, ["v", 0, "800k"]}
outputtimestampSet the recording timestamp in the container.Date :: date()
outputtargetSpecify target file type (vcd, svcd, dvd, dv, dv50). type may be prefixed with pal-, ntsc- or film- to use the corresponding standard.Target :: string(){target, "vcd"}
outputframesStop writing to the stream after framecount frames.[Stream :: string(), Framecount :: integer()] | Framecount :: integer(){frames, ["v", 1]}
outputqscaleUse fixed quality scale (VBR).[Stream :: string(), Quality :: integer()] | [Stream :: string(), Number :: integer(), Quality :: integer()] | Quality :: integer()
outputfilterCreate the filtergraph specified by filtergraph and use it to filter the stream.[Stream :: string(), Filtergraph :: string()]
outputfilter_script
outputpre
outputvframes
outputoutput_frame_rate
outputoutput_frame_size
outputaspect
outputno_video_recording
outputvcodec
outputpass
outputvlang
outputvideo_filtergraph
outputoutput_pixel_format
outputoutput_sws_flags
outputrc_override
outputtop
outputforce_key_frames
outputcopyinkf
outputaframes
outputoutput_audio_frequency
outputaudio_quality
outputoutput_audio_channels
outputno_audio_recording
outputoutput_acodec
outputsample_fmt
outputaudio_filtergraph
outputoutput_scodec
outputno_subtitle_recording
outputmap
outputmap_channel
outputmap_chapters
outputvsync
outputasync
outputcopytb
outputshortest
outputdts_delta_threshold
outputstreamid
outputbitstream_filters
outputtimecode
outputstrict
outputmetadata
outputdisable_video
outputdisable_audio
outputdisable_subtitle
outputx264_profile
outputx264_level
outputx264_refs
outputstart_number
outputhls_list_size
outputhls_key_info_file
outputhls_key_info[{key_uri, string()}, {enc_key, string() | file:filename_all()}, {iv, string()}]
outputhls_playlist_type
outputhls_segment_filename
outputhls_time

Video Thumbnails

To generate video thumbnails, VICE use ImageMagick

[®](http://tarr.uspto.gov/servlet/tarr?regser=serial&entry=78333969)

and FFmpeg. If you want to optimize output images, you must add image_optimizer in your project dependencies and install pngquand or OptiPNG.

Options

TypeNameDescriptionValueExample
globaleveryGenerate a thumbnail _every_ seconds.integer(){every, 6}
globalwidthThumbnail image width.integer(){width, 100}
globalout_pathOutput path.string() | binary(){out_path, "my_folder"}
globalassets_pathAssets path.string() | binary(){assets_path, "http://mysite.com/video/1/thumbnails"}
globalspriteGenerate a single image.true | false{sprite, true}

Audio

For audio conversion, VICE use SoX.

Options

TypeNameDescriptionValueExample
globalbuffer or input_bufferSet the size in bytes of the buffers used for processing audio (default 8192).Bytes :: integer(){buffer, 20000}
globalclobberDon’t prompt before overwriting an existing file with the same name as that given for the output file.true | false{clobber, false}
globalcombineSelect the input file combining method.concatenate | merge | mix | 'mix−power' | multiply | sequence{combine, concatenate}
globalno_ditherDisable automatic dither.true | false{no_dither, true}
globaleffects_fileUse File to obtain all effects and their arguments.File :: file:filename_all(){effects_file, "effects.data"}
globalguardAutomatically invoke the gain effect to guard against clipping.true | false{guard, true}
globalmagicIf SoX has been built with the optional libmagic library then this option can be given to enable its use in helping to detect audio file types.true | false{magic, true}
globalmulti_threadedBy default, SoX is single threaded. If the multi_threaded option is given however then SoX will process audio channels for most multi-channel effects in parallel on hyper-threading/multi-core architectures.true | false{multi_threaded, true}
globalsingle_threadedOpposite of the multi_threaded option.true | false{single_threaded, true}
globalnormAutomatically invoke the gain effect to guard against clipping and to normalise the audio.DBLevel :: integer() | true{norm, true}
globalplay_rate_argSelects a quality option to be used when the rate effect is automatically invoked whilst playing audio.Arg :: string()
globalplotIf not set to off (the default if plot is not given), run in a mode that can be used, in conjunction with the gnuplot program or the GNU Octave program, to assist with the selection and configuration of many of the transfer-function based effects.gnuplot | octave | off{plot, gnuplot}
globalrepeatableVICE will embed a fixed time-stamp in the output file (e.g. AIFF) and will seed pseudo random number generators (e.g. dither) with a fixed number, thus ensuring that successive SoX invocations with the same inputs and the same parameters yield the same output.true | false{repeatable, true}
globalreplay_gainSelect whether or not to apply replay-gain adjustment to input files.track | album | off{replay_gain, track}
globaltempSpecify that any temporary files should be created in the given Directory.Directory :: string(){temp, "/home/vice/tmp"}
inputignore_lengthOverride an (incorrect) audio length given in an audio file’s header.true | false{ignore_length, true}
inputvolumeIntended for use when combining multiple input files, this option adjusts the volume of the file that follows it on the command line by a factor of Factor.{volume, Factor :: float()}{volume, 0.8}
inputinput_bitsThe number of bits (a.k.a. bit-depth or sometimes word-length) in each encoded sample.Bytes :: integer(){input_bits, 8}
inputinput_channelsThe number of audio channels in the audio file.Channels :: integer(){input_channels, 2}}
inputinput_encodingThe audio encoding type.Encoding :: string(){input_encoding, "float"}
inputinput_rateGives the sample rate in Hz of the file.Rate :: integer(){input_rate, 48720}
inputinput_rate_kGives the sample rate in kHz of the file.KRate :: integer(){input_rate_k, 48}
inputinput_typeGives the type of the audio file.Filetype :: string(){input_type, "mp3"}
inputinput_endianSpecify the byte-order of the audio data.little | bug | swap{input_endian, little}
inputinput_reverse_nibblesSpecifies that the nibble ordering (i.e. the 2 halves of a byte) of the samples should be reversed.true | false{input_reverse_nibbles, true}
inputinput_reverse_bitsSpecifies that the bit ordering of the samples should be reversed.true | false{input_reverse_bits, true}
outputoutput_encodingThe audio encoding type.Encoding :: string(){output_encoding, "float"}
outputoutput_bitsThe number of bits (a.k.a. bit-depth or sometimes word-length) in each encoded sample.Bytes :: integer(){output_bits, 8}
outputoutput_channelsThe number of audio channels in the audio file.Channels :: integer(){output_channels, 2}}
outputoutput_rateGives the sample rate in Hz of the file.Rate :: integer(){output_rate, 48720}
outputoutput_rate_kGives the sample rate in kHz of the file.KRate :: integer(){output_rate_k, 48}
outputoutput_typeGives the type of the audio file.Filetype :: string(){output_type, "mp3"}
outputoutput_endianSpecify the byte-order of the audio data.little | bug | swap{output_endian, little}
outputoutput_reverse_nibblesSpecifies that the nibble ordering (i.e. the 2 halves of a byte) of the samples should be reversed.true | false{output_reverse_nibbles, true}
outputoutput_reverse_bitsSpecifies that the bit ordering of the samples should be reversed.true | false{output_reverse_bits, true}
outputadd_commentAppend a comment in the output file header (where applicable).Text :: string(){add_comment, "Encoded by VICE"}
outputcommentSpecify the comment text to store in the output file header (where applicable).Text :: string(){comment, "Encoded by VICE"}
outputcomment_fileSpecify a file containing the comment text to store in the output file header (where applicable).File :: file:filename_all(){comment_file, "/home/vice/comment.txt"}
outputcompressionThe compression factor for variably compressing output file formats.Factor :: integer(){compression, 2}
effectseffectsAudio effects to invoke (see Effects).Effects :: string(){effects, "chorus 0.7 0.9 55 0.4 0.25 2"}

Image

For image conversion, VICE use ImageMagick

[®](http://tarr.uspto.gov/servlet/tarr?regser=serial&entry=78333969)

.

Options

TypeNameDescriptionValueExample
convertresizeResize image{resize, P :: integer(), percent | pixel} | {resize, W :: integer(), H :: integer()} | {resize, W :: integer(), H :: integer(), percent | ignore_ration | no_enlarge | no_shrink | fill}{resize, 50, percent}
convertthumbnailCreate a thumbnail of the image. This is similar to resize, except it is optimized for speed and any image profile, other than a color profile, is removed to reduce the thumbnail size.{thumbnail, P :: integer(), percent | pixel} | {thumbnail, W :: integer(), H :: integer()} | {thumbnail, W :: integer(), H :: integer(), percent | ignore_ration | no_enlarge | no_shrink | fill}{thumbnail, 100, 100, no_enlarge}
convertquality
convertcropCut out a rectangular region of the image.{crop, W :: integer(), H :: integer(), X :: integer(), Y :: integer()} | {crop, W :: integer(), H :: integer()}{crop, 100, 80, 20, 30}
convertgravitySets the current gravity suggestion for various other settings and options. Choices include: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast{gravity, Gravity :: string()}{gravity, "SouthEast"}
convertrepage or '+repage'Adjust the canvas and offset information of the image-repage
convertflipCreate a mirror image-flip
converttrimTrim an image-trim
convertmagnifyDouble the size of the image with pixel art scaling-magnify
convertrotationApply Paeth image rotation (using shear operations) to the image{rotation, Degrees :: integer()}{rotation, 90}
convert'auto-orient'Adjusts an image so that its orientation is suitable for viewing-'auto-orient'
convertstripStrip the image of any profiles, comments or these PNG chunks: bKGD,cHRM,EXIF,gAMA,iCCP,iTXt,sRGB,tEXt,zCCP,zTXt,date.-strip
convertblurReduce image noise and reduce detail levels{blur, Radius :: integer()} | {blur, Radius :: integer(), Sigma :: integer()}{blur, 0, 8}
convertedgeDetect edges within an image{edge, Radius :: integer()}{edge 3}
convertsizeSet the width and height of the image{size, Width} | {size, Width :: integer(), Height :: integer()} | {size, Width :: integer(), Height :: integer(), Offset :: integer()}{size, 192, 128}
convertextentSet the image size and offset{extent, Width :: integer(), Height :: integer()}{extent, 384, 256}
mogrifygeometrySet the preferred size and location of the image.{geometry, Scale :: integer(), percent} | {geometry, Area :: integer(), pixels} | {geometry, ScaleX :: integer(), ScaleY :: integer(), percent} | {geometry, Width :: integer()} | {geometry, Width :: integer(), undefined} | {geometry, undefined, Height :: integer()} | {geometry, Width :: integer(), Height :: integer()} | {geometry, Width :: integer(), Height :: integer(), ignore_ration | no_enlarge | no_shrink | fill} | {geometry, Width :: integer(), Height :: integer(), X :: integer(), Y :: integer()}{geometry, 325, 192, 10, 10}
montagegeometrySet the preferred size and location of the image.{geometry, Scale :: integer(), percent} | {geometry, Area :: integer(), pixels} | {geometry, ScaleX :: integer(), ScaleY :: integer(), percent} | {geometry, Width :: integer()} | {geometry, Width :: integer(), undefined} | {geometry, undefined, Height :: integer()} | {geometry, Width :: integer(), Height :: integer()} | {geometry, Width :: integer(), Height :: integer(), ignore_ration | no_enlarge | no_shrink | fill} | {geometry, Width :: integer(), Height :: integer(), X :: integer(), Y :: integer()}{geometry, 10, percent}
montagetileSpecify the layout of images.{tile, Scale :: integer(), percent} | {tile, Area :: integer(), pixels} | {tile, ScaleX :: integer(), ScaleY :: integer(), percent} | {tile, Width :: integer()} | {tile, Width :: integer(), undefined} | {tile, undefined, Height :: integer()} | {tile, Width :: integer(), Height :: integer()} | {tile, Width :: integer(), Height :: integer(), ignore_ration | no_enlarge | no_shrink | fill} | {tile, Width :: integer(), Height :: integer(), X :: integer(), Y :: integer()}{tile, 234, 186, ignore_ration}

Licence

VICE is available for use under the following license, commonly known as the 3-clause (or "modified") BSD license:

Copyright (c) 2014-2015 Grégoire Lejeune<br /> Copyright (c) 2016 BotsUnit<br /> Copyright (c) 2017-2018 G-Corp<br />

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Modules

vice
vice_encoder
vice_subtitles
vice_thumbnails
## Contributors ## Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): | [
Gregoire Lejeune](http://lejeun.es)
[💻](https://github.com/G-Corp/vice/commits?author=glejeune "Code") [🎨](#design-glejeune "Design") [📖](https://github.com/G-Corp/vice/commits?author=glejeune "Documentation") [⚠️](https://github.com/G-Corp/vice/commits?author=glejeune "Tests") | [
Augustin G](https://github.com/agombault)
[💻](https://github.com/G-Corp/vice/commits?author=agombault "Code") [⚠️](https://github.com/G-Corp/vice/commits?author=agombault "Tests") | [
P](http://twitter.com/sulphur27)
[💻](https://github.com/G-Corp/vice/commits?author=sulphur "Code") [📖](https://github.com/G-Corp/vice/commits?author=sulphur "Documentation") | | :---: | :---: | :---: | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!