【问题标题】:How to add multiple audio streams to a video opened in vlc using python subprocess如何使用 python 子进程将多个音频流添加到在 vlc 中打开的视频中
【发布时间】:2020-03-21 01:09:00
【问题描述】:

我已经学习了如何使用python子进程在vlc中使用代码打开视频文件:

import os, subprocess

vlcPath = "C:/Program Files/VideoLAN/VLC/vlc.exe"
vid = "vid.mp4"
aud = "aud.mp3"
aud2 = "aud2.mp3"


#To open just the video in vlc, the following code works:

subprocess.Popen([vlcPath, vid])

现在如何让这段代码加载其他音频文件,以便它们同时作为编解码器加载,并且用户可以轻松地在 vlc 的特定音频文件之间切换。

我可以直接从 vlc 实现同时流式传输,通过将选项设置为另一个文件,单击“异步播放另一种媒体(额外音频文件,...)”选项并在额外媒体部分添加路径.

这样做时,vlc 添加了一个选项“:input-slave=[filename]

现在我该如何在 python 中做同样的事情,因为以下内容不起作用:

subprocess.Popen([vlcPath, vid, aud, aud2])

subprocess.Popen([vlcPath, "{} :input-slave={}".format(vid, aud)])

subprocess.Popen([vlcPath, vid, ":input-slave=", aud, ":input-slave=", aud2])

我在上面尝试的第一个和第三个解决方案,打开“vlcPath”之后的所有索引项目,作为 vlc 播放列表中的单独项目。第二种解决方案导致我出错。

我已尽力详细解释我的问题,但是如果您需要更多详细信息,请随时问我,我会尽力回答您的问题。

谢谢。

【问题讨论】:

    标签: python subprocess vlc


    【解决方案1】:

    好的,我刚刚找到了解决我自己问题的方法。

    我在以下帖子中从 Synetech 的 回答中找到了解决方案:https://superuser.com/questions/685507/how-to-play-a-soundless-video-and-add-a-audio-file-at-the-same-time

    为了使它正常工作,我所做的只是将 --input-slave= 添加到音频文件中,例如:

    subprocess.Popen([vlcPath, vid, "--input-slave="+aud])
    

    虽然,这可行,但如果我尝试使用此方法添加其他音频,它不起作用,即:

    subprocess.Popen([vlcPath, vid, "--input-slave="+aud,  "--input-slave="+aud2])
    

    这不起作用。

    因此,如果您对此也有解决方案,那将很有帮助。

    谢谢。

    【讨论】:

      【解决方案2】:

      答案为时已晚,但对于下一个人,您可以使用以下内容:

      subprocess.Popen([vlcPath, vid, "--input-slave="+aud+"#"+aud2])
      

      来自VLC command line documentation

        --input-slave=<string>     Input slave (experimental)
            This allows you to play from several inputs at the same time. This
            feature is experimental, not all formats are supported. Use a '#'
            separated list of inputs.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-04-11
        • 2013-11-17
        • 2018-04-02
        • 2023-01-26
        • 1970-01-01
        • 1970-01-01
        • 2011-11-02
        • 1970-01-01
        相关资源
        最近更新 更多