% @version 0.0.1 % % @doc % Generic encoder behavior % %

Create an encoder

% % Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam et felis % ornare, scelerisque velit vitae, pretium ante. Class aptent taciti sociosqu % ad litora torquent per conubia nostra, per inceptos himenaeos. % % To create a custom encoder, juste create a new module followinf this behavior. % %

init/0

% % The init/0 function is called to initialize the encoder. This function % must return a tuple : % % % % To help you create the initializer, VICE offer you the vice_utils:find_tools/2 % function. This function take a liste of executables (as a list of atoms) and an atom, % as parameters. % % In case of success, this function will return a tuple % {state, List :: list(tuple())}. In the list of tuple, the first element of each % tuple is the input executable (atom) and the second element is the string to the % executable path. % % Example : % %
% vice_utils:find_tools([ffmpeg, ffprobe], video).
% % => {state, [{ffmpeg, "/usr/bin/ffmpeg"}, {ffprobe, "/usr/bin/ffprobe"}]}
% 
% % The second parameter for vice_utils:find_tools/2 allow you to add % an alternative configurtion. In the above example, if VICE can't find % ffprobe for example, using this second parameter, it will this to find an % alternative path in the configuration. For example, if you put something like that % in your .config file : % %
% {video, [
%   {ffprobe, "/opt/ffmpeg/bin/ffprobe"}
% ]}
% 
% % So, vice_utils:find_tools([ffmpeg, ffprobe], video) will return % {state, [{ffmpeg, "/usr/bin/ffmpeg"}, {ffprobe, "/opt/ffmpeg/bin/ffprobe"}]}. % % If vice_utils:find_tools/2 can't find (at least) one executable, it will return % an error : {error, {App :: atom(), not_found}}. % %
% For now, VICE only support encoder using command line tools. %
% %

infos/3

% %

info/4

% %

command/5

% %

progress/2

% %

Use you own encoder

% % To determine which encoder to use, VICE use the type (from mimetype) of the % input file. % % The encoders are declared in the vice/encoders section of % the configuration. The default configration is the following : % %
% {vice, [
%   ...
%   {encoders, [
%     {video, [vice_prv_ffmpeg]},
%     {image, [vice_prv_imagemagick]},
%     {audio, [vice_prv_sox]}
%   ]},
%   ...
% }
% 
% % So if you create a new audio encoder, you must add it to the % audio list : % %
% {vice, [
%   ...
%   {encoders, [
%     {audio, [my_custom_audio_encoder, vice_prv_sox]}
%   ]},
%   ...
% }
% 
% % In such case, VICE will try to load my_custom_audio_encoder. % If my_custom_audio_encoder:init/0 return {ok, State :: term()} % it will not try to load vice_prv_sox. So my_custom_audio_encoder % will be used for all audio encoding. If my_custom_audio_encoder:init/0 % return {error, Reason :: term()} VICE will try to load % vice_prv_sox and if it succed, vice_prv_sox will be used for % all audio encoding ; if not, VICE will not allow you to encode audio files. % %
% When you change the configuration, if you do not specified a list of encoders for % a type, VICE will use its default list for this type. %
% @end -module(vice_encoder). -type sofar() :: {Duration :: float(), Time :: float(), Percent :: float()}. -callback init() -> {ok, State :: term()} | {stop, Reason :: term()}. -callback infos(State :: term(), File :: file:filename_all(), Options :: list()) -> {ok, Result :: map()} | {error, Reason :: term()}. -callback info(State :: term(), File :: file:filename_all(), Info :: atom(), Options :: list()) -> {ok, Result :: term()} | {error, Reason :: term()}. -callback command(State :: term(), In :: file:filename_all(), Out :: file:filename_all(), Options :: list(), Multi :: true | false) -> {ok, Command :: string()} | {error, Reason :: term()}. -callback progress(Bytes :: string(), Sofar :: sofar()) -> Sofar0 :: sofar().