Use FFmpeg to push rtmp streams under Windows platforms
It's customary to use ffmpeg to simulate push rtmp streaming under Linux, but the home computer is a Windows system that needs to use the bandwidth in the home to test the performance of the streaming media server. So we've studied how to push the stream quickly in Windows systems.
First Download Install FFmpeg
Download the FFmpeg compression package under Windows, unzip it to the current directory, see (How to upload the image quickly and uploaded?). )
We are using the Ffmpeg.exe file under the Ffmpeg-20180429-19c3df0-win64-static\bin path.
Write two scripts to implement push flow
You can use Windows batch or PowerShell scripts, but you have to implement two copies, so it's best to reuse shell scripts under Linux.
Installing Cygwin
Download the installation Cygwin.
Two X Cygwin commands
- Jump to another drive letter
$ cd /cygdrive/f
- Set the environment variable to add the bin directory of the ffmpeg to the environment variable
$ export PATH=$PATH:/cygdrive/f/Harlan/Software/ffmpeg-20180429-19c3df0-win64-st atic/bin/
Cyclic push-stream shell script
Create a shell script file pushstream.sh, which reads as follows
#!/bin/bashfor((;;)); do ffmpeg -re -i "..\videos\test-$1.mp4" -c copy -f flv "rtmp://stream_media_server_address:1935/live/test-$1/test-$1"sleep 1; done
Note Add a parameter of $.
A shell script that pushes a multi-channel stream
Start the process of pushing the stream as a daemon and create a script push_all.sh:
#!/bin/bashsetsid ./pushstream.sh 20 >/dev/null 2>&1 < /dev/null &setsid ./pushstream.sh 30 >/dev/null 2>&1 < /dev/null &setsid ./pushstream.sh 40 >/dev/null 2>&1 < /dev/null &setsid ./pushstream.sh 60 >/dev/null 2>&1 < /dev/null &
Execute the following command to start the script:
$ ./push_all.sh
You can see that there are four streams in the background while pushing:
Using ffmpeg to push rtmp streams under Windows platforms