With this feature that is also called "transwrapping", you can trim a local file, capture a network stream to a local file, or transcode a list of files in a single file of the same or different container. Note, that for a playlist all the files should be of the same codecs and format (resolution, frame rate, etc).
The feature is based on an approach where data packets from a source (a network stream or a file) are extracted and the same packets are used to create new frames in the output file. The packets are not changed in this process. And as a result, you'll get a direct copy of your source file.
It is similar to the FFmpeg "copy" feature, but it works differently within SDKs.
Required settings
Transcoding works within a single process - in this mode, the packets are processed within a single thread so they are not changed. To work in a single process, for a source object and for the received one "external_process" should be disabled. Additional settings enable direct extraction of packets and their processing.
MFormats
m_objMFReader.PropsSet("experimental.mfcodecs", "true");
m_objMFReader.PropsSet("experimental.out_video_packets", "true");
m_objMFReader.PropsSet("experimental.out_audio_packets", "true");
m_objMFReader.PropsSet("external_process", "false");
m_objWriter.PropsSet("external_process", "false");
MPlatform
For MPlaylist, you should set the properties directly the moment you add a file to the playlist:
m_objPlaylist.PlaylistAdd(null, openMediaFile.FileNames[i], "external_process=false experimental.mfcodecs=true experimental.out_video_packets=true experimental.out_audio_packets=true", ref nIndex, out pFile);
For MFile, the properties should be set within a FileNameSet method:
myFile.FileNameSet(pathToFile, "external_process=false experimental.mfcodecs=true experimental.out_video_packets=true experimental.out_audio_packets=true");
and for MWriter you should disable external processing:
m_objWriter.PropsSet("external_process", "false");
Important! This feature works for original video sources only. Don't use any conversion, i.e. FormatVideoSet(eMFT_Convert, ...) or SourceFrameConvertedGet methods.
If you set the "experimental.out_video_packets" to "true" or "1", the video is still decoded so you can use it for preview. If you don't need the preview and you'd like to increase the overall speed of the encoding, consider setting the following:
m_objMFReader.PropsSet("experimental.out_video_packets", "2");
m_objMFReader.PropsSet("experimental.out_audio_packets", "2");
In this case, the video and audio data is not decoded.
Encoding configuration
You should use a specific video and audio codecs for transcoding - "packets" as a video codec and "audio_packets" as an audio codec. For example, for MP4 container, the encoding configuration looks like:
format='mp4' video::codec='packets' audio::codec='packets'