语境
我在我的 .NET Core API 项目中使用FFMpegCore,该项目接收一个.h264
文件(以二进制格式发送,接收并转换为 a byte array
)以转换为.ts
.
我想使用 FFmpeg将.h264
流转换为输出流。.ts
当前方法
(...)
byte[] body;
using ( var ms = new MemoryStream() )
{
await request.Body.CopyToAsync( ms ); // read sent .h264 data
body = ms.ToArray();
}
var outputStream = new MemoryStream();
// FFMpegCore
await FFMpegArguments
.FromPipeInput( new StreamPipeSource( new MemoryStream( body ) ) )
.OutputToPipe( new StreamPipeSink( outputStream ), options => options
.ForceFormat( VideoType.MpegTs ) )
.ProcessAsynchronously();
// view converted ts file
await File.WriteAllBytesAsync( "output.ts", outputStream.ToArray() );
(...)
问题
我没有得到工作.ts
文件。我做错了什么?你能给我一些提示或帮助我吗?即使您有其他您认为更适合此问题的 FFmpeg 包装器。
笔记:
- 我没有文件的物理位置,因为这将通过 HTTP 接收文件的内容。因此,我将只有字节数组,这意味着我需要使用输入流转换为另一种格式。
- FFmpeg 命令用于测试从
.h264
到的转换.ts
(使用文件):ffmpeg -i file.h264 -an -vcodec copy -f mpegts output.ts