BOBOBK

Installing ffmpeg on CentOS 7 and Streaming Movies on Douyu

TECHNOLOGY

A friend suggested to use a Douyu live room, leveraging various idle VPS to automatically stream movies daily, which not only makes use of idle VPS resources but can also earn over ten thousand a month automatically. Eh, wake up, time to work.

Getting back on track, today Chunjiang Muker brings you a tutorial on how to automatically push streams on Douyu live on CentOS 7, achieving 24/7 uninterrupted live streaming.

Main steps:

  1. Install ffmpeg
  2. Open a Douyu live room and get the stream key
  3. Download movies and start streaming

Installing ffmpeg

ffmpeg is a free video processing software supporting multiple video formats and can convert between formats. Streaming usually uses mp4 files, so videos downloaded beforehand need to be converted to mp4 format.

ffmpeg cannot be installed directly via yum. Use the following commands to install the rpm packages.

Here are two installation methods. Usually, the first script works. If not, use the second method with a script.

Method One

yum install epel-release
rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

yum install ffmpeg ffmpeg-devel -y

It’s recommended to install as root; otherwise, add sudo before commands. First, add the li.nux.ro repo so yum knows where to find packages, then install ffmpeg. If no errors, check installation with:

ffmpeg --version

Method Two

If method one fails due to missing dependencies, use the ffmpeg-install script. Tested to work where the first method failed.

wget https://raw.githubusercontent.com/q3aql/ffmpeg-install/master/ffmpeg-install
chmod a+x ffmpeg-install
./ffmpeg-install --install release 

This method works reliably. If it still fails, consider downloading and compiling from the official ffmpeg site, though this is least recommended.

Open a Douyu Live Room and Get Stream Key

Check Douyu’s official How to Become a Douyu Anchor guide. Mainly, you need real-name authentication, bind a bank card, etc. We won’t detail that here.

Once live permissions are granted, you can see the stream key at the top of your room. Click to get the stream URL and key. Example screenshot:

For example, my current stream URL is:
rtmp://send3.douyu.com/live Stream key is:
1146076rWGz7JQ9H?wsSecret=d3ca1dd38441abdd037df9146fcf6cea&wsTime=5dee22cc&wsSeek=off&wm=0&tw=0&roirecognition=0

Download Movies and Start Streaming

Download your movie to the current directory, for example godfather.mp4. To stream to Douyu, run:

ffmpeg -re -i godfather.mp4 -vcodec libx264 -acodec aac -f flv "rtmp://send3.douyu.com/live/1146076rWGz7JQ9H?wsSecret=d3ca1dd38441abdd037df9146fcf6cea&wsTime=5dee22cc&wsSeek=off&wm=0&tw=0&roirecognition=0"

You will see ffmpeg start streaming normally.

Check live status in your streaming room:

Streaming started successfully — now just wait for the gifts, hehe.

Notes

Due to potential copyright issues, streaming movies requires Douyu’s copyright approval. Here we use the old movie “The Godfather” as a demo. Streaming unlicensed content will get your room banned and points deducted immediately.

I just got points deducted; turns out you need to join the content review QQ group to get approval before streaming any movie. The review group QQ is: 708345458

Summary

This article explains how to use ffmpeg on CentOS 7 to stream movies on Douyu live successfully. Currently, the stream only shows video, without info like movie list or playback progress, which will be added later.

Feel free to visit my Douyu live room.

Future features to add:

  1. Live time progress
  2. Movie playlist in the live room
  3. Check-in and on-demand features

Related