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;
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.
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.
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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With