2013-01-03 29 views
1

我開發顯示了各種媒體的Qt應用程序。目前視頻文件存在問題。由於在使用Phonon與ATI圖形卡加速時出現了一些問題,我們目前在從屬模式下使用mplayer和vaapi。的Mplayer在從模式 - 多個實例

然而,有與加載文件的問題。每當新文件顯示時,mplayer都需要一些時間(大約2秒)才能加載,只顯示黑屏。由於大部分文件相當短(10 - 25秒),所以相當明顯。 第一個問題是 - 沒有任何人知道如何告訴MPlayer開始加載一個文件在播放前一個?可能嗎?

第二個:我想創建的mplayer的兩個實例,講述一個加載的第一個文件和其他加載第二個則告訴第二個暫停的。在第一個文件完成後,我將取消暫停第二個文件。我正在使用QProcesses,但現在第二個mplayer在第二個mplayer完成之前不會啓動,即使我沒有暫停它。在下面的代碼中,player1和player2是QProcess對象,在player1完成之前,player2不會開始做任何事情。所有「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; 
}   

回答

0

我不知道你是否已經找到了在此期間您的問題的解決方案,但我做從bash腳本類似的東西,並啓動多個實例的工作只是backgrounding罰款。雙mplayer技巧也很好,我想我可能不得不使用它。無論如何,我的bash在幾個小時後破解,但請注意,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