FFMPEG - RTMP到HLS没有音频输出 [英] FFMPEG - RTMP to HLS no audio output

查看:1307
本文介绍了FFMPEG - RTMP到HLS没有音频输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个动态的HLS分段为我们livecam应用。
为此我赶上外部RTMP流,并将其与ffmpeg的转换成段。

I am currently developing a dynamic HLS segmenter for our livecam application. Therefor I catch the external RTMP stream and convert it into segments with ffmpeg.

下面的命令如下:

ffmpeg -i rtmp://"$serverip"/"$application"/mp4:"$stream_name".f4v -c:v libx264 -profile:v baseline -level 5.1 \
-c:a aac -strict experimental -flags +global_header -f mpegts - | ffmpeg -i - -c copy -map 0 -f segment \
-segment_list /tmp/hls/"$id"/"$stream_name".m3u8 -segment_format libmp3lame -segment_time 10 \
-segment_wrap 4 /tmp/hls/"$id"/"$stream_name"%03d.ts

不过,与此命令我确实有直播和HLS输出(约1-2分钟!)之间存在着巨大的延迟。

But with this command I do have a huge latency between the livestream and the HLS output (around 1-2 minutes!).

所以,我想另一个命令,这会导致20-30秒的等待时间!我唯一​​的问题是,音频流无法识别,也没有投入HLS文件(指我只得到了视频,但没有音频的话):

So I tried another command, which results in a latency of 20-30 seconds! My only problem is, that the audio stream is not recognized and also not put to HLS files (means I only got the video, but no audio at all):

ffmpeg -probesize 50k -i rtmp://"$serverip"/"$application"/mp4:"$stream_name".f4v \
-c:v libx264 -b:v 128k -g 90 -c:a aac -strict experimental -flags -global_header -map 0 \
-f segment -segment_time 3 -segment_list /tmp/hls/"$id"/"$stream_name".m3u8 -segment_list_flags +live \
-segment_list_type m3u8 -segment_list_size 5 -segment_format mpegts /tmp/hls/"$id"/"$stream_name"%d.ts

我想,-c:一个AAC标志应流合并的音频以及做的工作。

I thought, the -c:a aac Flag should do the job for muxing the audio as well.

你有什么建议,什么地方出了错在第二个命令?我definitly有节段音频流以及!

Do you have any suggestions what went wrong on the second command? I definitly have to segement the audio stream as well!

在此先感谢

更新:

FFmpeg的命令的一些输出:

Some outputs of the FFMPEG command:

我开始命令(2)的人,并得到了一个音频输出,但它似乎没有工作每次。

I started the command (2) ones, and got an audio output, but it seems not to work everytime.

从工作命令2,音频输出工作:
http://pastebin.com/bhxfNQBg

Output from working command 2, audio is working: http://pastebin.com/bhxfNQBg

从工作命令2,音频无法正常工作输出(没有改变):
http://pastebin.com/engEuSdn

Output from working command 2, audio not working (nothing changed): http://pastebin.com/engEuSdn

请告诉我怪我,是该行:

Whats strange for me, is the line:

[flv @ 0x1eed900] New audio stream 0:1 at pos:716680 and DTS:0s

这仅发生,如果HLS侧音频不工作。

This only occurs, if the audio on hls side is NOT working.

任何帮助将AP preciated

Any help will be appreciated

更新2:结果
它好像有一个问题,当我开始FFmpeg的命令后,流已经公布。结果
如果我按照这些步骤,一切工作正常:结果
1.启动流(成立NC连接到AMS)结果
2.启动FFMPEG命令(这将闲置,直到流出版)结果
3.开始发布搜索结果

Update 2:
It seems like there is a problem when I start the ffmpeg command after the stream is already published.
If I follow these steps, everything works fine:
1. Start Stream (nc Connection to AMS is established)
2. Start FFMPEG command (it will idle until the stream publishes)
3. Start publishing

但是,如果我那样做(我们需要),无音频将present:结果
1.启动流结果
2.用户加入,开始发布结果
3.触发ffmpeg的命令

But If I do it like that (which we will need), no audio will be present:
1. Start Stream
2. User join, start publishing
3. Trigger ffmpeg command

推荐答案

由于越来越多的人纷纷实施HLS功能,我赶紧想我的答案张贴到我的出身问题。

Because more and more people have to implement HLS features, I quickly want to post my "answer" to my origin question.

我想通了,这个问题必须做的事情probesize

I figured out, that the problem has to do something with the probesize.

正如你可以在文档中看到,probesize定义长的ffmpeg开始之前分割如何等待流的信息。

As you can see in the documentation, the probesize defines how long ffmpeg waits for stream information before starting the segmentation.

在一个运行实时流我必须设置该1000K左右才能正确读取音频流。

On an running live stream I have to set this around 1000k to fetch the audio stream correctly.

没有一切正常。
但是注意,较高的probesize将导致更高的延迟!

No everything works as expected. But note, that a higher probesize will result in higher latencies!

这篇关于FFMPEG - RTMP到HLS没有音频输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆