简体   繁体   English

如何在Xamarin中压缩来自PCL的视频

[英]How to compress video from a PCL in Xamarin

I´m doing a "Whatsapp" like app and I need to send user videos (from camera/gallery). 我正在做类似应用程序的“ Whatsapp”,我需要发送用户视频(来自相机/画廊)。

I need to send video from ios to android and from android to ios (windows phone in the future). 我需要将视频从ios发送到android,再从android发送到ios(以后将是Windows Phone)。

First thing I thought is to use camera params to record the video in low resolution, but that won´t help with recorded videos stored in the phone already. 我首先想到的是使用相机参数以低分辨率录制视频,但这对已经存储在手机中的录制视频没有帮助。

Second thought was to zip the video file, but I guess this is not enough for very large files. 第二个想法是压缩视频文件,但是我想这对于非常大的文件是不够的。

Third: actually compressing the video file generating a new file, and then zip it before sending it through the network. 第三:实际压缩视频文件以生成新文件,然后将其压缩,然后再通过网络发送。

So this is what I need before actually sending the video: 所以这是我实际发送视频之前需要的:

  1. Compress the video file, generating a new file that will play nicely in both platforms (ios and android) 压缩视频文件,生成一个可以在两种平台(ios和android)上正常播放的新文件
  2. Make the compressing process aysnc(as I don´t want to block the UI thread for a really long time) 使压缩过程aysnc(因为我不想长时间阻止UI线程)
  3. Zip it (this is the easy part, just for the record) 压缩(这是简单的部分,仅供记录)

Any ideas or help are appreciated 任何想法或帮助表示赞赏

  1. You would best need to use your platforms framework to also leverage existing hardware support for encoding (mainly h.264 hardware encoding). 您最好使用平台框架来利用现有的硬件支持进行编码(主要是h.264硬件编码)。 A PCL solution would eat to much battery as it would need to run on CPU only giving you bad performance and even worst battery live. PCL解决方案会消耗大量电池,因为它需要在CPU上运行,这只会给您带来不良的性能,甚至会延长电池的使用寿命。

  2. This ties in with 1. Just use your platforms native method to execute the frameworks methods async. 这与1相关联。只需使用平台的本机方法来异步执行框架方法。

  3. Skip this part. 跳过这一部分。 It will increase overhead and disallow video streaming There are virtually 0 benefits from using a zip algorithm on top of an already compressed video stream. 这将增加开销并禁止视频流传输。在已经压缩的视频流之上使用zip算法实际上带来了0好处。

Just make sure that you end up with a cross platform compatible video format like H264. 只要确保您最终获得兼容H264的跨平台视频格式即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM