[FFmpeg-user] How do I use the HW accerlator?

nrson nrson at win4net.com
Fri May 18 09:55:49 CEST 2012


Hi Carl!

Thank you for your response quickly.

I did it according to your advices and the config.h file created as 
following:

   #define CONFIG_HWACCELS 1
   #define CONFIG_H264_DXVA2_HWACCEL 1

I want to recognize dxva2_h264 in my source but I can't use it.
Please you think I am big ffmpeg beginner.
My source is next following and what do I do?

AVHWAccel h264_dxva2_hwaccel = NULL;

av_register_all();
avcodec_register_all();

pGBCodec = avcodec_find_decoder(CODEC_ID_H264);

if(pGBCodec)
{
	pGBContext	=	avcodec_alloc_context();
	avcodec_get_context_defaults(pGBContext);

	if(!h264_dxva2_hwaccel)
	{
		AVHWAccel* hwaccel = NULL;
		while(hwaccel = av_hwaccel_next(hwaccel))
		{
			if(hwaccel->pix_fmt == PIX_FMT_DXVA2_VLD && hwaccel->id == 
CODEC_ID_H264)
			{
				h264_dxva2_hwaccel = hwaccel;
				printf("dxva2_hwaccel = %s",h264_dxva2_hwaccel->name);
				break;
			}
		}
	}
	if(!h264_dxva2_hwaccel)
	{
		printf("dxv2 not supported by ffmpeg");
		exit(0);
	}
          if(avcodec_open(pGBContext, pGBCodec) < 0)
	{
		avcodec_close(pGBContext);
		av_free(pGBContext);

		pGBContext = NULL;
	}
}

Best regards,
nrson

On 2012-05-17 19:27, Carl Eugen Hoyos wrote:
> nrson <nrson <at> win4net.com> writes:
>
>> My configure and version on WinGW are as follows:
>>
>> ffmpeg version 0.9.1.git
>
> Always use current git head if you are not distributing FFmpeg
>
>>    built on Apr 20 2012 11:14:30 with gcc 4.6.2
>>    configuration: --enable-gpl --enable-shared
>
>> --enable-swscale
>> --enable-hwaccel=h264_dxva2 --enable-decoder=h264
>> --enable-w32threads --enable-memalign-hack --disable-libvorbis
>> --disable-libx264
>
> These options look all unneeded, they are the default iirc.
>
>> --disable-yasm
>
> This is not advisable if you care about performance.
>
>> When I reviewd the config.h after compiling, the results was as
>> following
>>
>>    #define CONFIG_HWACCELS 0
>>    #define CONFIG_H264_DXVA2_HWACCEL 0
>>
>> How do I solves the problem?
>
> Look at config.log, search for dxva, it will tell you that
> you have to install additional headers.
>
> Carl Eugen
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user



More information about the ffmpeg-user mailing list