LINUX.ORG.RU

Добавить аудио поток

 


1

1
av_register_all(); 
	
//Открываем видео источник
err = av_open_input_file( &pFormatCtxSrcFl, srcFlNm, NULL, 0, NULL );

err = av_find_stream_info( pFormatCtxSrcFl );

if( err < 0 )
{
	cout << "\nUnable to find stream info!\n " << err << endl;
	return -1;
}

cout << "Found the audio streams:" << endl;	

for( i = 0; i < pFormatCtxSrcFl -> nb_streams; i++ )
{
	if( pFormatCtxSrcFl->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO  )
		cout << "\taudio stream " << pFormatCtxSrcFl->streams[ i ]->id << endl;
}

while( true )
{
	cout << "\nEnter the PID: ";
	cin >> enterPID;

	for( i = 0; i < pFormatCtxSrcFl -> nb_streams; i++ )
	{
		if( ( pFormatCtxSrcFl->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO ) 
				&& ( pFormatCtxSrcFl->streams[ i ]->id == enterPID )  )
			break;
	}

	if( i != pFormatCtxSrcFl->nb_streams )
		break;
	else
		cout << "Error: Invalid PID!" << endl;
}
//Файл в который будем записывать
err = av_open_input_file( &pFormatCtxOutFl, outFlNm, NULL, 0, NULL );

err = av_find_stream_info( pFormatCtxOutFl );

if( err < 0 )
{
	cout << "\nUnable to find stream info!\n " << err << endl;
	return -1;
}

newIDProgram = getID( pFormatCtxOutFl->streams, pFormatCtxOutFl->nb_streams );

av_new_stream( pFormatCtxOutFl, newIDProgram );

nb_audStrOut = pFormatCtxOutFl->nb_streams - 1;

memcpy( pFormatCtxOutFl->streams[ nb_audStrOut ], pFormatCtxSrcFl->streams[ i ], sizeof( AVStream ) );

av_write_header( pFormatCtxOutFl );

Возникает ошибка :

[mpegts @ 0x839ec60]Aspect ratio mismatch between encoder and muxer layer

Хотя к видео потоку я вообще не прикосаюсь



Последнее исправление: agrobobr (всего исправлений: 2)

Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.