V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lsk569937453
V2EX  ›  程序员

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

  •  
  •   lsk569937453 · 159 天前 · 789 次点击
    这是一个创建于 159 天前的主题,其中的信息可能已经有所发展或是发生改变。

    两个视频信息如下:

    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 也没问出个所以然来,谷歌也没搜到正确的答案。

    2 条回复    2024-06-16 07:35:20 +08:00
    frayesshi1
        1
    frayesshi1  
       159 天前 via Android
    为什么不用 ffmpeg 啊,gstreamer 一般用在 Nvidia 小盒子里硬编解码的
    MrKrabs
        2
    MrKrabs  
       158 天前
    为什么不直接用傻瓜软件呢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1908 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 16:20 · PVG 00:20 · LAX 08:20 · JFK 11:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.