build complex ffmpeg command easier
A simple ffmpeg command line untility, make ffmpeg command easier
use FFmpeg::Syntax::Builder;
my $ffmpeg_builder = FFmpeg::Syntax::Builder->new();
$ffmpeg_builder->add_input(stdin); # you can assign your sid_port and sid_mode
$ffmpeg_builder->add_input(udp => {url => "udp://ip"});
$ffmpeg_builder->add_input(ip => {rtmp => "rtmp://ip"});
$ffmpeg_builder->add_input(file => {filepath => $local_file_path});
$ffmpeg_builder->add_input(watermark => {filepath => '/tmp/xxx.jpeg'});
$ffmpeg_builder->add_vf_split(udp => {channel_id => $channel_id}); # [0:p:$channel_id:0]
$ffmpeg_builder->add_vf_split(ip => {channel_id => $channel_id}); # [$channel_id:0]
$ffmpeg_builder->add_vf_split(watermark => {water_positon => 'top_left'})
$ffmpeg_builder->add_vf_split('format');
$ffmpeg_builder->add_vf_split(deinterlace => $deinterlace);
$ffmpeg_builder->add_vf_split(output_count => $output_count);
$ffmpeg_builder->add_vf('fps' => $fps);
$ffmpeg_builder->add_vf('scale' => {width => $width, height => $height});
$ffmpeg_builder->add_vf(vf => $vf_string);
$ffmpeg_builder->add_vf( 'drawtext' => {
fontfile => '/data1/sue/rc/san_serif.ttf',
logo_text => $logo_text,
fontsize => $o_fontsize });
$ffmpeg_builder->add_vf(dar => {width => $width, height => $height} );
$ffmpeg_builder->add_vf('output_tag');
$ffmpeg_builder->add_vf_split(udp => {channel_id => $channel_id}); # [0:p:$channel_id:0]
$ffmpeg_builder->add_vf_split(ip => {channel_id => $channel_id}); # [$channel_id:0]
$ffmpeg_builder->add_af('mono');
$ffmpeg_builder->add_af('volume');
$ffmpeg_builder->add_af('async');
$ffmpeg_builder->add_af(audio_delay => {audio_delay_msecs => 15});
$ffmpeg_builder->add_af(output_count => 1);
$ffmpeg_builder->add_output(codec_video => {x264opts => $x264opts});
$ffmpeg_builder->add_output('vsync' => { vsync_mode => 2 });
$ffmpeg_builder->add_output('codec_audio' => { abitrate => "libfdk_aac -b:a 16k" });
$ffmpeg_builder->add_output('rtmp' => { url => $rtmp_url });
$ffmpeg_builder->add_output('rtmp' => { url => $rtsp_url });
$ffmpeg_builder->log_output(logpath => '/tmp', logname => 'test')
$ffmpeg_builder->run();
Assgin the input type which you want
When you have multiple outputs, you must split multiple outpus
Assgin the codec videu
Assgin the codec audio
Assgin the output type which you want
Print ffmpeg command output to logfile
Run the command
Thanks for ChenGang. Written by WayneZhou, cumtxhzyyatgmail.com
Copyright (c) 2015 WayneZhou. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.