saki4510t / audiovideorecordingsample Goto Github PK
View Code? Open in Web Editor NEWSimultaneous audio and video recording sample using MediaCodec/MediaMuxer
License: Apache License 2.0
Simultaneous audio and video recording sample using MediaCodec/MediaMuxer
License: Apache License 2.0
Is there a way to record a video in square shape using openGL, without distorting the image? Please help! Thank you!
Hi, I am trying to use the library to record audio and video streams into separate files and merge them afterwards. I have tried using to MediaMuxerWrapper for each encoder. However, in some devices there is a synchronization problem between the audio and video which, I think, is caused by frame drops in case of Video encoder. Can anyone hep me with the problem?
Thanks.
stopRecording error:
java.util.concurrent.TimeoutException: android.media.MediaMuxer.finalize() timed out after 10 seconds
at android.media.MediaMuxer.nativeRelease(Native Method)
at android.media.MediaMuxer.finalize(MediaMuxer.java:240)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
at java.lang.Thread.run(Thread.java:841)
then
reccord audio
Hi there
Your code its the first one i found which seems to working flawlessly while recording audio and video with MediaCodec, but i tried to convert the MediaVideoEncoder to capture screen and for that i used small bits of code from https://github.com/yrom/ScreenRecorder but when i try to record it will only record for a second and then stops no matter i long i leave it recording.
What i did was strip the RenderHandler from the MediaVideoEncoder since it doesnt seem i need it and pass MediaProjection object to the MediaVideoEncoder constructor and then i just add this to the end of MediaVideoEncoder prepare method:
mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG + "-display",
mWidth, mHeight, mDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC,
mSurface, null, null);
From what i understand the mSurface receives input from display after this method, it works and i capture the screen for just a 1 second then it stops any idea what i might be missing?
Thank you for your time
Is it possible to record byte[] frames or bitmap?
Fatal Exception: java.lang.IllegalStateException
at android.media.MediaCodec.getFormatNative(MediaCodec.java)
at android.media.MediaCodec.getOutputFormat(MediaCodec.java:2515)
at com.BattleAppLLC.BattleApp.view.squarevideo.encoder.MediaEncoder.drain(MediaEncoder.java:303)
at com.BattleAppLLC.BattleApp.view.squarevideo.encoder.MediaEncoder.run(MediaEncoder.java:129)
at java.lang.Thread.run(Thread.java:818)
hello saki, thanks for your passion.
I have a question.
I want to add PreviewCallback in CameraGLView.
The following is what I have tried :
Callback is working well.
But if i try to record, happened crash with this message.
07-21 13:02:23.193 19753-19764/com.serenegiant.mediaaudiotest E/AndroidRuntime﹕ FATAL EXCEPTION: FinalizerWatchdogDaemon
Process: com.serenegiant.mediaaudiotest, PID: 19753
java.util.concurrent.TimeoutException: android.media.MediaMuxer.finalize() timed out after 10 seconds
at android.media.MediaMuxer.nativeRelease(Native Method)
at android.media.MediaMuxer.finalize(MediaMuxer.java:240)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
at java.lang.Thread.run(Thread.java:841)
can you help me?
sorry for my bad english, thank you.
I want to use h264 Mime type for Video Encoder, I tried using video/h264 but it resulted into an error.
Adding the list of string supported in value of MIME_TYPE would be very helpful.
Hello, Thanks for making Camera Implementation easy. I am using this but on some devices, camera preview is very dark and sometimes blink and become white-normal(While Recording as well).
Devices I have used
Moto G4 Plus, Moto G2, Samsung Galaxy - Working Fine
Mi A1 and Mi Note 4 - Problem of Dark view and blinking.
I agree that the preview is a mirror image.
But the images in the recorded files are also mirrored.
How do I flip it?
Hi,
thanks for your effort.
Could you please help me how to make video preview fullscreen in portrait mode
Thanks.
I want to change the video width and height.The default out put of video file is 720x1280. I want to change it to 1280x720.But If I change the width and height in below line of code it stretches the video.
MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, 1280, 720);
setVideoSize() in CameraGLView Class call twice first time width=1280 and height=720 and second time width=720 and height=1280.
How can I switch the camera from front to back and back to front with this code?
I have used lot of code to switch camera but always I am getting crash with, when I change the camera id at runtime.
the bbp is short for bits per pixel. I can not understand why it is float number
when i recorded a video , i opened it in my computer with MediaInfo but the number of information is unknown ,just with these information,and it cant player,but in the phone:
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/mp42)
File size : 1.02 MiB
IsTruncated : Yes
I want to know how to deal with it ?
thanks!
I'm using a Samsung Galaxy tab A 8" 2019.
I set resolution to 1600x900 and seems that the first video frames of the recording are like in slow motion. I have even see if async encoder could fix it, but no it seems it has something related with how OpenGL renders it. Is there anyway to fix this?
Here there is a interesting discussion about this issue. https://stackoverflow.com/questions/39171949/android-mediacodec-eglswapbuffer-blocking-gpu-in-asynchronous-mode
Thanks!
Hi,First, thank you for your share.How should I do if I want to pause the recording.
06-05 13:50:43.011 21960-22055/com.serenegiant.audiovideosample A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x66006600750042 in tid 22055 (MediaVideoEncod)
How I can add a method to change the camera while recording?
Hello Saki!
Thanks for the excellent library!
However on the One Plus One phone i discovered that the font textures in the app disappear after pause/resume (changing app).
Like this
I think the problem is that glDeleteTextures is called in the main thread.
CameraSurfaceRenderer.onSurfaceDestroyed is called in the main thread.
Changing its code solves the problem:
This way it is good:
public void onSurfaceDestroyed() {
if (DEBUG) Log.v(TAG, "onSurfaceDestroyed:");
GLSurfaceView parent = mWeakParent.get();
parent.queueEvent(new Runnable() {
@Override
public void run() {
if (mDrawer != null) {
mDrawer.release();
mDrawer = null;
}
if (mSTexture != null) {
mSTexture.release();
mSTexture = null;
}
GLDrawer2D.deleteTex(hTex);
}
});
}
The error no longer happens however i am not sure that this is the best solution.
I would appriciate your kind help.
Best regards
Tamás
Hi saki,
Thanks for your last response.
I am looking to make video preview fullscreen in landscape.
Then I set aspect ratio
mCameraView.setAspectRatio(display.getmWidth()/ display.getmHeight());
It takes only half of screen.
But then I removed setAspectRatio, camera preview is stretched.
Thanks in advice.
I am using your code to record video. It is working fine of few phone. But i am getting lag in few phones like lenovo k8 plus/ pixel 2
Hi Saki
I've been playing around with your project and I must say it's impressive. Since I'm using Xamarin I've 'translated' your code to C#, but all is working fine now. Muxing video and audio is working nicely on my test device.
So I've added some code to be able to switch the camera (front/back) and it's working. I stop the preview in the CameraHandler and restart it afterwards.
When playing a movie recorded by the back camera, the image is flipped. This is not the case with a front camera recording (preview = recorded orientation)
Any ideas are welcome !
Thanks
Benoit
Hi Saki,
First, thank you for your share. I would like to know if there is a way to crop/manipulate each frame before encoding it.
I am currently trying to get your code to work in my app.
However it seems like your code has some errors and does not output the videos the way they should be. The video is kind of skipping frames and cut apart and therefor useless because it is hardly blemished. Did you experience this behavior as well?
When doing a recording on the Samsung S4 with OS5.0.1. I got this crash log
11-18 07:53:25.045 18723-20104/com.serenegiant.audiovideosample E/ACodec: signalError(omxError 0x80001009, internalError -2147483648)
11-18 07:53:25.055 18723-20103/com.serenegiant.audiovideosample E/MediaCodec: Codec reported err 0x80001009, actionCode 0, while in state 6
11-18 07:53:25.055 18723-20093/com.serenegiant.audiovideosample E/AndroidRuntime: FATAL EXCEPTION: MediaVideoEncoder
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)
at com.serenegiant.audiovideosample.encoder.MediaEncoder.drain(MediaEncoder.java:301)
at com.serenegiant.audiovideosample.encoder.MediaEncoder.run(MediaEncoder.java:155)
at java.lang.Thread.run(Thread.java:818)
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.