2.6 File

2.6.1 Playlist format

If user wants to present multiple files as a single seamless file and/or user wants to use only a part of a file, then one can utilize a playlist for that purpose. Playlist is a simple text file with a list of file paths; each file must be located on the new line, like this:

C:\path\rec1.mp4
C:\path\rec2.mp4
C:\path\rec3.mp4

Playlist file extension must be .pls or .m3u.

All files in a playlist MUST have exactly the same encoding settings, including low level parameters; i.e., they must be recorded from one source or encoded using the same encoder/tool with the same settings. User CAN'T combine files recorded from different sources in one playlist. If a user wants to do it, then one has to transcode all the files to exactly the same output format using exactly the same encoding settings. A user can do it with FFmpeg, for example.

In addition to that, playback interval command is supported:

#EXT-X-VAST-INTERVAL:<from>-<to>

Both <from> and <to> parameters are optional. If <from> is not specified, then it is assumed that data will be read from the beginning of a file. If <to> is not specified, then it is assumed that data will be read till the end of a file.

When specified, <from> and <to> must be in a format parseable by the TimeSpan class.

It should be understood that position of <from> and <to> will be actually aligned to the keyframes nearest to them, because splicing of several files can be done only on keyframes. For <from>, by default, a keyframe that is equal to or preceding the indicated position will be used. For <to>, a keyframe that is equal to or following the indicated position will be used. But keyframe alignment can be changed in file opening parameters. Accordingly, the real range of every file with previously set parameter EXT-X-VAST-INTERVAL can be slightly different from what has been defined by a user because of keyframes alignment.

Examples:

Both <from> and <to> intervals are specified:

#EXT-X-VAST-INTERVAL:0:01:05.000-0:01:15.000

Only <from> is specified (reading till the end of a file):

#EXT-X-VAST-INTERVAL:0:01:05.000-

Only <to> is specified (reading from the beginning of a file):

#EXT-X-VAST-INTERVAL:-0:01:15.000

This line has to be placed before the line with file path, e.g.:

#EXT-X-VAST-INTERVAL:0:01:05.000-0:01:15.000
C:\path\rec1.mp4

Playback interval indicating NTP timestamps is also supported:

#EXT-X-VAST-NTP-INTERVAL:<from>-<to>

Both <from> and <to> parameters are optional. If <from> is not specified, then it is assumed that data will be read from the beginning of a file. If <to> is not specified, then it is assumed that data will be read till the end of a file.

When specified, <from> and <to> are absolute NTP timestamps. They can be decimal or hexadecimal numbers.

EXT-X-VAST-NTP-INTERVAL can only be used with mp4 files written by VASTreaming library and containing NTP timestamp.

Positions of <from> and <to> are also aligned to the keyframes nearest to them, because splicing of several files can be done only on keyframes. For <from>, by default, a keyframe that is equal to or preceding the set position will be used. For <to>, a keyframe that is equal to or following the indicated position will be used. But keyframe alignment can be changed in file opening parameters. Accordingly, the real range of every file with previously set parameter EXT-X-VAST-NTP-INTERVAL can be different from what has been defined by a user because of keyframes alignment.

Example:

#EXT-X-VAST-NTP-INTERVAL:0xe5a5b9370e71f70e-0xe5a5b9c31b186799

This line has to be placed before the line with file path, e.g.:

#EXT-X-VAST-NTP-INTERVAL:0xe5a5b9370e71f70e-0xe5a5b9c31b186799
C:\path\rec1.mp4



2.6.2 Classes

FileCache is a class which can be used for caching internet and local files, including video and image files. In case of mp4, FileCache implements advanced algorithm of metadata sharing, described in the previous paragraph; i.e., it saves memory and processor time while opening new file copies.

FileSource is an object implementing interface of IInteractiveMediaSource and allowing use of a playlist as a single seamless file. Separate files inside the playlist can be .mp4, .mp3, .wav, or .ts. Besides, a playlist can be set not only as a text file but as an inline URI.

Supported URI format is "content:\n<inline-playlist>", for example:

fileSource.Uri =
@"content:
#EXT-X-VAST-INTERVAL:0:01:05.000-
T:\file1.mp4
T:\file2.mp4
#EXT-X-VAST-INTERVAL:0:00:00-0:00:33.133
T:\file3.mp4";

MpaSource - an object inherited from IInteractiveMediaSource which allows opening MP1, MP2, MP3 audio files.

WavSource - an object inherited from IInteractiveMediaSource which allows opening WAV audio files.



2.6.3 MP4 utilities

VASTreaming library provides user with several utilities for manipulating mp4 files directly from a user code.

AudioMixer allows mixing audio tracks of two or more mp4 files into one output audio track. Video is copied from the first source file.

Concatenator- a utility for splicing of two or more mp4 files. It is also can be used for cutting one file if user sets only one file as a parameter and indicates start and end timestamps for this file.

ImageExtractor is intended for extracting of an image from a previously set position of an original mp4 file and saving it as a JPEG image.

VideoMixer is intended for mixing source mp4 file with one or more images including animated images e.g., GIFs.

contact us

info@vastreaming.net