Update FFmpeg plugin with some minor changes.
parent
26a9e2b3a1
commit
2771809af6
|
@ -102,6 +102,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
- (BOOL)open:(id<CogSource>)s
|
- (BOOL)open:(id<CogSource>)s
|
||||||
{
|
{
|
||||||
int errcode, i;
|
int errcode, i;
|
||||||
|
AVStream *stream;
|
||||||
|
|
||||||
source = s;
|
source = s;
|
||||||
|
|
||||||
|
@ -154,12 +155,16 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
AVCodecParameters *codecPar;
|
AVCodecParameters *codecPar;
|
||||||
|
|
||||||
for(i = 0; i < formatCtx->nb_streams; i++) {
|
for(i = 0; i < formatCtx->nb_streams; i++) {
|
||||||
codecPar = formatCtx->streams[i]->codecpar;
|
stream = formatCtx->streams[i];
|
||||||
if(codecPar->codec_type == AVMEDIA_TYPE_AUDIO)
|
codecPar = stream->codecpar;
|
||||||
|
if(streamIndex < 0 && codecPar->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||||
{
|
{
|
||||||
DLog(@"audio codec found");
|
DLog(@"audio codec found");
|
||||||
streamIndex = i;
|
streamIndex = i;
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stream->discard = AVDISCARD_ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +173,8 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stream = formatCtx->streams[streamIndex];
|
||||||
|
|
||||||
codecCtx = avcodec_alloc_context3(NULL);
|
codecCtx = avcodec_alloc_context3(NULL);
|
||||||
if (!codecCtx)
|
if (!codecCtx)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +190,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_codec_set_pkt_timebase(codecCtx, formatCtx->streams[streamIndex]->time_base);
|
av_codec_set_pkt_timebase(codecCtx, stream->time_base);
|
||||||
|
|
||||||
AVCodec * codec = avcodec_find_decoder(codecCtx->codec_id);
|
AVCodec * codec = avcodec_find_decoder(codecCtx->codec_id);
|
||||||
if (!codec) {
|
if (!codec) {
|
||||||
|
@ -243,7 +250,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
|
|
||||||
//totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE);
|
//totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE);
|
||||||
AVRational tb = (AVRational) { 1, codecCtx->sample_rate };
|
AVRational tb = (AVRational) { 1, codecCtx->sample_rate };
|
||||||
totalFrames = av_rescale_q(formatCtx->streams[streamIndex]->duration, formatCtx->streams[streamIndex]->time_base, tb);
|
totalFrames = av_rescale_q(stream->duration, stream->time_base, tb);
|
||||||
bitrate = (int)((codecCtx->bit_rate) / 1000);
|
bitrate = (int)((codecCtx->bit_rate) / 1000);
|
||||||
framesRead = 0;
|
framesRead = 0;
|
||||||
endOfStream = NO;
|
endOfStream = NO;
|
||||||
|
|
Loading…
Reference in New Issue