本文介绍了ffmpeg从具有多个通道的输入输出独立通道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行此命令能够将udp直播流传输到使用正在构建的移动应用程序可播放的http直播流。
它只是一个只有音频流的流。



ffmpeg -i udp:// @ localhost:1111 -map 0:a

 输入#0,mpegts,from'udp:// @ localhost:1111':
持续时间:N / A,开始:54616.264622,比特率:768 kb / s
程序1
元数据:
service_name:服务1
service_provider:TLK
流#0:0 [0x101]:音频:mp2([3] [0] [0] [0 ] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序2
元数据:
service_name:服务2
service_provider:TLK
流#0 :1 [0x111]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序3
元数据:
service_name:Service 3
service_provider:TLK
流#0:2 [0x121]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序4
元数据:
service_name:服务4
s ervice_provider:TLK
流#0:3 [0x131]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序5
元数据:
service_name:服务5
service_provider:TLK
流#0:4 [0x141]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序6
元数据:
service_name:服务6
service_provider:TLK
流#0:5 [0x151]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序7
元数据:
service_name:Service 7
service_provider:TLK
流#0:6 [0x161]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序8
元数据:
service_name:服务1
service_provider:TLK
流#0:7 [0x171]音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s

我得到这个输出

 流映射:
流#0:0 - > #0:0(mp2(native))> mp2(native))
流#0:0 - > #0:1(mp2(本机) - > mp2(本机))
按[q]停止,[?]寻求帮助
size = 100kB time = 00:00:07.19 bitrate = 113.8 kbits / s speed = 3.01x
视频:0kB音频:84kB字幕:0kB其他流:0kB全局头文件:0kB多路复用开销:18.358242%

我真的想要一种方式,我可以将每个输入流映射到一个输出流,可以与另一个分开访问,如果我需要第一个流,也许我会只是

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

如果我需要第七个流,我将只是

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

请帮助我解决这个问题。 FFmpeg没有我现在的情况的复杂的例子。



这是我的头信息

  ubuntu @ ip-localhost:〜$ \ 
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://本地主机:8090 / feed8.ffm

ffmpeg版本3.2.4-1〜16.04.york0版权所有(c )2000-2017用gcc 5.4.1(Ubuntu 5.4.1-5ubuntu2〜16.04.york1)构建的FFmpeg开发人员20170210
配置:--prefix = / usr --extra-version ='1〜16.04.york0 ' - toolchain = hardened --libdir = / usr / lib / x86_64-linux-gnu --incdir = / usr / include / x86_64-linux-gnu --enable-gpl --disable-stri pping --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 --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable- libous --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 --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57。 56.101
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 / 4.2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

 输入#0,mpegts,从'udp:// @ localhost:1111':
持续时间:N / A,开始:60047.944622,比特率:768 kb / s
程序1
元数据:
service_name:服务1
service_provider:TKL
流#0:0 [0x101]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序2
元数据:
service_name:服务2
service_provider:TKL
流#0:1 [0x111]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序3
元数据:
service_name: 3
service_provider:TKL
流#0:2 [0x121]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
Pro gram 4
元数据:
service_name:服务4
service_provider:TKL
流#0:3 [0x131]:音频:mp2([3] [0] [0] [ 0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序5
元数据:
service_name:服务5
service_provider:TKL
流# 0:4 [0x141]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序6
元数据:
service_name:服务6
service_provider:TKL
流#0:5 [0x151]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz ,立体声,s16p,96 kb / s
程序7
元数据:
service_name:服务7
service_provider:TKL
流#0:6 [0x161]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
程序8
元数据:
service_name:
service_provider:TKL
流#0:7 [0x171]:音频:mp2([3] [0] [0] [0] / 0x0003),48000 Hz,立体声,s16p,96 kb / s
输出#0,ffm到'http:// localhost:8090 / feed1.ffm':
Metad ata:
creation_time:now
编码器:Lavf57.56.101
流#0:0:音频:mp2,44100 Hz,mono,s16,32 kb / s
元数据:
编码器:Lavc57.64.101 mp2
流#0:1:音频:mp2,44100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57.64.101 mp2
输出#1,ffm,到'http:// localhost:8090 / feed2.ffm':
元数据:
creation_time:now
encoder:Lavf57.56.101
流#1:0:音频:mp2,44100Hz,立体声,s16,64kb / s
元数据:
编码器:Lavc57.64.101 mp2
输出#2,ffm, http:// localhost:8090 / feed3.ffm':
元数据:
创建时间:现在
编码器:Lavf57.56.101
流#2:0:音频:mp2,44100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57.64.101 mp2
输出#3,ffm到http:// localhost:8090 / feed4.ffm :
元数据:
creation_time:now
编码器:Lavf57.56.101
流#3:0:音频:mp2,4 4100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57.64.101 mp2
输出#4,ffm到http:// localhost:8090 / feed5.ffm ':
元数据:
创建时间:现在
编码器:Lavf57.56.101
流#4:0:音频:mp2,44100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57.64.101 mp2
输出#5,ffm到http:// localhost:8090 / feed6.ffm:
元数据:
creation_time:now
编码器:Lavf57.56.101
流#5:0:音频:mp2,44100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57 .64.101 mp2
输出#6,ffm到'http:// localhost:8090 / feed7.ffm':
元数据:
creation_time:now
encoder:Lavf57.56.101
流#6:0:音频:mp2,44100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57.64.101 mp2
输出#7,ffm ,到'http:// localhost:8090 / feed8.ffm':
元数据:
creation_time:now
encoder:L avf57.56.101
流#7:0:音频:mp2,44100 Hz,立体声,s16,64 kb / s
元数据:
编码器:Lavc57.64.101 mp2
流映射:
流#0:0 - > #0:0(mp2(native))> mp2(native))
流#0:0 - > #0:1(mp2(native) - > mp2(native))
流#0:0 - > #1:0(mp2(本机) - > mp2(本机))
流#0:0 - > #2:0(mp2(native))> mp2(native))
流#0:0 - > #3:0(mp2(native) - > mp2(native))
流#0:0 - > #4:0(mp2(native) - > mp2(native))
流#0:0 - > #5:0(mp2(native) - > mp2(native))
流#0:0 - > #6:0(mp2(native) - > mp2(native))
流#0:0 - > #7:0(mp2(本机) - > mp2(本机))
按[q]停止,[?]寻求帮助

这是我的完整控制台。

解决方案

你可以通过运行7种不同的方式ffmpeg的实例与并行进程同时进行;



让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)
&等等。



不推荐它,会吃掉你的CPU的容量。


i run this command to be able to stream a udp live stream to a http live stream that is playable using a mobile application that am building.its just a stream with audio streams only.

ffmpeg -i udp://@localhost:1111 -map 0:a 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

i get this output

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%

i really want a way i can be able to map every input stream to have an output stream that can be accessed separately from the other like maybe if i need the first stream maybe i will just

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

and if i need the 7th stream i will just

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

Please can someone help me crack this issue. FFmpeg dont have complex examples for my current situation.

this is my header information

ubuntu@ip-localhost:~$ \ 
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 version 3.2.4-1~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.1 (Ubuntu 5.4.1-5ubuntu2~16.04.york1) 20170210 configuration: --prefix=/usr --extra-version='1~16.04.york0' -- toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --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 --enable-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 --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 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 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100

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

thats my full console.

解决方案

You could do that by running 7 different instances of ffmpeg at the same time as parallel processes; if you're open to that.

Let each instance of ffmpeg demultiplex a single audio stream and output to the respective port.

Would go somewhat like this:

(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.

Wouldn't recommend it though, will eat up your CPU's capacity.

这篇关于ffmpeg从具有多个通道的输入输出独立通道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 08:29