将byte []转换为视频(mp4或其他任何适用的格式) [英] Convert byte[] to Video (mp4 or any other palyable format)

本文介绍了将byte []转换为视频(mp4或其他任何适用的格式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个机器人,该机器人将记录Microsoft团队的实时会话.录音工作正常,但在生成视频文件时遇到问题.我要执行的过程是将视频数据转换为字节数组,然后将数据写入视频格式文件.

I am creating a bot that will record the Microsoft team live sessions. Audio recording is working fine but facing problems in generating the video file. The process I am following is that I am converting the video data into a byte array and then writing the data to a video format file.

到目前为止,我已经添加了一些代码段.

I am adding some code snippets, I have examined so far.

1. Stream videoStream = new FileStream(videoFilePath, FileMode.Create);
   BinaryWriter videoStreamWriter = new BinaryWriter(videoStream);
   videoStreamWriter.Write(videoBytesArray, 0, videoBytesArray.Length);
   videoStreamWriter.Close();

2. System.IO.File.WriteAllBytes(videoFilePath, videoBytesArray);

从以上代码段生成的文件格式不受支持.可能是因为从会话中接收到数据.

The generated files from the above code snippets are of an unsupported format. It may be because of the data receiving from the session.

我正在通过本地媒体会话的VideoMediaReceived事件(ICall.ILocalMediaSession.VideoSockets)上的视频套接字接收数据.套接字接收的数据的视频颜色格式为H264格式.

I am receiving the data through the Local media session's Video Socket on VideoMediaReceived Event (ICall.ILocalMediaSession.VideoSockets). The Video Color Format of the data that the socket is receiving is of H264 Format.

创建音频文件时遇到类似的问题.为此,我利用WaveFormat包来创建音频文件.

A similar problem I encountered when creating the audio file. For that, I utilized the WaveFormat package for creating an audio file.

那么,是否有任何库/方法可以将字节数组转换为任何格式的视频文件?

So, Is there any library/method to convert the byte array to a video file of any format?

推荐答案

@Murtaza,您可以尝试一下,看看是否有帮助.如果字节数组已经是视频流,则只需将其序列化为扩展名为mp4的磁盘即可.(如果是MP4编码的流).

@Murtaza, you can try this and see if it helps. If the byte array is already a video stream then, simply you can serialize it to the disk with the extension mp4. (If it's an MP4 encoded stream).

Stream t = new FileStream("video.mp4", FileMode.Create);
BinaryWriter b = new BinaryWriter(t);
b.Write(videoData);
t.Close();

这篇关于将byte []转换为视频(mp4或其他任何适用的格式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆