简体   繁体   English

如何在ActionScript中以NetStream的“传入帧速度”(不是视频内部)播放FLV视频

[英]How to play FLV video at “incoming frames speed” (not video-internal) coming from NetStream in ActionScript

How to play NetStream frames immediatly as they arrive without any additional AS framerate logic? 如何在没有任何额外AS帧速率逻辑的情况下立即播放NetStream帧?

I have recorded some audio & video data packets from RTMP protocol received by Red5, and now I'm trying to send it back to the flash client in a loop by pushing packets to NetStream with incrementing timestamp. 我已经从Red5收到的RTMP协议中录制了一些音频和视频数据包,现在我试图通过递增时间戳将数据包推送到NetStream ,将其发送回闪存客户端。 The looped sequence has length of about ~20 sec nad is build from about ~200 RTMP packets (VideoData/AudioData) 循环序列的长度约为~20秒,nad是从大约200个RTMP数据包构建的(VideoData / AudioData)

Environment: both Flash client and server on localhost, no network bottleneck, video is H.264 encoded earlier by same Flash client. 环境:本地主机上的Flash客户端和服务器,没有网络瓶颈,视频是由同一个Flash客户端提前H.264编码的。

It generaly works, but video is not very fluent - there ale lot of freezes, slowdowns and long pauses. 它通常有效,但视频不是很流畅 - 有很多冻结,减速和长时间停顿。 The slower packets transmitting causing the more pauses and freezes. 较慢的数据包传输导致更多的暂停和冻结。 , even extreme long pauses like transmiting whole sequence 2x-3x times (~60 sec) without effect - this comes up when forwarding slower than ~2 RTPM packets per second. 甚至是极端长时间的暂停,例如在没有效果的情况下传输整个序列2x-3x次(~60秒) - 这在每秒转发慢于~2个RTPM数据包时出现。

The problem looks like some AS-logic is trying to force framerate of a video, not just output received frames , so one of my questions is does AS looks for in-video-frame fps info in live streaming? 问题看起来像一些AS逻辑试图强制视频的帧速率,而不仅仅是输出接收到的帧 ,所以我的一个问题是AS是否在直播中寻找视频帧内fps信息? why it can play faster, but can't play slower? 为什么它可以发挥更快,但不能发挥更慢? How can I play video "by frames" not synchronizing video fps with RTPM packets timestamps? 如何“逐帧”播放视频而不是将视频fps与RTPM数据包时间戳同步?

On the other side, if I push packets faster than recorder, the video is just faster but almost fluent - I just can't get slower or stable stream (still very irregular speed). 另一方面,如果我比录音机更快地推送数据包,视频只是更快但几乎流畅 - 我只是不能得到更慢或稳定的流(仍然是非常不规则的速度)。

I have analysed some NetStream values: 我已经分析了一些NetStream值:

  • .bufferLength = ~0 or 0.001, incrasing when I forward packets extremaly fast (like targeting ~90fps) .bufferLength = ~0或0.001,当我以非常快的方式转发数据包时(例如定位~90fps)
  • .currentFPS = shows real FPS count seen in Video object, not incoming frames/s .currentFPS =显示在Video对象中看到的实际FPS计数,而不是传入的帧/ s
  • .info.currentBytesPerSecond = ~8 kB/s to ~50kB/s depending on forwarding speed .info.currentBytesPerSecond = ~8 kB / s到~50kB / s,具体取决于转发速度
  • .info.droppedFrames = frequently incrases, even if I stream packets like 2/sec! .info.droppedFrames = 经常插入,即使我像2 /秒一样流式传输数据包! also jumps after long self-initiated-pause (but buffer is whole time 0!) 长时间自启动 - 暂停后也会跳转(但缓冲区是整个时间0!)
  • .info.isLive = true .info.isLive = true
  • .info.dataBufferLength = same as .bufferLength .info.dataBufferLength =与.bufferLength相同

It looks like AS is dropping frames, because of too rare RTMP packets receive - like expecting that they will arrive with internal-frame-encoded-fps-speed. 看起来AS正在丢帧,因为接收的RTMP数据包太少 - 比如期望它们将以内部帧编码的fps速度到达。

My currently best NetStream configuration: 我目前最好的NetStream配置:

chatStream.videoReliable = false;
chatStream.audioReliable = false;
chatStream.backBufferTime = 0;
chatStream.bufferTime =0;

Note that if I set bufferTime to 1 , video is paused until gathering "1 second of video" but this is not true - buffering is very slow, like assuming that video has FPS of 100 or 200 - even if I'm forwarding packets fast (like targeting ~15fps without buffer), the buffer is filing about 10-20 seconds. 请注意,如果我将bufferTime设置为1 ,视频将暂停,直到收集“1秒视频”但这不是真的 - 缓冲非常慢,就像假设视频的FPS为100或200 - 即使我快速转发数据包(比如在没有缓冲区的情况下定位~15fps),缓冲区填充大约10-20秒。

Loop, of course, starts with keyframed video data and keyframe interval of sequence is about 15 frames. 当然,循环以关键帧视频数据开始,序列的关键帧间隔约为15帧。

Have you tried netStream.step(1) 你试过netStream.step(1)吗

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#step() http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#step()

Also I would remove 'live' from the play() call. 我也会从play()调用中删除'live'。

Finally, maybe flash tries to sync to the audio like it does in regular timeline. 最后,也许闪存尝试像在常规时间线中那样同步到音频。 Have you tried a video without audio channel? 您是否尝试过没有音频频道的视频?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM