如何用 gstreamer 进行 mp4 视频拼接?

12次阅读

共计 3770 个字符,预计需要花费 10 分钟才能阅读完成。

两个视频信息如下:

Properties:
  Duration: 0:01:12.100000000
  Seekable: yes
  Live: no
  Tags:
      video codec: H.264 / AVC
      container-specific-track-id: 1
      bitrate: 286767
      datetime: 2023-08-27T00:21:51Z
      container format: ISO MP4/M4A
  container #0: video/quicktime, variant=(string)iso
    Tags:
      datetime: 2023-08-27T00:21:51Z
      container format: ISO MP4/M4A

    video #1: video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4.2, profile=(string)constrained-baseline, codec_data=(buffer)0142402affe1001b2742402a95a01a80a1e693011000000300100000030288da1c32a001000428ce3c80, width=(int)1686, height=(int)1274, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)20/1, coded-picture-structure=(string)frame, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
      Tags:
        video codec: H.264 / AVC
        container-specific-track-id: 1
        bitrate: 286767

      Codec:
        video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4.2, profile=(string)constrained-baseline, codec_data=(buffer)0142402affe1001b2742402a95a01a80a1e693011000000300100000030288da1c32a001000428ce3c80, width=(int)1686, height=(int)1274, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)20/1, coded-picture-structure=(string)frame, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
      Stream ID: 300fa2d73257adb55ba1f7b66d59e5f3a02d95809b27cad83b8aeee34ca206d7/001
      Width: 1686
      Height: 1274
      Depth: 24
      Frame rate: 20/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 286767
      Max bitrate: 0
Properties:
  Duration: 0:00:08.541000000
  Seekable: yes
  Live: no
  Tags:
      audio codec: MPEG-4 AAC audio
      maximum bitrate: 64000
      bitrate: 64000
      language code: en
      container-specific-track-id: 1
      datetime: 2018-06-14T03:53:44Z
      QT atom: buffer of 33 bytes
      container format: ISO MP4/M4A
      video codec: H.264 / AVC
  container #0: video/quicktime, variant=(string)iso
    Tags:
      datetime: 2018-06-14T03:53:44Z
      QT atom: buffer of 33 bytes
      container format: ISO MP4/M4A

    audio #1: audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, level=(string)2, base-profile=(string)lc, profile=(string)lc, codec_data=(buffer)1208, rate=(int)44100, channels=(int)1
      Tags:
        audio codec: MPEG-4 AAC audio
        maximum bitrate: 64000
        bitrate: 64000
        language code: en
        container-specific-track-id: 1

      Codec:
        audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, level=(string)2, base-profile=(string)lc, profile=(string)lc, codec_data=(buffer)1208, rate=(int)44100, channels=(int)1
      Stream ID: ce71f7e55d3b89b717642b27ff2725345d4ecdc789036440d8e659aa9c8e39d0/001
      Language: en
      Channels: 1 (unknown layout)
      Sample rate: 44100
      Depth: 32
      Bitrate: 64000
      Max bitrate: 64000
    video #2: video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4, profile=(string)baseline, codec_data=(buffer)01428028ffe1001267428028da01100f1e5e520a0c0c0da1426a01000468ce06e2, width=(int)1080, height=(int)1920, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)bt709, framerate=(fraction)0/1, coded-picture-structure=(string)frame, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
      Tags:
        video codec: H.264 / AVC
        language code: en
        container-specific-track-id: 2
        bitrate: 13165685

      Codec:
        video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4, profile=(string)baseline, codec_data=(buffer)01428028ffe1001267428028da01100f1e5e520a0c0c0da1426a01000468ce06e2, width=(int)1080, height=(int)1920, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)bt709, framerate=(fraction)0/1, coded-picture-structure=(string)frame, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
      Stream ID: ce71f7e55d3b89b717642b27ff2725345d4ecdc789036440d8e659aa9c8e39d0/002
      Width: 1080
      Height: 1920
      Depth: 24
      Frame rate: 0/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 13165685
      Max bitrate: 0

需求如下:

  • 把第二个视频放到第一个视频的后面然后拼接成一个 mp4 视频。不是同一个画面内左右拼接两个视频。
  • 只用 gstreamer 相关的,代码也可以,命令行也行。

问了 chatgpt 也没问出个所以然来,谷歌也没搜到正确的答案。

正文完
 0