1

我正在尝试使用 copy /b init.mp4 + audio.mp4 complie.mp4 来编译 init.mp4 及其音频文件

它正在编译,但无法在 vlc 和 ffmpeg 上播放。

当我检查 mpd 文件时,我看到它有音频

            <SegmentTemplate timescale="48000" media="57_audio_1_17_$Number$.mp4?m=1532401844" initialization="57_audio_1_17_init.mp4?m=1532401844" startNumber="6815976">
                <SegmentTimeline>
                    <S t="1521333224447" d="479232" r="1"/>
                    <S t="1521334182911" d="483328"/>
                    <S t="1521334666239" d="479232" r="3"/>
                    <S t="1521336583167" d="483328"/>
                    <S t="1521337066495" d="479232" r="3"/>
                    <S t="1521338983423" d="483328"/>
                    <S t="1521339466751" d="479232" r="4"/>
                    <S t="1521341862911" d="483328"/>
                    <S t="1521342346239" d="479232" r="3"/>
                    <S t="1521344263167" d="483328"/>
                    <S t="1521344746495" d="479232" r="3"/>
                    <S t="1521346663423" d="483328"/>
                    <S t="1521347146751" d="479232" r="4"/>
                    <S t="1521349542911" d="483328"/>
                    <S t="1521350026239" d="479232" r="3"/>
                    <S t="1521351943167" d="483328"/>
                    <S t="1521352426495" d="479232" r="3"/>
                    <S t="1521354343423" d="483328"/>
                    <S t="1521354826751" d="479232" r="4"/>
                    <S t="1521357222911" d="483328"/>
                    <S t="1521357706239" d="479232" r="3"/>
                    <S t="1521359623167" d="483328"/>
                    <S t="1521360106495" d="479232" r="3"/>
                    <S t="1521362023423" d="483328"/>
                    <S t="1521362506751" d="479232" r="4"/>
                    <S t="1521364902911" d="483328"/>
                    <S t="1521365386239" d="479232" r="3"/>
                    <S t="1521367303167" d="483328"/>
                    <S t="1521367786495" d="479232" r="3"/>
                    <S t="1521369703423" d="483328"/>
                    <S t="1521370186751" d="479232" r="4"/>
                    <S t="1521372582911" d="483328"/>
                    <S t="1521373066239" d="479232" r="3"/>
                    <S t="1521374983167" d="483328"/>
                    <S t="1521375466495" d="479232" r="3"/>
                    <S t="1521377383423" d="483328"/>
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>

有人可以解释它是什么吗?那些 t,r,d 值是。如何将这些音频片段添加到 complie.mp4 并使其播放?

4

1 回答 1

2

首先,您需要下载 init.mp4,然后根据 SegmentTimeline 下载片段。

对于 a <SegmentTemplate>,通常使用<SegmentTimeline>标签来指示每个段的长度以及哪些段重复。时间刻度(表示一秒的单位)通常作为属性的一部分包含在内,<SegmentTemplate>以便我们可以基于此单位计算段的时间。在下面的示例中,<S>标签表示片段标签,d属性指定片段的长度,r属性指定相同持续时间重复的片段数量,以便$Time$可以正确计算以下载media属性中指定的媒体片段。

<SegmentTemplate>
  timescale="48000"
  initialization="$RepresentationID$-init.dash"
  media="$RepresentationID$-$Time$.dash"
    startNumber="1">
    <SegmentTimeline>
      <S t="0" d="96256" r="2" />
      <S d="95232" />
      <S d="96256" r="2" />
      <S d="95232" />
      <S d="96256" r="2" />
   </SegmentTimeline>
</SegmentTemplate>

以下是表示中的段模板示例。它使用 $Time$ 变量。

<SegmentTemplate timescale="30000" media="155_video_1_2_$Time$.mp4?m=1545421124" initialization="155_video_1_2_init.mp4?m=1545421124" startNumber="710">
  <SegmentTimeline>
       <S t="255197799" d="360360" r="8"/>
       <S t="258441039" d="334334"/>
  </SegmentTimeline>
</SegmentTemplate>

第一段的请求 URL 是155_video_1_2_ 255197799 .mp4。持续时间为 360360,下一个片段请求是155_video_1_2_ 255558159 .mp4,依此类推,直到第 9 个片段。

最后的片段请求是155_video_1_2_ 258441039 .mp4

如果段模板使用 $Number$ 而不是 $Time$,那么您在开始编号处下载文件,然后重复 r 指示的次数。

<AdaptationSet
            bitstreamSwitching="false"
            contentType="video"
            id="1"
            mimeType="video/mp4"
            segmentAlignment="true">
            <SegmentTemplate
                initialization="$RepresentationID$/init.mp4"
                media="$RepresentationID$/$Number$.m4f"
                startNumber="218646"
                timescale="90000">
                <SegmentTimeline>
                    <S
                        d="540540"
                        r="28"/>
                </SegmentTimeline>
            </SegmentTemplate>
            <Representation
                bandwidth="1199626"
                codecs="avc1.4D001E"
                frameRate="90000/3003"
                height="480"
                id="5501_video_seg_auto_video_32"
                width="528"/>
        </AdaptationSet>

第一个文件将是起始编号,然后重复段 28 次。所以 start + 28 是 29 个文件加上 init.mp4。

218646.m4f
218647.m4f
218648.m4f
218649.m4f
218650.m4f
218651.m4f
218652.m4f
218653.m4f
218654.m4f
218655.m4f
218656.m4f
218657.m4f
218658.m4f
218659.m4f
218660.m4f
218661.m4f
218662.m4f
218663.m4f
218664.m4f
218665.m4f
218666.m4f
218667.m4f
218668.m4f
218669.m4f
218670.m4f
218671.m4f
218672.m4f
218673.m4f
218674.m4f
init.mp4

然后,您可以将片段转换为 .mp4 文件。

cat init.mp4 > source.mp4
cat segment-1.m4f >> source.mp4
cat segment-2.m4f >> source.mp4
...

参考:

https://developers.google.com/cast/docs/mpl/streaming_protocols

https://docs.aws.amazon.com/mediapackage/latest/ug/segtemp-format.html

将 MPEG-DASH 片段(例如,init.mp4 + segments.m4s)组合回完整的 source.mp4?

于 2019-04-10T14:52:26.167 回答