More debugging and restore copying lastkeyframe. Also init videoStore to NULL so that we don't crash
This commit is contained in:
parent
f1e69463b6
commit
db52a61b01
|
@ -61,6 +61,7 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
|
||||||
mOpenStart = 0;
|
mOpenStart = 0;
|
||||||
mReopenThread = 0;
|
mReopenThread = 0;
|
||||||
wasRecording = false;
|
wasRecording = false;
|
||||||
|
videoStore = NULL;
|
||||||
|
|
||||||
#if HAVE_LIBSWSCALE
|
#if HAVE_LIBSWSCALE
|
||||||
mConvertContext = NULL;
|
mConvertContext = NULL;
|
||||||
|
@ -350,7 +351,8 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
if ( mAudioStreamId == -1 )
|
if ( mAudioStreamId == -1 )
|
||||||
Debug( 2, "Unable to locate audio stream in %s", mPath.c_str() );
|
Debug( 2, "Unable to locate audio stream in %s", mPath.c_str() );
|
||||||
|
|
||||||
Debug ( 1, "Found video stream" );
|
Debug ( 3, "Found video stream at index %d", mVideoStreamId );
|
||||||
|
Debug ( 3, "Found audio stream at index %d", mAudioStreamId );
|
||||||
|
|
||||||
mCodecContext = mFormatContext->streams[mVideoStreamId]->codec;
|
mCodecContext = mFormatContext->streams[mVideoStreamId]->codec;
|
||||||
|
|
||||||
|
@ -397,7 +399,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug ( 1, "Validated imagesize" );
|
Debug ( 1, "Validated imagesize %d", pSize );
|
||||||
|
|
||||||
#if HAVE_LIBSWSCALE
|
#if HAVE_LIBSWSCALE
|
||||||
Debug ( 1, "Calling sws_isSupportedInput" );
|
Debug ( 1, "Calling sws_isSupportedInput" );
|
||||||
|
@ -579,9 +581,11 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi
|
||||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
||||||
|
|
||||||
//Keep the last keyframe so we can establish immediate video
|
//Keep the last keyframe so we can establish immediate video
|
||||||
/*if(packet.flags & AV_PKT_FLAG_KEY)
|
if(packet.flags & AV_PKT_FLAG_KEY) {
|
||||||
av_copy_packet(&lastKeyframePkt, &packet);*/
|
Debug(3, "Have keyframe");
|
||||||
//TODO I think we need to store the key frame location for seeking as part of the event
|
av_copy_packet(&lastKeyframePkt, &packet);
|
||||||
|
//TODO I think we need to store the key frame location for seeking as part of the event
|
||||||
|
}
|
||||||
|
|
||||||
//Video recording
|
//Video recording
|
||||||
if ( recording && !wasRecording ) {
|
if ( recording && !wasRecording ) {
|
||||||
|
@ -592,6 +596,9 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi
|
||||||
wasRecording = true;
|
wasRecording = true;
|
||||||
strcpy(oldDirectory, event_file);
|
strcpy(oldDirectory, event_file);
|
||||||
|
|
||||||
|
|
||||||
|
// Need to write out all the frames from the last keyframe?
|
||||||
|
|
||||||
} else if ( ( ! recording ) && wasRecording && videoStore ) {
|
} else if ( ( ! recording ) && wasRecording && videoStore ) {
|
||||||
Info("Deleting videoStore instance");
|
Info("Deleting videoStore instance");
|
||||||
delete videoStore;
|
delete videoStore;
|
||||||
|
@ -649,9 +656,10 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi
|
||||||
}
|
}
|
||||||
if ( videoStore && recording ) {
|
if ( videoStore && recording ) {
|
||||||
if ( record_audio ) {
|
if ( record_audio ) {
|
||||||
Debug(3, "Recording audio packet" );
|
Debug(3, "Recording audio packet streamindex(%d) packetstreamindex(%d)", mAudioStreamId, packet.stream_index );
|
||||||
//Write the packet to our video store
|
//Write the packet to our video store
|
||||||
int ret = videoStore->writeAudioFramePacket(&packet, mFormatContext->streams[packet.stream_index]); //FIXME no relevance of last key frame
|
//FIXME no relevance of last key frame
|
||||||
|
int ret = videoStore->writeAudioFramePacket( &packet, mFormatContext->streams[packet.stream_index] );
|
||||||
if ( ret < 0 ) {//Less than zero and we skipped a frame
|
if ( ret < 0 ) {//Less than zero and we skipped a frame
|
||||||
av_free_packet( &packet );
|
av_free_packet( &packet );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue