0

Using Mp4Parser

when I try to add a watermark on video download from pixels it throws an error as below

2021-11-24 10:43:12.879 5748-5959/com.example.fastsaveapp E/Mp4Composer:

**This device cannot codec with that setting. Check width, height, bitrate, and video format.**

**android.media.MediaCodec$CodecException: Error 0xfffffc0e**
at android.media.MediaCodec.native_configure(Native Method)
at android.media.MediaCodec.configure(MediaCodec.java:1882)
at com.example.fastsaveapp.mp4compose.composer.VideoComposer.setUp(VideoComposer.java:78)
at com.example.fastsaveapp.mp4compose.composer.Mp4ComposerEngine.compose(Mp4ComposerEngine.java:198)
**at com.example.fastsaveapp.mp4compose.composer.Mp4Composer$2.run(Mp4Composer.java:319)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)**
at java.lang.Thread.run(Thread.java:761)

but video downloaded from youtube or from any Instagram video works like charm or from media gallery,

what can be done to add a watermark or encode video with such a high bitrate video like download from Pexels or so..

Mp4Composer(videoPath!!, getDestinationPath())
                .filter(GlWatermarkFilter(bitmap, getRepostWatermarkPosition()))
                .listener(object : Mp4Composer.Listener {
                    override fun onProgress(progress: Double) {
                        mainScoopLauncher {
                            loadStateEnable(true)
                            val progressValue = (progress * 100).toString()
                            val isUnder10Percentage = progressValue.take(2).contains(".")
                            val under10PercentageValue = "${progress * 100}".take(1) + "%"
                            val upto10PercentageValue = progressValue.take(2) + "%"
                            val loadValue =
                                if (isUnder10Percentage) under10PercentageValue else upto10PercentageValue
                            binding.txtPercentage.text = loadValue
                        }
                    }

                    override fun onCurrentWrittenVideoTime(timeUs: Long) {
                        mainScoopLauncher { loadStateEnable(true) }
                    }

                    override fun onCompleted() {
                        mainScoopLauncher {
                            loadStateEnable(false)
                            toast("Repost Video Complate")
                        }
                    }

                    override fun onCanceled() {
                        logger("cancelled")
                        mainScoopLauncher {
                            loadStateEnable(false)
                            toast("Repost Process Cancel..")
                        }
                    }

                    override fun onFailed(exception: Exception?) {
                        mainScoopLauncher {
                            loadStateEnable(false)
                            toast("Repost Process Failed..")
                        }
                    }
                }).start()
  • You should at least state what are the video specs/codecs you are trying to transcode. However if the format/size isn't in the [list of supported codecs](https://developer.android.com/guide/topics/media/media-formats#video-formats) then ffmpeg is the remaining option. – Morrison Chang Nov 24 '21 at 08:36
  • the bitrate of the video is 252kb frame width 3840 frame height 2160 total bitrate frame width 3840 audio sample rate 48000kHz the data rate is 2456kbps – Ravi Sorathiya Nov 24 '21 at 08:43
  • You can use VLC on PC to get details of the codec/profile of any breaking video file. That said, the [Android Compatibility Definition Document section on video encoding](https://source.android.com/compatibility/android-cdd#52_video_encoding) lists a number of 'SHOULD' which means optional support. – Morrison Chang Nov 24 '21 at 09:11
  • I have tested functionality on another device redmi note 4 and it works but when I try to encode the same video on another deice Lenovo K33a42 it doesn't work and throw the error as mentioned in my question. is it the device compatibilty isuue of MediaCodec Api? – Ravi Sorathiya Nov 24 '21 at 09:23
  • Lenovo K33a42 was released in 2016. Trying to decode/encode a UHD/4K on a low to midrange device of the time will be a poor experience as that model only required to support [Android CDD 6.0](https://source.android.com/compatibility/6.0/android-6.0-cdd) specification. – Morrison Chang Nov 24 '21 at 09:30
  • so, Are you trying to say that using mp4parser or FFMpeg is not a big deal because video encoding on midrange devices is not suitable whether you use mp4parser or FFmpeg? – Ravi Sorathiya Nov 24 '21 at 09:37
  • If you want to use built-in hardware the input formats/output formats have to be supported. If you want to transcode on device and want to use ffmpeg in order to support more codecs, more time will probably be taken and will still depend on hardware. A general rule is not to encode into or stream a video bigger than the device screen. – Morrison Chang Nov 24 '21 at 09:47

0 Answers0