szatmary / libcaption

Free open-source CEA608 / CEA708 closed-caption encoder/decoder
MIT License
148 stars 64 forks source link

Live captioning: need help #55

Open nitsuj102284 opened 5 years ago

nitsuj102284 commented 5 years ago

My goal is to update a .srt file through a web form for live streaming captioning. Our output is HLS + Facebook and YouTube. Nginx RTMP converts the stream to HLS, but for my test, I bypassed HLS and tested output of RTMP stream back into Nginx RTMP.

My test was: Streaming encoder --> Nginx RTMP --> FFMPEG/FLV+SRT --> Nginx RTMP

I tried the example, noticing the paragraph regarding live captioning.

Here is my command: ffmpeg -i rtmp://streamserver.tld:1936/publish/999 -codec copy -f flv - | flv+srt - ~/libcaption/cc.srt - | ffmpeg -i - -codec copy rtmp://streamserver.tld:1936/rtmp/999_cc

I tried two srt files, because I was unsure of the exact format:

cc.srt: 1 00:00:00,000 --> 00:00:00,000 Test live cc text \0

cc2.srt: 1 \0 00:00:00,000 --> 00:00:00,000 Test live cc text

Received pretty big output in CLI, including: Reading flv from - Reading captons from /home/streambright/libcaption/cc.srt Writing flv to - buffer overflow detected : flv+srt terminated

...

and

...

pipe:: Invalid data found when processing input

Any help on what I am not getting is appreciated. Thanks!

curtgrimes commented 5 years ago

Are both the captions and video going to be live, changing and not predetermined? If so, I'm trying to also figure out right now how to accomplish this. This comment outlines a possible solution: https://github.com/szatmary/libcaption/issues/17#issuecomment-302152133

nitsuj102284 commented 5 years ago

Yes, exactly. My first test was to create the captions file and then, if that worked, update the file to see if it updates on the video output.

I saw that comment, and tried to make sense of it. Also, there is a paragraph about it at the bottom of the 'examples' Readme. That comment and the paragraph in the Readme seemed to be contradictory about where to put the null character.

Can you post the command/caption file that you have tried, and if you have had any success or different errors?

curtgrimes commented 5 years ago

I think you're still a few steps ahead of me at the moment in figuring this out. I haven't tried anything yet, but let me get back to you when I'm able to make some progress.

curtgrimes commented 5 years ago

@nitsuj102284 Would you like to message me to talk about this? https://m.me/curtgrimes

KPAXIT commented 5 years ago

Hi there. I would like to share some of my findings regarding the 'broken' output from flv+srt when you use pipe eg '-' instead of file.

As a TS my goal is also to inject CC in the livestream. I only use Gstreamer instead of ffmpeg. I was able to generate input data with gstreamer(h264 video wraped in flv) pass it to flv+srt and save to a file successfully. gst-launch-1.0 videotestsrc ! ...etc ... ! flvmux ! fdsink | flv+srt - mysrtfile.srt output_with_cc.flv

The problem was when I was trying to pass output from flv+srt further to the next process (ffmpeg or gstreamer) for re-sending the result data to streaming server. I was able to capture this (broken) output to a file and compare it with working output created by flv+srt eg 'output_with_cc.flv' and there where a bunch of added lines with 'Matches: 2 Start pts: 4.271000' etc. Those are produced by vtt.c (line 164 and 168) uncommenting this lines has helped to resolve this issue for now.

I assume this lines should not be printed when using pipe and it's bug.

Good luck.