实时从RTMP流中将帧提取为图像 [英] Extract frames as images from an RTMP stream in real-time

查看:71
本文介绍了实时从RTMP流中将帧提取为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以VGA品质以15 fps的速率将以H264编码的短视频(4或5秒)从不同的客户端流到使用RTMP生成文件的RTMP服务器.我需要尽快将视频中的帧作为图像进行分析,以便在接收到这些帧时将它们写为PNG图像.

I am streaming short videos (4 or 5 seconds) encoded in H264 at 15 fps in VGA quality from different clients to a server using RTMP which produced an FLV file. I need to analyse the frames from the video as images as soon as possible so I need the frames to be written as PNG images as they are received.

当前,我使用Wowza接收流,并且尝试使用转码器API访问各个帧并将其写入PNG.这部分起作用,但是在转码器开始处理之前有大约一秒钟的延迟,当流结束时,Wowza刷新其缓冲区,导致最后一秒钟不被转码,这意味着我可能会丢失最后25%的视频帧.我试图找到一种解决方法,但

Currently I use Wowza to receive the streams and I have tried using the transcoder API to access the individual frames and write them to PNGs. This partially works but there is about a second delay before the transcoder starts processing and when the stream ends Wowza flushes its buffers causing the last second not to get transcoded meaning I can lose the last 25% of the video frames. I have tried to find a workaround but Wowza say that it is not possible to prevent the buffer getting flushed. It is also not the ideal solution because there is a 1 second delay before I start getting frames and I have to re-encode the video when using the transcoder which is computationally expensive and unnecessarily for my needs.

我还尝试过将视频实时传输到FFmpeg并获取以生成PNG图像,但不幸的是,它一直等到接收到完整的视频,然后再生成PNG帧.

I have also tried piping a video in real-time to FFmpeg and getting it to produce the PNG images but unfortunately it waits until it receives the entire video before producing the PNG frames.

如何从流中提取尽可能接近实时的所有帧?我不介意使用什么语言或技术,只要它们可以在Linux服务器上运行即可.如果我能找到一种方法来使它在仍接收视频的同时写入图像,或者甚至能找到一种不丢失帧且不进行重新编码的方式来制作Wowza,我将很高兴使用FFmpeg.

How can I extract all of the frames from the stream as close to real-time as possible? I don’t mind what language or technology is used as long as it can run on a Linux server. I would be happy to use FFmpeg if I can find a way to get it to write the images while it is still receiving the video or even Wowza if I can find a way not to lose frames and not to re-encode.

感谢您的帮助或建议.

推荐答案

我终于找到了使用FFmpeg做到这一点的方法.诀窍是禁用音频,使用其他flv元数据分析器,并减少FFmpeg在处理之前等待的持续时间.我的FFmpeg命令现在开始如下:

I finally found a way to do this with FFmpeg. The trick was to disable audio, use a different flv meta data analyser and to reduce the duration that FFmpeg waits for before processing. My FFmpeg command now starts like this:

ffmpeg -an -flv_metadata 1 -analyzeduration 1 ...

这会在接收到来自管道的输入后的一秒钟内开始生成帧,因此将流传输的帧写得非常接近实时.

This starts producing frames within a second of receiving an input from a pipe so writes the streamed frames pretty close to real-time.

这篇关于实时从RTMP流中将帧提取为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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