2017-02-22 113 views
0

我正在使用nginx和rtmp模塊來傳輸實時hls和mpeg-dash。 這裏是我的nginx的RTMP命令的.confffmpeg exec命令不在nginx中運行rtmp

rtmp { 
server { 
    listen 1936; 


    application mypull { 
    live on ; 
    meta copy; 
    allow play all; 

    pull rtmp://184.72.239.149/vod/BigBuckBunny_115k.mov name=test live=1; 


    exec_push /usr/bin/ffmpeg -re -i rtmp://localhost:1936/mypull/$name -vcodec libx264 -acodec libmp3lame -f flv rtmp://localhost:1936/hls/$name; 


} 


application dash { 
     live on; 
     dash on; 
     dash_path /tmp/dash; 
     dash_nested on; 
     dash_fragment 5s; 
     dash_playlist_length 30s; 
    } 
    application hls { 
     live on; 
     hls on; 
    hls_playlist_length 30s; 
    hls_fragment 5s; 
     hls_path /tmp/hls; 
    } 
} 
} 

,但它是不是在玩。似乎ffmpeg命令甚至沒有運行。並且hls和破折號文件夾是空的。任何人都可以幫助我嗎?

+0

與實際流ID替換變量後,確實在命令行的ffmpeg的命令工作? –

+0

這是真正的id,我的nginx.conf就是這樣。它不會創建任何輸出。 @GergelyLukacsy – evan

+0

不可以。流ID是在'$ name'變量中被替換的。當您打開流時,URL如下所示:'rtmp://server.com:1935/mypull/12345',其中'12345'是您的流ID。 我想你可以在這種情況下替換任何東西,所以試試這是你的控制檯: 'ffmpeg -re -i rtmp:// localhost:1936/mypull/123 -vcodec libx264 -acodec libmp3lame -f flv rtmp:// localhost:1936/hls/123' 另外,請確保端口在您的防火牆設置中打開。你爲什麼使用1936作爲RTMP?默認是1935. –

回答

0

將ffmpeg命令放入bash腳本中。例如,我的bash腳本被命名爲ff.sh,並存儲在文件夾/文件

把整個ffmpeg的命令腳本,並使其可執行:

chmod +x /files/ff.sh 

exec_push的腳本nginx的。 conf

application origin { 
live on; 
exec_push /files/ff.sh; 
} 

您可能會發現這適用於您。

0

編輯您的nginx.conf文件,並把在第一線:

user root; 

這將運行命令,作爲根