This commit is contained in:
Luke 2020-01-14 10:36:38 +08:00
parent 9cdbe4c4ef
commit 2d9537ec84

View File

@ -34,6 +34,7 @@ namespace FFmpeg {
#define FFmpeg_FIELD "ffmpeg." #define FFmpeg_FIELD "ffmpeg."
const string kBin = FFmpeg_FIELD"bin"; const string kBin = FFmpeg_FIELD"bin";
const string kCmd = FFmpeg_FIELD"cmd"; const string kCmd = FFmpeg_FIELD"cmd";
const string kSnap = FFmpeg_FIELD"snap";
const string kLog = FFmpeg_FIELD"log"; const string kLog = FFmpeg_FIELD"log";
onceToken token([]() { onceToken token([]() {
@ -41,9 +42,12 @@ onceToken token([]() {
string ffmpeg_bin = System::execute("where ffmpeg"); string ffmpeg_bin = System::execute("where ffmpeg");
//windows下先关闭FFmpeg日志(目前不支持日志重定向) //windows下先关闭FFmpeg日志(目前不支持日志重定向)
mINI::Instance()[kCmd] = "%s -re -i \"%s\" -loglevel quiet -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s "; mINI::Instance()[kCmd] = "%s -re -i \"%s\" -loglevel quiet -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s ";
//利用ffmpeg进行抓拍
mINI::Instance()[kSnap] = "%s -i \"%s\" -loglevel quiet -y -f mjpeg -t 0.001 -s 720*576 %s "
#else #else
string ffmpeg_bin = System::execute("which ffmpeg"); string ffmpeg_bin = System::execute("which ffmpeg");
mINI::Instance()[kCmd] = "%s -re -i \"%s\" -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s "; mINI::Instance()[kCmd] = "%s -re -i \"%s\" -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s ";
mINI::Instance()[kSnap] = "%s -i \"%s\" -y -f mjpeg -t 0.001 -s 720*576 %s "
#endif #endif
//默认ffmpeg命令路径为环境变量中路径 //默认ffmpeg命令路径为环境变量中路径
mINI::Instance()[kBin] = ffmpeg_bin.empty() ? "ffmpeg" : ffmpeg_bin; mINI::Instance()[kBin] = ffmpeg_bin.empty() ? "ffmpeg" : ffmpeg_bin;
@ -64,6 +68,7 @@ FFmpegSource::~FFmpegSource() {
void FFmpegSource::play(const string &src_url,const string &dst_url,int timeout_ms,const onPlay &cb) { void FFmpegSource::play(const string &src_url,const string &dst_url,int timeout_ms,const onPlay &cb) {
GET_CONFIG(string,ffmpeg_bin,FFmpeg::kBin); GET_CONFIG(string,ffmpeg_bin,FFmpeg::kBin);
GET_CONFIG(string,ffmpeg_cmd,FFmpeg::kCmd); GET_CONFIG(string,ffmpeg_cmd,FFmpeg::kCmd);
GET_CONFIG(string, ffmpeg_snap, FFmpeg::kSnap);
GET_CONFIG(string,ffmpeg_log,FFmpeg::kLog); GET_CONFIG(string,ffmpeg_log,FFmpeg::kLog);
_src_url = src_url; _src_url = src_url;