1MP4(3)                      MP4 File Format Library                     MP4(3)
2
3
4

NAME

6       MP4ReadSampleFromTime - Read a track sample based on a specified time
7

SYNTAX

9       #include <mp4.h>
10
11       bool MP4ReadSampleFromEditTime(
12            MP4FileHandle hFile,
13            MP4TrackId trackId,
14            MP4Timestamp when,
15            u_int8_t** ppBytes,
16            u_int32_t* pNumBytes,
17            MP4Timestamp* pStartTime = NULL,
18            MP4Duration* pDuration = NULL,
19            MP4Duration* pRenderingOffset = NULL,
20            bool pIsSyncSample = NULL
21       );
22

ARGUMENTS

24       hFile  Specifies the mp4 file to which the operation applies.
25
26       trackId
27              Specifies the track to which the operation applies.
28
29       when   Specifies  which  sample  is  to  be read based on a time in the
30              track timeline. See MP4GetSampleIdFromTime() for details.
31
32       ppBytes
33              Pointer to the pointer to the sample data. See  DESCRIPTION  for
34              details on this argument.
35
36       pNumBytes
37              Pointer  to  variable that will be hold the size in bytes of the
38              sample.
39
40       pStartTime
41              If non-NULL, pointer to variable that will receive the  starting
42              timestamp for this sample. Caveat: The timestamp is in the track
43              timescale.
44
45       pDuration
46              If non-NULL, pointer to variable that will receive the  duration
47              for  this sample. Caveat: The duration is in the track timescale
48              units.
49
50       pRenderingOffset
51              If non-NULL, pointer to variable that will receive the rendering
52              offset for this sample. Currently the only media type that needs
53              this feature is MPEG video. Caveat: The offset is in  the  track
54              timescale units.
55
56       pIsSyncSample
57              If  non-NULL, pointer to variable that will receive the state of
58              the sync/random access flag for this sample.
59

RETURN VALUES

61       Upon success, true (1). Upon an error, false (0).
62

DESCRIPTION

64       MP4ReadSampleFromTime reads the sample corresponding to the time on the
65       track  timeline from the specified track. Typically this sample is then
66       decoded in a codec dependent fashion and  rendered  in  an  appropriate
67       fashion.
68
69       The  argument,  ppBytes, allows for two possible approaches for buffer‐
70       ing:
71
72       If the calling application wishes to handle its own  buffering  it  can
73       set *ppBytes to the buffer it wishes to use. The calling application is
74       responsible for ensuring that the buffer is large enough  to  hold  the
75       sample.  This can be done by using either MP4GetSampleSize() or MP4Get‐
76       TrackMaxSampleSize() to determine before-hand how large  the  receiving
77       buffer must be.
78
79       If the value of *ppBytes is NULL, then an appropriately sized buffer is
80       automatically malloc'ed for the sample data and *ppBytes  set  to  this
81       pointer.  The calling application is responsible for free'ing this mem‐
82       ory.
83
84       The last four arguments are pointers  to  variables  that  can  receive
85       optional sample information.
86
87       Typically for audio none of these are needed. MPEG audio such as MP3 or
88       AAC has a fixed sample duration and every sample  can  be  accessed  at
89       random.
90
91       For video, all of these optional values could be needed. MPEG video can
92       be encoded at a variable frame rate, with only occasional random access
93       points,  and  with "B frames" which cause the rendering (display) order
94       of the video frames to differ from the storage/decoding order.
95
96       Other media types fall between these two extremes.
97

SEE ALSO

99       MP4(3)   MP4ReadSample(3)   MP4GetSampleIdFromTime(3)    MP4ReadSample‐
100       FromEditTime(3)
101
102
103
104Cisco Systems Inc.                Version 0.9                           MP4(3)
Impressum