question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Video doesn't play on iOS or Mac after compress

See original GitHub issue

I am using this library for one of my project and I discover one issue when i compress video using this library and try to play on iPhone or Safari browser.

Original video: https://drive.google.com/file/d/1MXmwkjxB8WKX6_Rf78JXZ1E6W4yg639a/view?usp=sharing Compressed video: https://drive.google.com/file/d/1zdX8gUgrEoGttWifHh_2JZP3hZqncSq7/view?usp=sharing

When we try to play this video in quick time player, It showing following error alert:

image

  • LightCompressor version: 0.7.8
  • Device: Nokia 6.1 Plus - 10.0
  • Code:
val sourceFile = File(video.url)
val destinationFile =
    File(context.cacheDir.absolutePath + "/" + sourceFile.name)

VideoCompressor.start(
    srcPath = sourceFile.path,
    destPath = destinationFile.path,
    quality = VideoQuality.HIGH,
    isMinBitRateEnabled = false,
    listener = object : CompressionListener {
        override fun onCancelled() {
            if (isCancelled) return
            isCancelled = true
            emitter.onError(UnknownErrorException("Video compression process cancelled"))
            emitter.onComplete()
        }

        override fun onFailure(failureMessage: String) {
            VideoCompressor.cancel()
            if (isCancelled) return
            isCancelled = true
            emitter.onError(UnknownErrorException(failureMessage))
            emitter.onComplete()
        }

        override fun onProgress(percent: Float) {
            //Do nothing
        }

        override fun onStart() {
            //Do nothing
        }

        override fun onSuccess() {
            if (isCancelled) return
            compressedVideoMediaList.add(Video(destinationFile.path))
            if (videoMediaList.size == compressedVideoMediaList.size) {
                emitter.onNext(compressedVideoMediaList.toList())
                emitter.onComplete()
            }
        }

    },
)

@AbedElazizShe Can you please help me here to figure out this issue? Let me know if you need any other details from my end.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AbedElazizShecommented, Mar 28, 2021

Issue fixed in version 0.8.1. Please let me know if you still have the issue. You can close the task if the problem is solved.

0reactions
ashotterekyanlmccommented, Dec 10, 2021

Still didn’t work on version 1.0.0. Replaced line

val encoder = if (hasQTI) { MediaCodec.createByCodecName(“c2.android.avc.encoder”) } else { MediaCodec.createEncoderByType(MIME_TYPE) }

with val encoder = MediaCodec.createEncoderByType(MIME_TYPE)

now all is good

Read more comments on GitHub >

github_iconTop Results From Across the Web

If an audio or video file doesn't play on Mac - Apple Support
If an audio or video file doesn't play on Mac. Older or specialized media formats might require other software. Apple apps such as...
Read more >
How to Fix HD/4K Videos Won't Play on iPhone (14 or 13)
This guide offers solutions when iPhone won't play 4K/HD videos whether they are from camera roll, Facebook, Safari, Mac, Windows, GoPro, ...
Read more >
What's the best way to compress videos on Mac? - Setapp
Compare a few apps that can compress a video on Mac and reduce video size, ... Compress, crop, convert, play, and edit videos...
Read more >
All the Best Ways to Compress Videos on a Mac - MacKeeper
Compressing videos using QuickTime Player · Launch QuickTime Player · Use the file browser to select the video you want to compress ·...
Read more >
How to reduce video size (compress video) on Mac - MacPaw
Since a video is just a series of photos rapidly playing in succession, ... reducing video file size on Mac doesn't have to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found