[FFmpeg-user] Add soft subtitles to YouTube Stream Now?

Steven Kan steven at kan.org
Wed Nov 20 22:59:13 EET 2019


The good news is that all the required pieces appear to exist; the bad news is that no one has yet (to my knowledge) glued them together to make a functional solution. Here’s someone who has gotten very close:

https://github.com/szatmary/libcaption/issues/55#issuecomment-525688953

"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."



> On Nov 20, 2019, at 2:16 PM, Verachten Bruno <gounthar at gmail.com> wrote:
> 
> That's a very interesting subject (to me at least).
> I would like to embed automatic (or human generated, depending on the
> budget) subtitles to help hearing-impaired people grab most of the
> talk in our conference.
> I am producing H.264 and sending it (for the time being) to YouTube,
> so your request is not far from my needs.
> I will follow this subject with great attention.
> Thanks.
> 
> On Wed, Nov 20, 2019 at 5:20 PM Michael Shaffer <mikeshaffer at gmail.com> wrote:
>> 
>> I noticed your Youtube streams only last a day or so. I have a Python
>> script I made that keeps the ffmpeg process sending to Youtube. I have 5 IP
>> cameras going to youtube and they have been going about 9 months without
>> the stream ending. Anyways, if you want I could show you how the script
>> works. You would just have to change the stream keys and the bitrate that
>> each camera uses, so it knows when to restart the stream.
>> 
>> Michael
>> 
>> On Wed, Nov 20, 2019 at 12:17 AM Steven Kan <steven at kan.org> wrote:
>> 
>>> First time poster, so please be kind if I ask anything stupid!
>>> 
>>> I have a live BeeCam feed on YouTube:
>>> 
>>> https://www.youtube.com/channel/UCE0jx2Z6qbc5Co8x8Kyisag/live <
>>> https://www.youtube.com/channel/UCE0jx2Z6qbc5Co8x8Kyisag/live>
>>> 
>>> using YouTube’s “Stream Now” feature, which is distinct from a streaming
>>> “event” because I don’t have to schedule it. Whenever I’m pushing video to
>>> YouTube, the channel goes live.
>>> 
>>> The stream is supplied by a Raspberry Pi running as an ffmpeg “relay
>>> server,” e.g. it’s not doing any transcoding; it’s just repacking an RTSP
>>> stream from an off-the-shelf camera:
>>> 
>>> ./ffmpeg -re -thread_queue_size 512 -rtsp_transport tcp -i "rtsp://
>>> anonymous:password at 192.168.1.11:554" -f concat -safe 0 -i playlist.txt
>>> -vcodec copy -acodec copy -t 01:47:02 -f flv "rtmp://
>>> a.rtmp.youtube.com/live2/my-youtube-streaming-key”
>>> 
>>> The -t and playlist.txt are because my camera lacks and audio feed, and YT
>>> requires an audio stream, so I have a collection of royalty-free mp3s in
>>> the playlist, and I’m wrapping this command in a loop.
>>> 
>>> When I run this on my RPi 2, CPU utilization for ffmpeg is <<<<10%, which
>>> is what I want, because I will have up to 3 instances of ffmpeg pushing 3
>>> camera streams to 3 YT channels during honey bee swarm season in Spring.
>>> 
>>> What I want to do is add some captions to the video as soft subtitles,
>>> e.g. my location, the present temperature, and the weather forecast. I
>>> don’t have enough CPU on the Pi to burn these into the video stream.
>>> 
>>> Is this possible in ffmpeg and with YouTube’s “stream now” feature?
>>> 
>>> I can get ffmpeg to put a soft subtitle into a local .mkv file:
>>> 
>>> ./ffmpeg -i video.mp4" -i SubtitleTest.srt -acodec copy -scodec copy
>>> out.mkv
>>> 
>>> but I changing the output to .m4v, mp4, or .flv results in errors such as:
>>> 
>>> Subtitle codec 'ass' for stream 2 is not compatible with FLV
>>> 
>>> and pushing mkv to YouTube via:
>>> 
>>> ./ffmpeg -i video.mp4" -acodec copy -f mkv "rtmp://
>>> a.rtmp.youtube.com/live2/my-youtube-streaming-key”
>>> 
>>> returns:
>>> 
>>> Requested output format 'mkv' is not a suitable output format
>>> rtmp://a.rtmp.youtube.com/live2/my-youtube-streaming-key <rtmp://
>>> a.rtmp.youtube.com/live2/my-youtube-streaming-key>
>>> 
>>> Am I doing this fundamentally wrong? Or is this just not possible? If it’s
>>> possible I will continue reading documentation until I get it working!!!
>>> 
>>> Thanks!
>>> 
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>> 
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
> 
> 
> 
> -- 
> Bruno Verachten
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-user mailing list