ffmpeg is a powerful cross-platform tool for processing and publishing video- and audiocontent. In terms of publishing RTMP stream on server, ffmpeg allows:
1. For test we use:
2. Launch ffmpeg
ffmpeg -re -i BigBuckBunny.mp4 -preset ultrafast -acodec aac -vcodec h264 -strict -2 -f flv rtmp://test1.flashphoner.com:1935/live/stream_ffmpeg |
Where
The stream publishing begins.
3. Open Player appliction in browser https://test1.flashphoner.com:8888/client2/examples/demo/streaming/player/player.html, where test1.flashphoner.com is WCS server. Set the stream name and press 'Play'. The stream playback begins.
ffmpeg allows to explicitly set the encoding parameters when stream is publishing, for example
ffmpeg -re -i BigBuckBunny.mp4 -acodec aac -vcodec libx264 -f flv -ar 44100 rtmp://127.0.0.1:1935/live/stream_ffmpeg |
A more complicated case with addition of a sound track to a file that has not one (/dev/zero source is used for example):
ffmpeg -re -f lavfi -i "movie=filename=test.mov:loop=0, setpts=N/(FRAME_RATE*TB)" -an -s 1280x720 -r 15 -f rawvideo -pix_fmt yuv420p - | ffmpeg -thread_queue_size 512 -an -f rawvideo -pix_fmt yuv420p -r 15 -s 1280x720 -i - -vn -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero -r 15 -c:v libx264 -tune zerolatency -profile:v baseline -g 60 -b:v 960k -s 1280x720 -c:a aac -b:a 64k -f flv rtmp://127.0.0.1/live/test_video |
In the "-rtmp_conn" option, ffmpeg allows to set RTMP connection paramtters that should be passed to the server when stream is publishing:
ffmpeg -re -i BigBuckBunny.mp4 -f flv -rtmp_conn "O:1 NS:appKey:flashStreamingApp NS:name:12121212 NS:stream:12121212 NO:custom:O:1 NS:auth:22222222 NS:stream:3333333 O:0 O:0" rtmp://test1.flashphoner.com:1935/12121212 |
Here, the following parameters are passed
{ "auth" : "22222222", "stream" : "3333333" } |