Transcoding Audio/Video/Image file in Android Device
Asked Answered
D

2

10

I am working on a chat application like whatsApp, I want to transcode media file before uploading to server,I have gone through so many links but not able to decide which method i should use, is there any straight forward way of transcoding in android ?

  • FFMPEG i found it is highly cpu intensive process ,it will consume more battery power

  • Media Codec i want to do the transcoding using mediacodec but not able to get proper steps to understand the process.

Best link to give idea about transcoding

Library to transcode using media codec (It has many bugs)

Doloresdolorimetry answered 28/9, 2016 at 16:19 Comment(0)
S
2

We used both implementation for our video editing app. Basically we used MediaCodec implementation if android version >= 4.3 and use FFMPEG otherwise.

The problem with using FFMPEG:

  1. As you said, cpu intensive process thus consume more battery
  2. x264 encoder is licensed under GPL, so you might want to use OpenH264 encoder instead which only support Baseline Profile, therefore video quality is not the best
  3. Since it used software encoder, processing speed is relatively slow, at least compared to the MediaCodec implementation

MediaCodec also have some cons though, for example:

  1. If you want to do transcoding, android version need to be >= 4.3 unless you want to deal with color format conversion yourself, which is completely mess, since each vendor may have it's own color format implementation. (Since 4.3, MediaCodec support encoding using input surface)
  2. Hardware encoder may behave differently for different models. (For example some encoder may produces B frames which is not supported yet by android MediaMuxer, so you may want to use ffmpeg for the muxing part)

So I should say if you only support new android version, you should use mediacodec, but if you want to be safe (easier to write code that works on all device) and does not really mind the performance, use FFMPEG with OpenH264

Shupe answered 10/10, 2016 at 8:8 Comment(0)
S
0

Android's MediaCodec is a relatively better way to transcode on the client since it uses its own low level buffer processing. But then it doesn't provide elaborate tweaking freedom as FFMpeg does. As to MediaCodec source code, it also is CPU intensive for holding the buffers and processing them but its actually way lesser than FFmpeg.

Sunbreak answered 8/10, 2016 at 18:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.