小编Jan*_*uri的帖子

使用H264编解码器将FLV流式传输到带有FFMpeg的RTMP,使用C++ API将FLV流式传输到flv.js

我想使用H264编解码器使用OpenCV从网络摄像头流式传输实时视频,然后将其转换为FLV,然后通过RTMP服务器流式传输,并使用flv.js在浏览器中捕获流.基本上我有一切工作,除了我无法读取flv.js中的流.我可以打开流,ffplay所以我认为至少大多数事情都设置正确.

我目前的实施:

#include <iostream>
#include <vector>

#include <opencv2/highgui.hpp>
#include <opencv2/video.hpp>

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/pixdesc.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
}

void stream_video(double width, double height, int fps, int camID)
{
  av_register_all();
  avformat_network_init();

  const char *output = "rtmp://localhost/live/stream";
  const AVRational dst_fps = {fps, 1};
  int ret;

  // initialize video capture device
  cv::VideoCapture cam(camID);
  if (!cam.isOpened())
  {
    std::cout << "Failed to open video capture device!" << std::endl;
    exit(1);
  }

  cam.set(cv::CAP_PROP_FRAME_WIDTH, width);
  cam.set(cv::CAP_PROP_FRAME_HEIGHT, height);

  // …
Run Code Online (Sandbox Code Playgroud)

flv ffmpeg rtmp live-streaming

13
推荐指数
1
解决办法
2641
查看次数

标签 统计

ffmpeg ×1

flv ×1

live-streaming ×1

rtmp ×1