dbof10 / bitmp4 Goto Github PK
View Code? Open in Web Editor NEWConvert bitmaps to video
Home Page: https://medium.com/@Cuong.Le/open-sourcing-bitmp4-1e7517e5462f
License: Apache License 2.0
Convert bitmaps to video
Home Page: https://medium.com/@Cuong.Le/open-sourcing-bitmp4-1e7517e5462f
License: Apache License 2.0
This issue relates to #7
I tried your advise and updated
https://github.com/dbof10/Bitmp4/blob/master/lib-bitmp4/src/main/java/com/ctech/bitmp4/MP4Encoder.java#L64
but it didn't really affect the output.
Is there any other line of code I need to update to change a frame rate?
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
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)
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)
I tried to import Sample App and run. When I click Export, the data generated (10MB and length of video is 0:00) could not open with any video player. Using Huewei Y 9 2018, Android 9
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)
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?
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)
}
will be cool to add ability to set custom thread to encoder
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.