Git Product home page Git Product logo

bitmp4's People

Contributors

dbof10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bitmp4's Issues

COLOR_FormatYUV420SemiPlanar throws MediaCodec$CodecException: Error 0x80001001

Hi,

I am since yesterday trying to make your great library work. However, it shows the error on title. If i change to COLOR_FormatSurface, it throws IllegalStateException in native_dequeueOutputBuffer.

I'm testing in an old ZTE device with Android 5.0. Which device did you test this library?

Do you have any clues on how to fix this?

thanks

guich

E/AndroidRuntime: FATAL EXCEPTION

I get a fatal error when trying to run this:

        val encoder=MP4Encoder().apply{
            setFrameDelay(50)
            setOutputFilePath(getVideoFile(baseDir).path)  // Comes from File(baseDir.getExternalFilesDir(null) + "/XXXX.mp4")
            val firstbmp: Bitmap = ... // (A 68x68 bitmap)
            setOutputSize(firstbmp.width, firstbmp.height). // It's 68x68 pixels
        }
        encoder.startEncode()  // <--- This live throws error
E/AndroidRuntime: FATAL EXCEPTION: Thread-260
    Process: com.dji.videostreamdecodingsample, PID: 14942
    android.media.MediaCodec$CodecException: Error 0xfffffc0e
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:2127)
        at android.media.MediaCodec.configure(MediaCodec.java:2043)
        at com.ctech.bitmp4.MP4Encoder.onStart(MP4Encoder.java:67)
        at com.ctech.bitmp4.Encoder.startEncode(Encoder.java:107)
        at com.dji.videostreamdecodingsample.DetectionRecord.saveVideoFile(DetectionRecord.kt:144)

Export and Stop buttons not working

When I press Export button it produces the below error:

E/C2AllocatorIon: >>>SEC mapUsage Mapper1 1
E/ion: ioctl c0044901 failed with code -1: Not a typewriter
E/C2AllocatorIon: >>>SEC mapUsage	0, 1
E/AndroidRuntime: FATAL EXCEPTION: EncodeThread
    Process: com.ctech.bitmp4.sample, PID: 16545
    java.nio.BufferOverflowException
        at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:298)
        at java.nio.ByteBuffer.put(ByteBuffer.java:732)
        at com.ctech.bitmp4.MP4Encoder.onAddFrame(MP4Encoder.java:138)
        at com.ctech.bitmp4.Encoder$1.run(Encoder.java:40)
        at java.lang.Thread.run(Thread.java:919)

When I press Stop button it produces the below error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ctech.bitmp4.sample, PID: 16924
    kotlin.UninitializedPropertyAccessException: lateinit property exportDisposable has not been initialized
        at com.ctech.bitmp4.sample.MainActivity.stopExport(MainActivity.kt:113)
        at com.ctech.bitmp4.sample.MainActivity.access$stopExport(MainActivity.kt:24)
        at com.ctech.bitmp4.sample.MainActivity$onCreate$2.onClick(MainActivity.kt:83)
        at android.view.View.performClick(View.java:7862)
        at android.widget.TextView.performClick(TextView.java:15004)
        at android.view.View.performClickInternal(View.java:7831)
        at android.view.View.access$3600(View.java:879)
        at android.view.View$PerformClick.run(View.java:29359)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

java.nio.BufferOverflowException

Hello, i tried running your sample on my phone and it crashes with the below error

2021-02-25 02:20:04.190 14686-14686/? E/h.bitmp4.sampl: Unknown bits set in runtime_flags: 0x8000
2021-02-25 02:20:08.123 14686-14756/com.ctech.bitmp4.sample E/ion: ioctl c0044901 failed with code -1: Invalid argument
2021-02-25 02:20:08.123 14686-14756/com.ctech.bitmp4.sample E/C2AllocatorIon: >>>SEC C2AllocatorIon::mapUsage ion_is_legacy++++++++
2021-02-25 02:20:08.123 14686-14756/com.ctech.bitmp4.sample E/C2AllocatorIon: >>>SEC mapUsage 0, 2000000
2021-02-25 02:20:08.321 14686-14761/com.ctech.bitmp4.sample E/AndroidRuntime: FATAL EXCEPTION: EncodeThread
Process: com.ctech.bitmp4.sample, PID: 14686
java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:298)
at java.nio.ByteBuffer.put(ByteBuffer.java:732)
at com.ctech.bitmp4.MP4Encoder.onAddFrame(MP4Encoder.java:138)
at com.ctech.bitmp4.Encoder$1.run(Encoder.java:40)
at java.lang.Thread.run(Thread.java:919)

bitmap4 error

FATAL EXCEPTION: EncodeThread

When using the library I get the exception:

2022-06-20 14:55:08.688 28013-28522/xxxxxxxxxx E/AndroidRuntime: FATAL EXCEPTION: EncodeThread
Process: com.xxxxxxxxx, PID: 28013
java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:298)
at java.nio.ByteBuffer.put(ByteBuffer.java:732)
at com.ctech.bitmp4.MP4Encoder.onAddFrame(MP4Encoder.java:138)
at com.ctech.bitmp4.Encoder$1.run(Encoder.java:40)
at java.lang.Thread.run(Thread.java:920)

Code:
Init:
file = new File(SportUpApplication.getAppContext().getExternalFilesDir(null), "export.mp4");
mp4Encoder=new MP4Encoder();
mp4Encoder.setFrameDelay(20);
mp4Encoder.setOutputFilePath(file.getPath());
mp4Encoder.setOutputSize(640, 360);
mp4Encoder.startEncode();

Loop:
.....
bitmap=Bitmap.createScaledBitmap(bitmap, 640, 360, true);
mp4Encoder.addFrame(bitmap);
.....

End:
mp4Encoder.stopEncode();

What am I doing wrong?

Video is corrupted and green

Hello. I am not sure what I am doing wrong here. The below method is what I use to get the bitmap from a custom SurfaceView class:

private fun getSnapshot(): Bitmap? {
    val surfaceBitmap = Bitmap.createBitmap(800, 600, Bitmap.Config.ARGB_8888)
    val lock = Object()
    val success = AtomicBoolean(false)
    val thread = HandlerThread("PixelCopyHelper")
    thread.start()
    val sHandler = Handler(thread.looper)
    val listener = PixelCopy.OnPixelCopyFinishedListener { copyResult ->
        success.set(copyResult == PixelCopy.SUCCESS)
        synchronized (lock) {
            lock.notify()
        }
    }
    synchronized (lock) {
        PixelCopy.request(video_stream_view.holder.surface, surfaceBitmap, listener, sHandler)
        lock.wait()
    }
    thread.quitSafely()
    return if (success.get()) surfaceBitmap else null
}

video_stream_view is a view that receives a live video feed from an RTSP camera. I then use the below piece of code to save the bitmap using the encoder:

val bitmap = getSnapshot()
bitmap?.let {
    val m = Matrix()
    m.preScale(-1f, -1f)
    val dst = Bitmap.createBitmap(it, 0, 0, it.width, it.height, m, false)
    dst.density = DisplayMetrics.DENSITY_DEFAULT
    if (recordVideo) {
        encoder.addFrame(dst)
    }

The bitmap extracted from the SurfaceView is upside down so I apply some operations to get it upright. When I reapply the bitmap to the SurfaceView from where I extracted it, it looks just fine:

withContext(Dispatchers.Main) {
    video_stream_view.background = BitmapDrawable(resources, dst)
}

But the recorded video looks like this:
Screenshot from 2023-07-19 12-20-29

setFrameDelay(int) has no effect on the final result

No matter what you ms value you pass as a frame delay, it has no effect on the final result. Upon close inspection, I noticed that the frame delay value isn't being used anywhere during the encoding process. It'll be great to get some help here.

do you support different frame rates?

Hi,

Is it possible to use your software for different frame rates?
At the moment I can see it uses 20FPS as default. Is there a way to change it?

Thanks a lot,
Aliaksei

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.