Use FFMPEG to push rtmp stream under windows platform
At work, I am used to using FFmpeg to simulate rtmp streaming under Linux. Unfortunately, the computers at home are all Windows systems, so I need to use the bandwidth at home to test the performance of the streaming media server. So I studied how to quickly push the stream in the windows system.
First download and install ffmpeg
Download the FFMPEG compressed package under Windows, extract it to the current directory, see the figure below ( how to quickly take a screenshot and upload it to the image transmission? )
We are using the ffmpeg.exe file in the ffmpeg-20180429-19c3df0-win64-static\bin path.
Write two scripts to implement push streaming
You can use windows batch or powershell scripts, but you have to implement two copies, so it is best to reuse the shell scripts under Linux.
Install Cygwin
Download and install Cygwin.
Two Cygwin commands
- Jump to another drive letter
$ cd /cygdrive/f
- Set the environment variable and add the bin directory of ffmpeg to the environment variable
$ export PATH=$PATH:/cygdrive/f/Harlan/Software/ffmpeg-20180429-19c3df0-win64-st atic/bin/
Loop push stream shell script
Create a shell script file pushstream.sh with the following content
#!/bin/bash
for((;;)); 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 the addition of a parameter $1.
Shell script to push multiple streams
Start the push process as a daemon and create a script push_all.sh:
#!/bin/bash
setsid ./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 pushing at the same time in the background: