7

I have a working app that streams video to Chromecast(using nannoHttpd) and everything is working fine. Now my problem is: videos recorded using new devices are too large in size to stream, so I want to re-encode videos to some lower bitrate.

I tried ffmpeg but the results are not satisfactory and it will increase the apk size by 14 MB.

Now I am trying the MediaCodec api. It is faster than ffmpeg, but it takes the input file and writes it to the output file and I want to re-encode byte data that is to be served by nannohttpd.

Now a solution comes to my mind, that is to transcode the video and stream the output file but its has two drawbacks;

  1. What if the file is too large and the user doesn't see the whole video? Much of CPU, battery resource is wasted.
  2. What if the user fast forwards a long video to a time which is not re-encoded yet?
Setily
  • 814
  • 1
  • 9
  • 21
ingsaurabh
  • 15,249
  • 7
  • 52
  • 81

1 Answers1

1

1 MediaCodec just do one thing decode encode! and you will get raw bytes of new encoded data. So it is up to the programmer to choose to either dump that into a container (.mp4 file) using a muxer. So no need here to rewrite everything back into a file.

2 Seek to the proper chunk of data and restart MediaCodec.

murielK
  • 1,000
  • 1
  • 10
  • 21