Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transcode video to lower bitrate and stream

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?
like image 966
ingsaurabh Avatar asked Aug 07 '16 04:08

ingsaurabh


People also ask

Does transcoding video reduce quality?

Namely, they remove extraneous data from the video feed to reduce file size while maintaining as high-quality video as possible. Technically speaking, video transcoding refers to the process of taking an existing video file (or ongoing stream) and re-encoding it with a different codec or different settings.

Does transcoding reduce quality?

The key drawback of transcoding in lossy formats is decreased quality. Compression artifacts are cumulative, so transcoding causes a progressive loss of quality with each successive generation, known as digital generation loss. For this reason, transcoding (in lossy formats) is generally discouraged unless unavoidable.

What is transcoding bitrate?

Transcoding is the process of taking an already encoded digital media file and unencoding it to change the file's size (transize) or bitrate (transrate). This is often done to maximize the number of compatible playback devices, making the encoded data more accessible to a wider audience.


1 Answers

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.

like image 141
murielK Avatar answered Nov 09 '22 00:11

murielK