【问题标题】:Mplayer in slave mode - multiple instances从属模式下的 Mplayer - 多个实例
【发布时间】:2013-01-03 14:00:05
【问题描述】:

我正在开发一个显示各种媒体的 Qt 应用程序。目前视频文件存在问题。由于在使用带 ATI 显卡加速的 Phonon 时存在一些问题,我们目前在从属模式下使用 mplayer 和 vaapi。

但是,加载文件存在问题。每次显示新文件时,mplayer 需要一些时间(大约 2 秒)来加载它,只显示黑屏。由于大多数文件都很短(10 - 25 秒),因此非常引人注目。 第一个问题是 - 有人知道如何告诉 mplayer 在播放前一个文件时开始加载一个文件吗?有可能吗?

第二个:我正在考虑创建两个 mplayer 实例,告诉一个加载第一个文件,另一个加载第二个文件,然后告诉第二个暂停。第一个文件完成后,我会取消暂停第二个文件。我正在使用 QProcesses,但现在第二个 mplayer 在第二个完成之前不会启动,即使我没有暂停它。在下面的代码中,player1 和 player2 是 QProcess 对象,player2 在 player1 完成之前不会开始做任何事情。所有“readyRead ...”插槽都是我解析 mplayer 输出的函数。到目前为止,他们并没有做太多,只是将输出打印到 qDebug()。

你知道为什么这两个进程不一起开始吗?例如,如果我在 player1 中使用 mplayer,在 player2 中使用 vlc,它可以正常工作,并且我可以从命令行运行两个 mplayer 实例。

bool Player::run(){
    QStringList args;
    args << "-va" << "vaapi" << "-vo" << "vaapi:gl" << "-noborder" << "-framedrop" << "-v" << "-slave" << "-idle";
    connect(&player1, SIGNAL(readyReadStandardError()), this, SLOT(readyReadErr1()));
    connect(&player1, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadOut1()));
    connect(&player2, SIGNAL(readyReadStandardError()), this, SLOT(readyReadErr2()));
    connect(&player2, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadOut2()));
    player1.start("mplayer", args << "-geometry" << "860x540+0+0");
    player2.start("mplayer", args << "-geometry" << "860x540+800+500");
    player1.write("loadfile w_1.avi 1\n");
    player2.write("loadfile w_2.avi 1\n");

    if (!player1.waitForStarted(5000))
    {
        return false;
    }
    player2.waitForStarted(5000);

    player1.waitForFinished(50000);

    player2.waitForFinished(10000);
    return true;
}        

【问题讨论】:

    标签: qt qprocess mplayer


    【解决方案1】:

    我不知道您是否同时找到了解决问题的方法,但我正在从 bash 脚本中执行类似的操作,并且启动多个实例在后台运行时效果很好。双 mplayer 技巧也不错,我想我可能不得不使用它。无论如何,几个小时后我的 bash hack,但请注意,FIFO 目前只为其中一个创建,我正在考虑一个好的命名方案:

    #!/bin/bash
    
    set -e
    
    set -u
    
    # add working directory to $PATH
    export PATH=$(dirname "$0"):$PATH
    
    res_tuple=($(xres.sh))
    max_width="${res_tuple[0]}"
    max_height="${res_tuple[1]}"
    
    echo "w = $max_width, h = $max_height"
    
    mplayer() {
      /home/player/Downloads/vaapi-mplayer/mplayer \
        -vo vaapi \
        -va vaapi \
        -fixed-vo \
        -nolirc \
        -slave \
        -input file="$5"\
        -idle \
        -quiet \
        -noborder \
        -geometry $1x$2+$3+$4 \
        { /home/player/Downloads/*.mov } \
        -loop 0 \
        > /dev/null 2>&1 &
    }
    
    mfifo() {
      pipe='/tmp/mplayer.pipe'
    
      if [[ ! -p $pipe ]]; then
        mkfifo $pipe
      fi
    }
    
    half_width=$(($max_width / 2))
    half_height=$(($max_height / 2))
    
    mfifo
    
    mplayer $half_width $half_height 0 0 $pipe 
    mplayer $half_width $half_height $half_width 0 $pipe
    mplayer $half_width $half_height 0 $half_height $pipe
    mplayer $half_width $half_height $half_width $half_height $pipe
    

    【讨论】:

      猜你喜欢
      • 2013-03-29
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多