element-hq / riot-android

A glossy Matrix collaboration client for Android
Apache License 2.0
1.4k stars 393 forks source link

Option to recompress video before sending to save size #73

Open matrixbot opened 8 years ago

matrixbot commented 8 years ago

Created by @ matthew:matrix.org.

Surely Android gives us APIs for this these days?

ylecollen commented 8 years ago

I have had a play with https://github.com/lalongooo/VideoCompressor https://github.com/hoolrory/AndroidVideoSamples

It seems that only the video can resized (not the sound). It is good but i've one device (on my 5 devices set) which did not work properly while trying to resize the same video. The compression is an hardware one so it will depends in the mobile phone.

Zjemm commented 6 years ago

Im wondering how telegram does this. Is it on the phone or in the server

But this is indeed a needed feature

rkfg commented 6 years ago

It's only reasonable to do on the client because you'll most likely send the video via mobile network and need to care about the size. There are two options, basically:

  1. use MediaCodec from the Android framework itself;
  2. add ffmpeg or separate native libraries for h264/vp8/vp9 + ogg/aac + mp4/mkv/webm and do the same with JNI or such.

The first option is probably better as it doesn't increase the build size, is kinda standard and doesn't require native libs. However, if it doesn't work on at least one device out of 5, it's bad already (maybe the library is poorly written, who knows). The second option might work on every device but could be harder to support. I'd say, if you don't write a game or a very specific software it's better not to use native libs.

I'd love to have this feature as my native cam app produces huge files like 126 Mb for 1 minute (17 Mbit/s) and in Riot I have no video settings if using the native cam, the resulting file is compact but of low quality and blurry.