Search code examples
ffmpegudplive-streamingyoutube-dl

Encode youtube live stream to UDP out using youtube-dl and ffmpeg


I am trying to encode youtube live stream to UDP destination using youtube-dl and ffmpeg with below command

youtube-dl -f best --buffer-size 2M -o - "https://www.youtube.com/watch?v=tkUvWJiTf9A" | ffmpeg -re -f mp4 -i pipe:0 -codec copy -f mpegts udp://192.168.1.107:1234?pkt_size=1316

But its not working, its just downloading ts segments of that live stream.
When I am trying with video of youtube its working fine with below commands

youtube-dl -f best --buffer-size 2M -o - "https://www.youtube.com/watch?v=snDI6AaL04g" | ffmpeg -re -f mp4 -i pipe:0 -codec copy -f mpegts udp://192.168.1.107:1234?pkt_size=1316

Any help or suggestion appreciated.


Solution

  • I have got it solved using below command using Streamlink with ffmpeg. sharing so anyone needed can refer that.

    streamlink --hls-segment-threads 10 --ringbuffer-size 10M https://www.youtube.com/watch?v=NMre6IAAAiU 140p,worst --stdout | ffmpeg -i pipe:0 -codec copy -bsf:v h264_mp4toannexb -f mpegts udp://192.168.2.7:1234?pkt_size=1316