Migz
Migz

Reputation: 145

Xamarin Android C# Video resizing

I need to send a video to the server. Video sizes differ randomly, some can be a Meg and others can be 900Mb.. How does one resize a video to a smaller size?

I can get iOS examples but have not found any Android versions.

Upvotes: 1

Views: 1868

Answers (1)

SushiHangover
SushiHangover

Reputation: 74184

A lot of it depends upon what you mean by making it smaller:

  • Trimming the length (running time) of the video
  • Changing the playback rate (FPS)
  • Resizing to a smaller resolution
  • Changing the bitrate to a lower one
  • Re-compressing/transcoding the video using a different codec or the same codec but using a higher compression ratio.

Android's MediaCodec library can change a number of things, but does not give the user a lot of options on "how" it does it:

  • Resolutions 1080P, 720P, 480P, 360P, QVGA, QCIF
  • BitRates 2Mbps, 1Mbps, 500Kbps, 56Kbps
  • FrameRates = 30fps. 15fps
  • FrameIntervals = 1, 5, 10

(that is just a quick sampling of MediaCodec's ability)

MediaCodec Usage:

The way you use the Android MediaCodec for "transcoding" is use the Decoder to process the original video (off screen), pass those frames to the Encoder (using different encoding options then the original) and save the results to file...

The most popular method for video resizing/transcoding/etc... on Android seems to be using ffmpeg due to the large number of options available and how well known that application is.

There Java wrappers (and a couple of C# wrappers) available for Android, I have only used the Java based ones via a Binding project. (Google is your friend for finding these).

There is a bunch of licensing "issues" in using FFmpeg and you should review their license:

FFmpeg License and Legal Considerations

Upvotes: 4

Related Questions