EmguFFmpeg icon indicating copy to clipboard operation
EmguFFmpeg copied to clipboard

AVHWDeviceType and MediaFilterGraph

Open ChristopheI opened this issue 1 year ago • 2 comments

I use with success MediaFilterGraph with one or several MediaStream (as Video type) as Inputs I can use simple or complex filter - here I describe my problem using only one MediaStream as Input.

For example:

  1. scale=400:-2
  2. subtitles=f=c\:\\media\\TOEFLTest.mp4:si=0

When I tried to use an AVHWDeviceType ("d3d11va" to be precise) on MediaDecoder of the MediaStream using the first filter it's working fine When the second is used it failed on MediaFilterContext.ReadFrame (...) - see code snippet below.

// Get MediaFilterContext according the id specified
var mediaInputFilterContext = _videoFilterGraph.Where(mediaFilterContext => mediaFilterContext.Name == id).FirstOrDefault();
if (mediaInputFilterContext == null)
    return;

// Write frame in the MediaFilterContext
mediaInputFilterContext.WriteFrame(mediaFrame, (int)BufferSrcFlags.KeepRef);

// ReadFrame (if any) from FilterGraph Output
var mediaOutputFilterContext = _videoFilterGraph.Where(mediaFilterContext => mediaFilterContext.NbOutputs == 0 ).FirstOrDefault();
if(mediaOutputFilterContext != null)
    foreach (var filterFrame in mediaOutputFilterContext.ReadFrame()) // => FAILED WITH ERROR -22
        ManageVideoFrame(filterFrame);

I suppose I need to do specific stuff when AVHWDeviceType is used but I really don't know where ...
Could you advise me ? Thanks.

ChristopheI avatar Aug 02 '23 15:08 ChristopheI

From ffmpeg I have this log entry:

[local04 @ 000001d9712a6700] [warning] Changing video frame properties on the fly is not supported by all filters.

ChristopheI avatar Aug 03 '23 07:08 ChristopheI

Perhaps the AddFilter and the decoded AVFrame parameters are inconsistent.

IOL0ol1 avatar Aug 07 '23 17:08 IOL0ol1