在YouTube上直播时,FFMPEG处于永无止境的状态

问题描述 投票:0回答:1

我一直在AS3工作,在YouTube上播放1080P视频,视频开始上传,大约4-5分钟的视频已成功上传,之后YouTube显示流已结束,但FFMPEG永远不会点击“退出”或任何其他方法,即使在等待下一个10分钟后。

以下是我正在使用的方法。

public var _nativeProcessStartupInfo:NativeProcessStartupInfo;
public var _processArgs:Vector.<String>;
public var _process:NativeProcess;
protected function StartVideo_clickHandler(event:MouseEvent):void
{
    _nativeProcessStartupInfo.executable = File.applicationStorageDirectory.resolvePath("ffmpeg.exe Path");
    _processArgs.push('-re');
    _processArgs.push('-i');
    _processArgs.push(VideoPath);
    _processArgs.push('-vcodec');
    _processArgs.push('copy');
    _processArgs.push('-acodec');
    _processArgs.push('copy');
    _processArgs.push('-maxrate');
    _processArgs.push('4500k');
    _processArgs.push('-bufsize');
    _processArgs.push('9000k');
    _processArgs.push('-pix_fmt'); 
    _processArgs.push('yuv422p');
    _processArgs.push('-preset');
    _processArgs.push('fast');
    _processArgs.push('-ac'); 
    _processArgs.push('2');
    _processArgs.push('-r'); 
    _processArgs.push('30');                            
    _processArgs.push('-g');
    _processArgs.push('60');                            
    _processArgs.push('-ar');
    _processArgs.push('44100');
    _processArgs.push('-f');
    _processArgs.push('flv');                   
    _processArgs.push(streamurl+'/'+streamname);
    _nativeProcessStartupInfo.arguments = _processArgs;
    _process = new NativeProcess();
    _process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
    _process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, progress);
    _process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
    _process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOErrorNativeProcess);
    _process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOErrorNativeProcess);
    _process.start(_nativeProcessStartupInfo);
}
public function onIOErrorNativeProcess(event:IOErrorEvent):void
{
    trace(event.toString());
}
public function onOutputData(event:ProgressEvent):void
{
    trace("Got: ", _process.standardOutput.readUTFBytes(_process.standardOutput.bytesAvailable)); 
}
public function progress(e:ProgressEvent):void 
{
    trace(e);
}
public function onExit(e:NativeProcessExitEvent):void
{
    trace(e);
}

我已尝试使用720P视频,将比特率从4500k更改为2500k,这是根据YouTube,它工作正常,但1080P的东西并没有按照预期进行。

以下是视频详情:分辨率:1920 * 1080数据速率:3220kbps FrameRate:20 Video Description

提前致谢

actionscript-3 ffmpeg youtube encode
1个回答
2
投票

以下代码存在两个问题。

  1. 在“进度”功能中我没有读取FFMPEG的实际日志,必须更新如下的进度事件。 public function progress(e:ProgressEvent):void { trace("Progress: ", _process.standardOutput.readUTFBytes(_process.standardOutput.bytesAvailable)); }
  2. 现在我刚刚跟踪了日志,并且在创建构建问题之后代码在调试模式下正常工作,之后我将所有数据记录在文件中,然后甚至在创建构建之后一切正常。

我不知道它背后的确切原因,但这个解决方案现在帮助我。

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.