2017-02-15 67 views
5

我運行此命令可以將udp實時流傳輸到可使用正在構建的移動應用程序播放的http實時流。 它只是一個只有音頻流的流。ffmpeg從具有多個通道的輸入輸出單獨通道

的ffmpeg -i UDP:// @本地:1111 -map 0:一個http://localhost:8090/feed1.ffm

Input #0, mpegts, from 'udp://@localhost:1111': 
    Duration: N/A, start: 54616.264622, bitrate: 768 kb/s 
    Program 1 
    Metadata: 
    service_name : Service 1 
    service_provider: TLK 
    Stream #0:0[0x101]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
    Program 2 
Metadata: 
    service_name : Service 2 
    service_provider: TLK 
Stream #0:1[0x111]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 3 
Metadata: 
    service_name : Service 3 
    service_provider: TLK 
Stream #0:2[0x121]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 4 
Metadata: 
    service_name : Service 4 
    service_provider: TLK 
Stream #0:3[0x131]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
    Program 5 
Metadata: 
    service_name : Service 5 
    service_provider: TLK 
Stream #0:4[0x141]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
    Program 6 
Metadata: 
    service_name : Service 6 
    service_provider: TLK 
Stream #0:5[0x151]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
    Program 7 
Metadata: 
    service_name : Service 7 
    service_provider: TLK 
Stream #0:6[0x161]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 8 
Metadata: 
    service_name : Service 1 
    service_provider: TLK 
Stream #0:7[0x171]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 

我得到這個輸出

Stream mapping: 
    Stream #0:0 -> #0:0 (mp2 (native) -> mp2 (native)) 
    Stream #0:0 -> #0:1 (mp2 (native) -> mp2 (native)) 
Press [q] to stop, [?] for help 
size=  100kB time=00:00:07.19 bitrate= 113.8kbits/s speed=3.01x 
video:0kB audio:84kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 18.358242% 

我真的想要一個方法可以讓我能夠映射每個輸入流有一個輸出流,可以從另一個可以分開訪問,也許如果我需要第一個流也許我只會

ffplay http://localhost:8090/feed1.ffm 

,如果我需要第7流我只是

ffplay http://localhost:8090/feed7.ffm 

請誰能幫我破解這個問題。對於我目前的情況,FFmpeg沒有複雜的例子。

這是我的頭信息

[email protected]:~$ \ 
ffmpeg -i udp://@localhost:4000 \ 
    -map 0:a:0  http://localhost:8090/feed1.ffm 
    -map 0:a:1 http://localhost:8090/feed2.ffm 
    -map 0:a:2 http://localhost:8090/feed3.ffm 
    -map 0:a:3 http://localhost:8090/feed4.ffm 
    -map 0:a:4 http://localhost:8090/feed5.ffm 
    -map 0:a:5 http://localhost:8090/feed6.ffm 
    -map 0:a:6 http://localhost:8090/feed7.ffm 
    -map 0:a:7 http://localhost:8090/feed8.ffm 

的ffmpeg版本3.2.4-1〜16.04.york0版權所有(C)2000-2017 FFmpeg的開發人員使用GCC 5.4.1內置(Ubuntu的5.4.1-5ubuntu2 〜16.04.york1)20170210 配置:--prefix =/usr --extra-version ='1〜16.04.york0' - toolchain =硬化--libdir =/usr/lib/x86_64-linux-gnu --incdir =/usr/include/x86_64-linux-gnu --enable-gpl --disable -s剝離--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable- libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enab le-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy - enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 - enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint - 使-frei0r --enable-libopencv --enable-libx264 --enable共享 libavutil 55. 34.101/34.101 55. libavcodec的 57. 64.101/64.101 57. 了libavformat 57. 56.101/56.101 57. libavdevice 57. 1.100/57. 1.100 libavfilter 6. 65.100/6. 65.100 libavresample 3.1.0/3. 1. 0 libswscale 4 2.100/2.100 4. libswresample 2. 3.100/2 3.100 libpostproc 54 1.100/1.100 54.

Input #0, mpegts, from 'udp://@localhost:1111': 
    Duration: N/A, start: 60047.944622, bitrate: 768 kb/s 
    Program 1 
    Metadata: 
    service_name : Service 1 
    service_provider: TKL 
Stream #0:0[0x101]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 2 
Metadata: 
    service_name : Service 2 
    service_provider: TKL 
Stream #0:1[0x111]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 3 
Metadata: 
    service_name : Service 3 
    service_provider: TKL 
Stream #0:2[0x121]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 4 
Metadata: 
    service_name : Service 4 
    service_provider: TKL 
Stream #0:3[0x131]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 5 
Metadata: 
    service_name : Service 5 
    service_provider: TKL 
Stream #0:4[0x141]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 6 
Metadata: 
    service_name : Service 6 
    service_provider: TKL 
Stream #0:5[0x151]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 7 
Metadata: 
    service_name : Service 7 
    service_provider: TKL 
Stream #0:6[0x161]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Program 8 
Metadata: 
    service_name : Service 8 
    service_provider: TKL 
Stream #0:7[0x171]: Audio: mp2 ([3][0][0][0]/0x0003), 48000 Hz, stereo, s16p, 96 kb/s 
Output #0, ffm, to 'http://localhost:8090/feed1.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #0:0: Audio: mp2, 44100 Hz, mono, s16, 32 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Stream #0:1: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #1, ffm, to 'http://localhost:8090/feed2.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #1:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #2, ffm, to 'http://localhost:8090/feed3.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #2:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #3, ffm, to 'http://localhost:8090/feed4.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #3:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #4, ffm, to 'http://localhost:8090/feed5.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #4:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #5, ffm, to 'http://localhost:8090/feed6.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #5:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #6, ffm, to 'http://localhost:8090/feed7.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #6:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Output #7, ffm, to 'http://localhost:8090/feed8.ffm': 
Metadata: 
creation_time : now 
encoder   : Lavf57.56.101 
Stream #7:0: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s 
Metadata: 
    encoder   : Lavc57.64.101 mp2 
Stream mapping: 
Stream #0:0 -> #0:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #0:1 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #1:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #2:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #3:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #4:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #5:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #6:0 (mp2 (native) -> mp2 (native)) 
Stream #0:0 -> #7:0 (mp2 (native) -> mp2 (native)) 
Press [q] to stop, [?] for help 

這就是我的全控制檯。

回答

0

基本語法ffmpeg -i input1 -i input2 {switches} output1 {switches} output2...,所以

ffmpeg -i udp://@localhost:1111 -map 0:a:0 http://localhost:8090/feed1.ffm 
           -map 0:a:1 http://localhost:8090/feed2.ffm 
           -map 0:a:2 http://localhost:8090/feed3.ffm 
           ... 
+0

我試過了,它將第一個流複製到所有其他流 流映射:流#0:0 - >#0:0(mp2(native) - > mp2(native)) Stream#0:0 - > #0:1(mp2(native)) - > mp2(native)) Stream#0:0 - >#2 :0(mp2(native) - > mp2(native)) Stream#0:0 - >#4:0(mp2(native)) - > mp2(native)) Stream#0:0 - >#3:0 (mp2(native) - > mp2(native)) Stream#0:0 - >#6:0(mp2(native)) - > mp2(native)) Stream#0: (native) - > mp2(native)) Stream#0:0 - >#7:0(mp2(native) - > mp2(native)) 按[q]停止,[?]尋求幫助 –

+0

顯示完整的控制檯輸出。 – Mulvya

+0

這是短樣本的鏈接。它擁有全部8個流媒體頻道。請下載並嘗試模擬我的情況。 http://drive.google.com/open?id=0B12_TxWYu6LzMlBsTDVMN2RjZ1E –

2

你可以做到這一點的同時並行進程運行的ffmpeg的7種不同的情況;如果你願意的話。

讓每個ffmpeg實例解複用單個音頻流並輸出到相應的端口。

會去有點像這樣:

(ffmpeg -i udp://@localhost:1111 -map 0:a:0 http://localhost:8090/feed1.ffm) & (ffmpeg -i udp://@localhost:1111 -map 0:a:1 http://localhost:8090/feed2.ffm) & (ffmpeg -i udp://@localhost:1111 -map 0:a:2 http://localhost:8090/feed3.ffm) & and so on.

不會推薦它雖然會吃了你的CPU的能力。