0

我正在开发一个媒体播放器应用程序:播放 ISDB-T 音频和视频。我正在使用 GStreamer 进行解码和渲染。

为了让 AV Sync 完美运行,我应该规范文件读取:这样数据就不会太快或太慢地推送到 Gstreamer。

If I know the duration of TS file before hand, then I can regulate my reads. But how to calculate the TS file duration ?

因为,我需要使用多个 TS 文件验证应用程序,无法使用某些实用程序计算持续时间并不断更改文件读取 - 如何在程序中实现?

谢谢,

克兰蒂

4

2 回答 2

2

如果你对传输流内部的编码和PES层有足够的了解,那么你可以读取TS中的时间戳并自己计算。它需要查找到文件末尾,查找最后一个时间戳,并在文件开头减去同一程序的第一个时间戳。

编辑:除了上述方法之外,您还需要包括最后一帧持续时间。
((last_pts - first_pts) + frame_duration) / pts_resolution

假设您有一个持续时间为 6.006 秒的 30 fps 片段
((1081080 - 543543) + 3003) / 90000 = 6.006

于 2013-05-13T07:50:47.453 回答
1

in most cases, each PES header contains a PTS and/or DTS, which is measured in 90kHz frequency. so the steps may include:

  1. find the program you need to demux from MPEG TS.
  2. find the PID of stream.
  3. find the first TS packet with PID found, and payload_start_indicator set to 1; that will be the starting of a PES frame, which will contain a PES header.
  4. Parse the PES header to find the starting PTS of the stream.
  5. parse the file backwards from end, to find a packet with same PID and payload_start_indicator set, which will contain the last PTS. find thier difference, divide it by 90000 will give duration in Seconds
于 2016-11-22T11:53:15.380 回答