项目作者: usunyu

项目描述 :
Publish H264 video file list to RTMP server
高级语言: C
项目地址: git://github.com/usunyu/librtmp-publish-h264-sequence.git
创建时间: 2017-07-19T04:58:35Z
项目社区:https://github.com/usunyu/librtmp-publish-h264-sequence

开源协议:

下载


librtmp-publish-h264-sequence

Exploring publish H264/FLV video file list to RTMP server

Attemp 1: Try publish h264 list in a loop with librtmp.

Cons: Require reconnect when process the new video file.
  1. LibRTMP* lib = new LibRTMP();
  2. for (int i = 1; i <= VIDEO_COUNT; i++)
  3. {
  4. std::string video_file = "h264/" + std::to_string(i) + ".h264";
  5. std::cout << "Start to publish " << video_file << "..." << std::endl;
  6. lib->connectRTMPWithH264(rtmp_url, string_to_tchar(video_file));
  7. lib->close();
  8. }

Attemp 2: Try use pipe to send h264 to ffmpeg and publish.

  1. LibFFmpeg* lib = new LibFFmpeg(rtmp_url, "ffmpeg.exe");
  2. for (int i = 1; i <= VIDEO_COUNT; i++)
  3. {
  4. std::string video_file = "h264/" + std::to_string(i) + ".h264";
  5. int size = get_file_size2(video_file.c_str());
  6. std::cout << "Start to publish " << video_file << ": " << size << " bytes" << "..." << std::endl;
  7. unsigned char* data = read_file_to_array2(video_file.c_str(), size);
  8. lib->WriteFrame(data, size);
  9. }
  10. lib->Close();