我正在尝试使用FFmpegFrameRecorder在android中的Javacv库中录制视频,获取带有错误代码-22的av_interleaved_write_frame()。执行FFmpegFrameRecorder对象的stop()方法时会抛出该错误。找到以下代码:
{
handler.post(new Runnable() {
@Override
public void run() {
while (true) {
if (keepRecording) {
if (!frameModels.isEmpty()) {
FrameModel model = retrieveAndRemoveFrame();
frame = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 2);
byteBuffer = (ByteBuffer) frame.image[0].position(0);
int start = 80;
for (int row = 0; row < 480 * 3 / 2; row++) {
byteBuffer.put(model.getPicture(), start, 480);
start += 640;
}
try {
if (model.getTimeStamp() == 0) {
timeStamp += 40000;
Log.d(getClass().getSimpleName()," Timestamp is Zero");
} else {
timeStamp += model.getTimeStamp();
}
//Log.d("TimeStamp: ", " " + timeStamp);
frameRecorder.setTimestamp(timeStamp);
/*Log.d("Frame data", "" + frame.image.length + " count: " + frameModelCount);*/
frameRecorder.record(frame);
if (model.getAudio() != null) {
frameRecorder.recordSamples(model.getAudio());
}
} catch (FrameRecorder.Exception e) {
e.printStackTrace();
}
++frameModelCount;
}
}
if ((VideoCapture.TOTAL_FRAME_COUNT == frameModelCount ||
nextButtonPressed) && frameModels.size() == 0) {
try {
Log.d("Record ", "Before stop");
frameRecorder.stop();
Log.d("Record ", "After stop");
frameRecorder.release();
Log.d("Record ", "After release");
frameRecorder = null;
Log.d("Record ", "Successss.l......../");
keepRecording = false;
nextButtonPressed = false;
} catch (FrameRecorder.Exception e) {
long ts = frameRecorder.getTimestamp();
e.printStackTrace();
}
}
}
}
});
}
堆栈追踪:
org.bytedeco.javacv.FrameRecorder$Exception: av_interleaved_write_frame() error -22 while writing interleaved video frame.
01-19 17:52:54.816 20418-20450 / com.example.user.videorecording W / System.err:at org.bytedeco.javacv.FFmpegFrameRecorder.recordImage(FFmpegFrameRecorder.java:796) 01-19 17:52:54.816 20418-20450 / com.example.user.videorecording W / System.err:at org.bytedeco.javacv.FFmpegFrameRecorder.stop(FFmpegFrameRecorder.java:661) 01-19 17:52:54.817 20418-20450 / com.example.user.videorecording W / System.err:at com.example.user.videorecording.FrameMerger $ VideoRecordThread $ 1.run(FrameMerger.java:146) 01-19 17:52:54.817 20418-20450 / com.example.user.videorecording W / System.err:at android.os.Handler.handleCallback(Handler.java:739) 01-19 17:52:54.817 20418-20450 / com.example.user.videorecording W / System.err:at android.os.Handler.dispatchMessage(Handler.java:95) 01-19 17:52:54.817 20418-20450 / com.example.user.videorecording W / System.err:at android.os.Looper.loop(Looper.java:135) 01-19 17:52:54.817 20418-20450 / com.example.user.videorecording W / System.err:at android.os.HandlerThread.run(HandlerThread.java:61)
有谁知道av_interleaved_write_frame()是什么错误代码-22是什么意思?