Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android FFmpegFrameRecorder and otaliastudios #2255

Open
openmotion opened this issue Jul 25, 2024 · 4 comments
Open

android FFmpegFrameRecorder and otaliastudios #2255

openmotion opened this issue Jul 25, 2024 · 4 comments

Comments

@openmotion
Copy link

openmotion commented Jul 25, 2024

Hello
i use the library otaliastudios for managing camera

i set the recorder
recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 0);
recorder.setFormat("flv");
recorder.setFrameRate(frameRate);

try {
recorder.start();
} catch (FFmpegFrameRecorder.Exception e) {
throw new RuntimeException(e);
}

then in frame processor i added

mCameraView.addFrameProcessor(new FrameProcessor() {
@OverRide
@workerthread
public void process(@nonnull Frame frame) {

try {
Log.d(TAG, "add frame ok");
recorder.record(frame.getData());
} catch (FFmpegFrameRecorder.Exception e) {
Log.d(TAG, "add frame ko");
throw new RuntimeException(e);
}

then i stopped the record after 10 seconds
but the flv file has a very low size of 212 ( bytes )
and is unreadeable

any suggestion ?

how can i convert the frame ( otaliastudio format ) to javacv.Frame

Required type:
org.bytedeco.javacv.Frame
Provided:
com.otaliastudios.cameraview.frame.Frame

thanks

@saudet
Copy link
Member

saudet commented Jul 25, 2024

You'll need to call recorder.close() somewhere

@openmotion
Copy link
Author

openmotion commented Jul 26, 2024

You'll need to call recorder.close() somewhere

yes i do that

` long time = 1000*20;
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
Log.i("tag","A Kiss after 5 seconds");
mymodel_toast.make_toasty(mContext,"stop record","success");
try {
recorder.stop();
recorder.release();
} catch (FFmpegFrameRecorder.Exception e) {
throw new RuntimeException(e);
}

                }
            }, time);

`

the size is 0 before the stop, and 212 after
i suspect the original frame is not correctly converted to the ffmpegframerecorder format

@saudet
Copy link
Member

saudet commented Jul 26, 2024

Please try again with the snapshots: http://bytedeco.org/builds/

@openmotion
Copy link
Author

openmotion commented Jul 26, 2024

Please try again with the snapshots: http://bytedeco.org/builds/

thanks but if i change my build.gradle to implementation("org.bytedeco:javacv-platform:1.5.11-SNAPSHOT")
the library is no more recognized in the import section

Cannot resolve symbol 'bytedeco'

this is code i use to save image in jpeg

YuvImage yuvImage = new YuvImage(bitmapbytes, ImageFormat.NV21, width, height, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
compression = 50;
Rect imageSizeRectangle = new Rect(0, 0, width, height);
yuvImage.compressToJpeg(imageSizeRectangle, compression, baos);
byte[] imageData = baos.toByteArray();

but imageData doesn't works with javacv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants