Skip to content

Commit e3cdebb

Browse files
author
Clement Champetier
committed
OutputVideo: update setProfile
* Have a default and a custom behavior for: * width * height * frameRate * par
1 parent d22af66 commit e3cdebb

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/AvTranscoder/EssenceStream/OutputVideo.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,24 @@ bool OutputVideo::encodeFrame( DataStream& codedFrame )
178178

179179
void OutputVideo::setProfile( Profile::ProfileDesc& desc )
180180
{
181+
// if not specified in the profile desc: 1920*1080, 25 fps, with pixel aspect ratio = 1
182+
const size_t width = ( desc.find( "width" ) != desc.end() ) ? atoi( desc[ "width" ].c_str() ) : 1920;
183+
const size_t height = ( desc.find( "height" ) != desc.end() ) ? atoi( desc[ "height" ].c_str() ) : 1080;
184+
const size_t frameRate = ( desc.find( "r" ) != desc.end() ) ? atoi( desc[ "r" ].c_str() ) : 25;
185+
const size_t par = ( desc.find( "par" ) != desc.end() ) ? atoi( desc[ "par" ].c_str() ) : 1;
186+
const AVPixelFormat pix_fmt = static_cast<AVPixelFormat>( atoi( desc[ "pix_fmt" ].c_str() ) );
187+
181188
_videoDesc.setVideoCodec( desc[ "codec" ] );
182-
_videoDesc.setTimeBase( 1, 25 ); // 25 fps
183-
_videoDesc.setImageParameters( 1920, 1080, av_get_pix_fmt( desc[ "pix_fmt" ].c_str() ) );
189+
_videoDesc.setTimeBase( 1, frameRate );
190+
191+
avtranscoder::ImageDesc imageDesc;
192+
avtranscoder::Pixel pixel( pix_fmt );
193+
// @todo: set par of pixel
194+
imageDesc.setPixel( pixel );
195+
imageDesc.setWidth( width );
196+
imageDesc.setHeight( height );
197+
imageDesc.setDar( width, height );
198+
_videoDesc.setImageParameters( imageDesc );
184199

185200
for( Profile::ProfileDesc::iterator it = desc.begin(); it != desc.end(); ++it )
186201
{
@@ -198,6 +213,10 @@ void OutputVideo::setProfile( Profile::ProfileDesc& desc )
198213
continue;
199214
if( (*it).first == "height" )
200215
continue;
216+
if( (*it).first == "r" )
217+
continue;
218+
if( (*it).first == "par" )
219+
continue;
201220

202221
try
203222
{
@@ -227,6 +246,10 @@ void OutputVideo::setProfile( Profile::ProfileDesc& desc )
227246
continue;
228247
if( (*it).first == "height" )
229248
continue;
249+
if( (*it).first == "r" )
250+
continue;
251+
if( (*it).first == "par" )
252+
continue;
230253

231254
try
232255
{

0 commit comments

Comments
 (0)