1

我使用具有以下配置的 GCP Transcoder API:

  • 节点JS 12

  • Firebase 存储

  • Firestore 数据库

  • GCP CDN

  • 上传作业开始(firebase 功能)

      const config = {
        "elementaryStreams": [
          {
            "videoStream": {
              "codec": "h264",
              "tune": 'zerolatency',
              "preset": 'superfast',
              "heightPixels": 360,
              "widthPixels": 640,
              "bitrateBps": 400000,
              "rateControlMode": "vbr",
              "frameRate": 30,
              "crfLevel": 26,
              "gopMode": { "gopDuration": "1.0s",  }
            },
            "key": "video-stream0"
          },
          {
            "videoStream": {
              "codec": "h264",
              "tune": 'zerolatency',
              "preset": 'superfast',
              "heightPixels": 480,
              "widthPixels": 854,
              "bitrateBps": 1500000,
              "rateControlMode": "vbr",
              "frameRate": 60,
              "crfLevel": 26,
              "gopMode": { "gopDuration": "1.0s",  }
            },
            "key": "video-stream1"
          },
          {
            "videoStream": {
              "codec": "h264",
              "tune": 'zerolatency',
              "preset": 'superfast',
              "heightPixels": 720,
              "widthPixels": 1280,
              "bitrateBps": 3000000,
              "rateControlMode": "vbr",
              "frameRate": 60,
              "crfLevel": 26,
              "gopMode": { "gopDuration": "1.0s",  }
            },
            "key": "video-stream2"
          },
          {
            "key": "audio-stream0",
            "audioStream":  {
              "codec":  "aac",
              "bitrateBps":  128000,
              "channelCount": 2,
              "channelLayout": ["fl", "fr"],
              "sampleRateHertz": 48000,
            }
          }
        ],
        "muxStreams": [
          {
            "key": "video-only-sd",
            "container": "fmp4",
            "elementaryStreams": [ "video-stream0" ],
            "segmentSettings": { 
              "segmentDuration": { "seconds": "2.0s" },
              "individualSegments": true 
            },
          },
          {
            "key": "video-only-md",
            "container": "fmp4",
            "elementaryStreams": [ "video-stream1" ],
            "segmentSettings": { 
              "segmentDuration": { "seconds": "2.0s" },
              "individualSegments": true 
            },
          },
          {
            "key": "video-only-hd",
            "container": "fmp4",
            "elementaryStreams": [ "video-stream2" ],
            "segmentSettings": { 
              "segmentDuration": { "seconds": "2.0s" },
              "individualSegments": true 
            },
          },
          {
            "key": "audio-only",
            "container": "fmp4",
            "elementaryStreams": [ "audio-stream0" ],
            "segmentSettings": { 
              "segmentDuration": { "seconds": "2.0s" },
              "individualSegments": true 
            }
          }
        ],
        "manifests": [
          {
            "fileName": "master.m3u8",
            "type": "HLS",
            "muxStreams": [
              "video-only-sd",
              "video-only-md",
              "video-only-hd",
              "audio-only"
            ]
          }
        ],
    

输出摘录:在此处输入图像描述

视频在各种播放器上运行良好,也适应带宽,但在 iPhone 上没有声音。可能原因:音频文件已生成,但与生成的视频文件数量不同。在大约 10 秒。视频,还有一个音频文件。

知道我忘记、忽略或错误定义或解释了什么吗?

4

1 回答 1

0

在 ElementaryStreams 中,您可以定义音频和视频流。MuxStreams 包含视频和音频的混合流,这是您想要的输出。您需要在此处添加音频流。

代替

"elementaryStreams": [ "video-stream0" ],

"elementaryStreams": [ "video-stream0", "audio-stream0" ],
于 2021-11-05T17:24:44.407 回答