-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
video take strang line on android api >= 21 #190
Comments
Have this issue too, only in android api>=21 |
I face with issue too. |
Doesn't sound like a problem with |
@tomerhatav how about on your side |
@nguyenvancuongit same result as yours, image is fine, video encode is making the strange 5 pixels line |
@tomerhatav any solution on your side? my bad currently solution is crop video ... |
I found the bug. /**
* Creates a direct byte buffer based on a newly allocated memory block.
*
* @param capacity
* the capacity of the new buffer
* @return the created byte buffer.
* @throws IllegalArgumentException
* if {@code capacity < 0}.
*/
public static ByteBuffer allocateDirect(int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException("capacity < 0: " + capacity);
}
return new DirectByteBuffer(MemoryBlock.allocate(capacity), capacity, 0, false, null);
} After 5.0: /**
* Creates a direct byte buffer based on a newly allocated memory block.
*
* @param capacity
* the capacity of the new buffer
* @return the created byte buffer.
* @throws IllegalArgumentException
* if {@code capacity < 0}.
*/
public static ByteBuffer allocateDirect(int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException("capacity < 0: " + capacity);
}
// Ensure alignment by 8.
MemoryBlock memoryBlock = MemoryBlock.allocate(capacity + 7);
long address = memoryBlock.toLong();
long alignedAddress = (address + 7) & ~(long)7;
return new DirectByteBuffer(memoryBlock, capacity, (int)(alignedAddress - address), false, null);
} The buffer's arrayOffset is always 0 before android 5.0, but not after 5.0. So I changed Before: int step = stride * Math.abs(depth) / 8;
BytePointer data = image[0] instanceof ByteBuffer
? new BytePointer((ByteBuffer)image[0].position(0))
: new BytePointer(new Pointer(image[0].position(0))); After: int step = stride * Math.abs(depth) / 8;
BytePointer data = image[0] instanceof ByteBuffer
? new BytePointer((ByteBuffer)image[0].position(image[0].arrayOffset()))
: new BytePointer(new Pointer(image[0].position(image[0].arrayOffset()))); Now it works well both on Android 4.x and 5.x. |
… from a buffer backed by an array (issue bytedeco/javacv#190)
Nice catch @DTHeaven! I've fixed the root cause of this bug in the latest commit for JavaCPP above. Thanks! |
@DTHeaven you're awesome !! |
@saudet is there any example of recoder.recordeImage().... so i can overcome this issue . |
@justflyhard No need to do that. Instead of |
@saudet i import that jar and avutil avcodec avformat all are missing ,using javacv.jar from http://bytedeco.org/download/ |
@saudet before i were using gradle build javacv 1.0 and javacpp 1.0 |
Reopening this just to try to get people to stop creating duplicates... |
@saudet help... your javacpp.jar 1.0.1 not working ...avutil avcodec avformat all are missing |
@justflyhard Just use the ones you used before. Those don't need to be changed. |
@saudet i tried everything you said about 5 times but these are errors .... first what i did
now my previous code showing these errors here is my code private void initRecorder() {
Log.w(LOG_TAG, "init recorder");
if (RECORD_LENGTH > 0) {
imagesIndex = 0;
images = new Frame[RECORD_LENGTH * frameRate];
timestamps = new long[images.length];
for (int i = 0; i < images.length; i++) {
images[i] = new Frame(imageHeight, imageHeight, Frame.DEPTH_UBYTE, 2);
timestamps[i] = -1;
}
} else if (yuvImage == null) {
yuvImage = new Frame(imageHeight, imageHeight, Frame.DEPTH_UBYTE, 2);
Log.i(LOG_TAG, "create yuvImage");
}
// filter = new FFmpegFrameFilter("transpose=cclock_flip", imageWidth, imageHeight);
// filter.setPixelFormat(org.bytedeco.javacpp.avutil.AV_PIX_FMT_NV21); // default camera format on Android
// filter.start();
captureFile=new File(getActivity().getExternalFilesDir(null),function.randomString(12)+".mp4");
recorder = new FFmpegFrameRecorder(captureFile, imageHeight, imageHeight, 1);
recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC); error here
recorder.setFormat("mp4");
recorder.setSampleRate(sampleAudioRateInHz);
recorder.setAudioBitrate(93);
//recorder.setVideoBitrate(2048);
recorder.setAudioChannels(2);
// Set in the surface changed method
recorder.setFrameRate(frameRate);
//recorder.setAspectRatio(1);
recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); error here -----
Log.i(LOG_TAG, "recorder initialize success");
audioRecordRunnable = new AudioRecordRunnable();
audioThread = new Thread(audioRecordRunnable);
runAudioThread = true;
} |
@justflyhard You forgot to add |
@saudet thanks but after doing all this that strange line still there ....your javacpp 1.0.1 didnt help ...are you sure about this jar that by adding this jar strange line will dissappear |
@justflyhard No one else has noted that yet, you would be the first. You could try the patch from @DTHeaven as well see if that does anything more. |
@justflyhard pls try to override FFmpegFrameRecorder.java with edited from #190 (comment) |
thankyou @nguyenvancuongit @saudet problem fixed .thanks a lot 👍 |
Fix included in version 1.1. Thanks for reporting and thanks to @DTHeaven for finding the bug!! |
Hi,
Sorry when open this issue, but did @saudet check on android api >= 21?
My result is strange, pls take a look here
There's a video area on the left.
Thanks you for your support.
The text was updated successfully, but these errors were encountered: