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. Below you can find additional settings you need to set.
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");
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");
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 codec. For example, for MP4 container, the encoding configuration looks like:
format='mp4' video::codec='packets' audio::codec='packets'
DVB Subtitles transwrapping
Since SDK version 2.7.2 you can also transwrap DVB Subtitles. For example, your source has two subtitle tracks, to transwrapp them into TS file, you should follow these steps:
1. Disable "external_process" for MFReader/MFile object as usual.
2. Select desired subtitle tracks and set "experimental.out_subtitle_packets" to "true".
As a result you will get:
myFile.FileNameSet(pathToFile, "external_process=false experimental.mfcodecs=true experimental.out_video_packets=true experimental.out_audio_packets=true experimental.out_subtitle_packets=true subtitle_track=0,1");
4. Set "packets" as subtitles codec in the Writer config string. Also, you can specify subtitles metadata:
format='mpegts' video::codec='packets' audio::codec='packets' subtitle::codec='packets' subtitle.1::codec='packets' subtitle::metadata::language='eng' subtitle.1::metadata::language='ger'
5. Run the transcoding process.
Please note that if you set the "experimental.out_subtitle_packets" to "true" (equal to "1"), subtitles are still decoded so you can use them for preview (as this described in the according article - Displaying-DVB-subtitles-from-TS-file), but they also will be burned-in to the recorded file. If you don't need the preview, you can set the "experimental.out_subtitle_packets" to "2".