Skip to content

Commit

Permalink
Modified a source code to cope with multiple ffmpeg versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeguchi committed Apr 23, 2013
1 parent 1da823a commit 9de6e5c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mist/io/video.h
Expand Up @@ -519,6 +519,23 @@ namespace video
{
if( !is_open( ) )
{
if( p_fctx_ != NULL )
{
av_close_input_file( p_fctx_ );
p_fctx_ = NULL;
}

p_fctx_ = avformat_alloc_context( );
if( p_fctx_ == NULL )
{
printf( "Couldn't allocate avformat context\n" );
return( false );
}

//p_fctx_->flags |= AVFMT_FLAG_NONBLOCK;
//p_fctx_->flags |= AVFMT_FLAG_GENPTS;
//p_fctx_->flags |= AVFMT_FLAG_SORT_DTS;

// ファイルのヘッダ情報を読み取ってビデオフォーマットを取得する
#if LIBAVFORMAT_VERSION_MAJOR < 54
if( av_open_input_file( &p_fctx_, filename.c_str( ), NULL, 0, NULL ) != 0 )
Expand All @@ -531,7 +548,11 @@ namespace video
}

// ファイルからストリーム情報を取得する
#if LIBAVFORMAT_VERSION_MAJOR < 55
if( av_find_stream_info( p_fctx_ ) < 0 )
#else
if( avformat_find_stream_info( p_fctx_, NULL ) < 0 )
#endif
{
printf( "Couldn't find stream information\n" );
return( false );
Expand Down Expand Up @@ -616,6 +637,7 @@ namespace video

// ファイルを閉じる
av_close_input_file( p_fctx_ );
p_fctx_ = NULL;

// 一時フレーム領域を解放する
av_free( p_frame_src_);
Expand Down

0 comments on commit 9de6e5c

Please sign in to comment.