Я долго ищу на net. Но бесполезно. Пожалуйста, помогите или попробуйте дать некоторые идеи, как этого добиться. мой код может нормально работать на других телефонах, кроме moto g play, это cra sh log
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 13589
A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
A/DEBUG: Build fingerprint: 'motorola/harpia/harpia:7.1.1/NPIS26.48-43-2/3:user/release-keys'
A/DEBUG: Revision: 'p1b0'
A/DEBUG: ABI: 'arm'
A/DEBUG: pid: 13238, tid: 13589, name: HW264SurfaceEnc >>> com.tianxingjian.screenshot <<<
A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
A/DEBUG: r0 00000000 r1 00003515 r2 00000006 r3 00000008
A/DEBUG: r4 8567a978 r5 00000006 r6 8567a920 r7 0000010c
A/DEBUG: r8 00000004 r9 00000000 sl 850a8c60 fp 00000004
A/DEBUG: ip 0000006e sp 85679560 lr b5a10407 pc b5a12c64 cpsr 200f0010
A/DEBUG: backtrace:
A/DEBUG: #00 pc 00049c64 /system/lib/libc.so (tgkill+12)
A/DEBUG: #01 pc 00047403 /system/lib/libc.so (pthread_kill+34)
A/DEBUG: #02 pc 0001d555 /system/lib/libc.so (raise+10)
A/DEBUG: #03 pc 000190a1 /system/lib/libc.so (__libc_android_abort+34)
A/DEBUG: #04 pc 00017104 /system/lib/libc.so (abort+4)
A/DEBUG: #05 pc 000c72af /system/lib/libstagefright.so
A/DEBUG: #06 pc 000c6783 /system/lib/libstagefright.so
A/DEBUG: #07 pc 000c53c5 /system/lib/libstagefright.so (_ZN7android11MPEG4Writer5Track12writeCttsBoxEv+184)
A/DEBUG: #08 pc 000c4c8d /system/lib/libstagefright.so (_ZN7android11MPEG4Writer5Track12writeStblBoxEb+104)
A/DEBUG: #09 pc 000bfda9 /system/lib/libstagefright.so (_ZN7android11MPEG4Writer5Track16writeTrackHeaderEb+112)
A/DEBUG: #10 pc 000bf4e3 /system/lib/libstagefright.so (_ZN7android11MPEG4Writer12writeMoovBoxEx+78)
A/DEBUG: #11 pc 000bdf23 /system/lib/libstagefright.so (_ZN7android11MPEG4Writer5resetEv+1026)
A/DEBUG: #12 pc 000dd573 /system/lib/libstagefright.so (_ZN7android10MediaMuxer4stopEv+82)
A/DEBUG: #13 pc 0002adc7 /system/lib/libmedia_jni.so
A/DEBUG: #14 pc 73d59985 /data/dalvik-cache/arm/system@framework@boot.oat (offset 0x28e2000)
это обратный вызов захвата экрана, и он отправит eos кодеру при остановке
@Override
public void onStart(ScreenCaptureTask task) {
Logger.d(TAG, "screen capture started");
mInputSurface = new InputSurface(mSurface);
mInputSurface.makeCurrent();
}
@Override
public void onStop(ScreenCaptureTask task) {
Logger.d(TAG, "screen capture stopped");
try {
mVideoEncoder.signalEOS();
} catch (Exception e) {
if (mAudioCapture != null)
mAudioCapture.requestStop();
stopWriter(STOP_REASON_ERROR_VIDEO_CAPTURE);
report(e, "signal eos error on screen capture stop");
}
}
@Override
public void onError(ScreenCaptureTask task, Exception e) {
Logger.e(TAG, e, "screen capture error");
mReason = STOP_REASON_ERROR_VIDEO_CAPTURE;
try {
mVideoEncoder.signalEOS();
} catch (Exception e1) {
//
mVideoTrackIndex = -1;
}
report(e, "screen capture error");
ScreenRecorder.this.onError(new Exception("screen capture error", e));
}
@Override
public void onTimelineChanged(ScreenCaptureTask task, long timeNs) {
if (mInputSurface != null) {
mInputSurface.setPresentationTime(timeNs);
mInputSurface.swapBuffers();
mVideoEncoder.feed(null, 0, 0, 0, 0);
}
}
это callbak кодировщика, вызовет stopWriter при остановке
private class VideoEncoderCallback implements AbsCodec.Callback {
private long mFirstPts;
@Override
public void onSurfaceCreated(AbsCodec codec, Surface surface) {
mSurface = surface;
}
@Override
public void onStart(AbsCodec codec) {
Logger.d(TAG, "video encoder started");
if (mVideoCapture != null) {
MCInfo mcInfo = mVideoEncoder.getMCInfo();
if (mcInfo != null && mcInfo.mediaFormat != null) {
mVideoCapture.setSize(mcInfo.mediaFormat.getInteger(MediaFormat.KEY_WIDTH),
mcInfo.mediaFormat.getInteger(MediaFormat.KEY_HEIGHT));
}
mVideoCapture.requestStart();
}
}
@Override
public void onStop(AbsCodec codec) {
Logger.d(TAG, "video encoder stopped");
stopWriter(mReason);
}
@Override
public void onError(AbsCodec codec, Exception e) {
Logger.e(TAG, e, "video encoder error");
mReason = STOP_REASON_ERROR_VIDEO_ENCODE;
if (mVideoCapture != null) {
mVideoCapture.requestStop();
mVideoCapture = null;
}
if (mAudioCapture != null) {
mAudioCapture.requestStop();
mAudioCapture = null;
}
ScreenRecorder.this.onError(new Exception("video encoder error", e));
report(e, "video encoder error");
}
@Override
public void onOutputFormatChanged(AbsCodec codec, MediaFormat outputFormat) {
Logger.d(TAG, "video encoder output format changed, %s", outputFormat);
startWriter(outputFormat, null);
}
@Override
public boolean onOutputBufferAvailable(AbsCodec codec, ByteBuffer buffer, MediaCodec.BufferInfo bufferInfo) {
synchronized (mWriterStartLock) {
if (!mWriterStarted) {
return false;
}
}
if (mFirstPts == 0)
mFirstPts = bufferInfo.presentationTimeUs;
bufferInfo.presentationTimeUs -= mFirstPts;
onTimelineChanged(bufferInfo.presentationTimeUs);
return writeSampleData(false, buffer, bufferInfo);
}
}
void stopWriter(int reason) {
if ((reason & STOP_REASON_STOP_REQUEST_SAW_EOS) == 0) {
mVideoTrackIndex = -1;
mAudioTrackIndex = -1;
}
Logger.i(TAG, "stop writer " + mVideoTrackIndex + ", " + mAudioTrackIndex);
if (mVideoTrackIndex >= 0 || mAudioTrackIndex >= 0) {
Logger.d(TAG, "wait all track stop");
return;
}
try {
Thread.sleep(1000);
mWriter.stop();
mWriter.release();
Logger.d(TAG, "writer stopped, reason %d", reason);
} catch (Throwable e) {
Logger.e(TAG, e, "stop writer error, reason %d", reason);
report(e, "stop writer error, reason %d", reason);
if (mCallback != null)
mCallback.onError(this, new Exception("stop writer error, reason " + reason, e));
return;
} finally {
synchronized (mWriterStartLock) {
mWriterStarted = false;
}
}
onStop((reason & STOP_REASON_ERROR) == 0);
}
public void stop() {
if (mState != MUXER_STATE_STARTED) {
throw new IllegalStateException("Can't stop due to wrong state.");
}
if (mUseBuiltin) {
mBuiltinWriter.stop(); // this is MediaMuxer
} else {
mWriter.stop();
}
}
public void release() {
if (mState == MUXER_STATE_STARTED) {
stop();
}
if (mWriter != null) {
mWriter.release();
mWriter = null;
}
if (mBuiltinWriter != null) {
mBuiltinWriter.release();
mBuiltinWriter = null;
}
mState = MUXER_STATE_UNINITIALIZED;
}
Я искал несколько дней для этого, но не могу это исправить, пожалуйста, помогите мне