xleon xleon - 10 days ago 6
Android Question

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).

I need to send video from ios to android and from android to ios (windows phone in the future).

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)

  2. Make the compressing process aysnc(as I don´t want to block the UI
    thread for a really long time)

  3. Zip it (this is the easy part, just for the record)



Any ideas or help are appreciated

Answer
  1. You would best need to use your platforms framework to also leverage existing hardware support for encoding (mainly h.264 hardware encoding). 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.

  2. This ties in with 1. Just use your platforms native method to execute the frameworks methods async.

  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.

Just make sure that you end up with a cross platform compatible video format like H264.