Making an MP4 renderer.

Topics: User Forum
Developer
Nov 10, 2006 at 4:08 PM
Hi There,

Thanks for all your hard work on this, it's a real help having these libraries. However, I am trying to add support for the MP4/3gp filter at http://www.standardmpeg.com/ . It looks like it should be as easy as modifying the existing AVI/WMV renderers but i'm finding it a bit tricky.

I've made a MPEGFileRenderer.cs with the following:


// Create the file writer
IBaseFilter multiplexer = StandardFilters.RenderMPEGDestination(Cleanup, graphBuilder, Graph, outputFile);

Based on the AVI renderer, and added in the new standard filter:

public static IBaseFilter RenderMPEGDestination(DisposalCleanup dc, ICaptureGraphBuilder2 graphBuilder, IGraphBuilder graph,
string outputFile)
{
if (dc == null) throw new ArgumentNullException("dc");
if (graphBuilder == null) throw new ArgumentNullException("graphBuilder");
if (string.IsNullOrEmpty(outputFile)) throw new ArgumentNullException("outputFile");

int hr = 0;
// mpeg objects (from directencode)
IBaseFilter m_pMPEGWriter;
IStandardMpegEncoder m_pIMPEGEncoder;
StandardMpegEncoderProfile m_pIMPEGEncoderProfile;
DirectEncodeNET.SystemsOutputFormat m_systemsFormat;
DirectEncodeNET.Constraint m_constraint;

Guid guid = new Guid("CFD87339-C61F-46ca-B6A1-F87D6B96243E");
Type comtype = Type.GetTypeFromCLSID(guid);
m_pMPEGWriter = (IBaseFilter)Activator.CreateInstance(comtype);

mpIMPEGEncoder = (IStandardMpegEncoder)mpMPEGWriter;

// make the mpeg encoder select one of the pre-defined
// profile objects that it stores internally. For audio
// you will need to create your own profile.
msystemsFormat = DirectEncodeNET.SystemsOutputFormat.SYSTEMSFORMATMP4;
mconstraint = DirectEncodeNET.Constraint.CONSTRAINTNONE;

mpIMPEGEncoder.SelectFormat(msystemsFormat, m_constraint);
mpIMPEGEncoder.GetSelectedProfile(out mpIMPEGEncoderProfile);


IBaseFilter fileWriter = (IBaseFilter)new FileWriter();
dc.Add(fileWriter);
IFileSinkFilter fs = (IFileSinkFilter)fileWriter;
dc.Add(fs);
hr = fs.SetFileName(outputFile, null);

hr = graph.AddFilter(fileWriter, "File Writer Filter");
DESError.ThrowExceptionForHR(hr);

hr = graph.AddFilter(m_pMPEGWriter, "Standard MPEG Encoder");
DESError.ThrowExceptionForHR(hr);



// Create the file write

return fileWriter;
}

However, when I run it, i get an error on line 319 of AbstractRenderer

There is a sample of the MPEG filter in use at http://www.moodia.com/code/

Hope you can point me in the right direction?

Thanks, Mike
Coordinator
Nov 23, 2006 at 11:15 PM
Sorry about the huge delay in responding to this, I've been very slack in monitoring the forums - If you can supply the source code for your renderer so far, I'll attempt to get it working properly (and add it the contrib project).

I'll turn this into a work item as well, so you can track it's progress.
Coordinator
Jan 13, 2007 at 4:20 AM
This discussion has been copied to Work Item 7270. You may wish to continue further discussion there.
Jan 19, 2012 at 6:06 AM
bittercoder wrote:
This discussion has been copied to Work Item 7270. You may wish to continue further discussion there.

Hi,

I wonder how to see the work item for the project? I am looking for the same thing and see if this thread has been dead. Thanks in advance.