Lines 20-26
Link Here
|
20 |
|
20 |
|
21 |
#include "_EncodeVideo.h" |
21 |
#include "_EncodeVideo.h" |
22 |
|
22 |
|
23 |
#define PIXFMT PIX_FMT_RGB24 |
23 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
|
|
24 |
#define PIXFMT AV_PIX_FMT_RGB24 |
25 |
#else |
26 |
#define PIXFMT PIX_FMT_RGB24 |
27 |
#endif |
24 |
#define QTPIXFMT QImage::Format_RGB888 |
28 |
#define QTPIXFMT QImage::Format_RGB888 |
25 |
|
29 |
|
26 |
//************************************************************************************************************************************************* |
30 |
//************************************************************************************************************************************************* |
Lines 410-418
Link Here
|
410 |
// Setup codec parameters |
414 |
// Setup codec parameters |
411 |
VideoStream->codec->width =ImageWidth; |
415 |
VideoStream->codec->width =ImageWidth; |
412 |
VideoStream->codec->height =ImageHeight; |
416 |
VideoStream->codec->height =ImageHeight; |
|
|
417 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
418 |
VideoStream->codec->pix_fmt =AV_PIX_FMT_YUV420P; |
419 |
#else |
413 |
VideoStream->codec->pix_fmt =PIX_FMT_YUV420P; |
420 |
VideoStream->codec->pix_fmt =PIX_FMT_YUV420P; |
|
|
421 |
#endif |
414 |
VideoStream->codec->time_base =VideoFrameRate; |
422 |
VideoStream->codec->time_base =VideoFrameRate; |
415 |
VideoStream->time_base =VideoFrameRate; |
|
|
416 |
VideoStream->codec->sample_aspect_ratio =PixelAspectRatio; |
423 |
VideoStream->codec->sample_aspect_ratio =PixelAspectRatio; |
417 |
VideoStream->sample_aspect_ratio =PixelAspectRatio; |
424 |
VideoStream->sample_aspect_ratio =PixelAspectRatio; |
418 |
if ((codec->id!=AV_CODEC_ID_H264)||(!VBR)) { |
425 |
if ((codec->id!=AV_CODEC_ID_H264)||(!VBR)) { |
Lines 435-441
Link Here
|
435 |
|
442 |
|
436 |
} else if (codec->id==AV_CODEC_ID_MJPEG) { |
443 |
} else if (codec->id==AV_CODEC_ID_MJPEG) { |
437 |
//-qscale 2 -qmin 2 -qmax 2 |
444 |
//-qscale 2 -qmin 2 -qmax 2 |
|
|
445 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
446 |
VideoStream->codec->pix_fmt =AV_PIX_FMT_YUVJ420P; |
447 |
#else |
438 |
VideoStream->codec->pix_fmt =PIX_FMT_YUVJ420P; |
448 |
VideoStream->codec->pix_fmt =PIX_FMT_YUVJ420P; |
|
|
449 |
#endif |
439 |
VideoStream->codec->qmin =2; |
450 |
VideoStream->codec->qmin =2; |
440 |
VideoStream->codec->qmax =2; |
451 |
VideoStream->codec->qmax =2; |
441 |
VideoStream->codec->bit_rate_tolerance =(ImageWidth*ImageHeight*2*VideoFrameRate.den/VideoFrameRate.num)*2; |
452 |
VideoStream->codec->bit_rate_tolerance =(ImageWidth*ImageHeight*2*VideoFrameRate.den/VideoFrameRate.num)*2; |
Lines 565-571
Link Here
|
565 |
#endif |
576 |
#endif |
566 |
|
577 |
|
567 |
// Create and prepare VideoFrame and VideoFrameBuf |
578 |
// Create and prepare VideoFrame and VideoFrameBuf |
568 |
VideoFrame=avcodec_alloc_frame(); // Allocate structure for RGB image |
579 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
|
|
580 |
VideoFrame=av_frame_alloc(); |
581 |
#else |
582 |
VideoFrame=avcodec_alloc_frame(); |
583 |
#endif |
569 |
if (!VideoFrame) { |
584 |
if (!VideoFrame) { |
570 |
ToLog(LOGMSG_CRITICAL,"EncodeVideo-OpenVideoStream: avcodec_alloc_frame() failed"); |
585 |
ToLog(LOGMSG_CRITICAL,"EncodeVideo-OpenVideoStream: avcodec_alloc_frame() failed"); |
571 |
return false; |
586 |
return false; |
Lines 655-661
Link Here
|
655 |
return false; |
670 |
return false; |
656 |
} |
671 |
} |
657 |
|
672 |
|
|
|
673 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
674 |
AudioFrame=av_frame_alloc(); |
675 |
#else |
658 |
AudioFrame=avcodec_alloc_frame(); |
676 |
AudioFrame=avcodec_alloc_frame(); |
|
|
677 |
#endif |
659 |
if (AudioFrame==NULL) { |
678 |
if (AudioFrame==NULL) { |
660 |
ToLog(LOGMSG_CRITICAL,QString("EncodeVideo-OpenAudioStream:: avcodec_alloc_frame failed")); |
679 |
ToLog(LOGMSG_CRITICAL,QString("EncodeVideo-OpenAudioStream:: avcodec_alloc_frame failed")); |
661 |
return false; |
680 |
return false; |
Lines 1096-1102
Link Here
|
1096 |
if (Continue) { |
1115 |
if (Continue) { |
1097 |
// Init AudioFrame |
1116 |
// Init AudioFrame |
1098 |
AVRational AVR; |
1117 |
AVRational AVR; |
|
|
1118 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
1119 |
av_frame_unref(AudioFrame); |
1120 |
#else |
1099 |
avcodec_get_frame_defaults(AudioFrame); |
1121 |
avcodec_get_frame_defaults(AudioFrame); |
|
|
1122 |
#endif |
1100 |
AVR.num =1; |
1123 |
AVR.num =1; |
1101 |
AVR.den =AudioStream->codec->sample_rate; |
1124 |
AVR.den =AudioStream->codec->sample_rate; |
1102 |
AudioFrame->nb_samples =DestPacketSize/DestSampleSize; |
1125 |
AudioFrame->nb_samples =DestPacketSize/DestSampleSize; |
Lines 1181-1187
Link Here
|
1181 |
int errcode; |
1204 |
int errcode; |
1182 |
|
1205 |
|
1183 |
if (Image) { |
1206 |
if (Image) { |
1184 |
avcodec_get_frame_defaults(VideoFrame); |
1207 |
#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300)) |
|
|
1208 |
av_frame_unref(AudioFrame); |
1209 |
#else |
1210 |
avcodec_get_frame_defaults(AudioFrame); |
1211 |
#endif |
1185 |
if (avpicture_fill( |
1212 |
if (avpicture_fill( |
1186 |
(AVPicture *)VideoFrame, // Frame to prepare |
1213 |
(AVPicture *)VideoFrame, // Frame to prepare |
1187 |
VideoFrameBuf, // Buffer which will contain the image data |
1214 |
VideoFrameBuf, // Buffer which will contain the image data |
Lines 1226-1239
Link Here
|
1226 |
} |
1253 |
} |
1227 |
} |
1254 |
} |
1228 |
|
1255 |
|
1229 |
if ((VideoFrameNbr%VideoStream->codec->gop_size)==0) |
1256 |
if ((VideoFrameNbr%VideoStream->codec->gop_size)==0) VideoFrame->pict_type=AV_PICTURE_TYPE_I; |
1230 |
VideoFrame->pict_type=AV_PICTURE_TYPE_I; |
1257 |
else VideoFrame->pict_type=(AVPictureType)0; |
1231 |
else |
|
|
1232 |
VideoFrame->pict_type=(AVPictureType)0; |
1233 |
VideoFrame->pts=VideoFrameNbr; |
1258 |
VideoFrame->pts=VideoFrameNbr; |
1234 |
VideoFrame->format=VideoStream->codec->pix_fmt; |
|
|
1235 |
VideoFrame->width=VideoStream->codec->width; |
1236 |
VideoFrame->height=VideoStream->codec->height; |
1237 |
|
1259 |
|
1238 |
if ((Continue)&&(!StopProcessWanted)) { |
1260 |
if ((Continue)&&(!StopProcessWanted)) { |
1239 |
|
1261 |
|