| | 84 | |
| | 85 | == Transcoding/repeating == |
| | 86 | |
| | 87 | Ffmpeg can also receive from "some source" (for instance live or udp) and then transcode and re-broadcast the stream. |
| | 88 | |
| | 89 | One mailing list user wrote this, quote: |
| | 90 | |
| | 91 | In my application, I have a server running vlc sucking streams from some cameras, encoding them as MPEG2 streams and sending them to ports 5000 through 5003 on my intermediary server (I'll have to let someone else explain how to set that up, as that was someone else's part of the project). I have another server running Wowza, with an instance named "live". And I've got an intermediate server that sucks in MPEG2 streams coming in on ports 5000 to 5003, transcoding them into mp4 streams with H.264 and AAC codecs, and pushing the transcoded streams on to Wowza. |
| | 92 | |
| | 93 | The command line I use to pull the stream from port 5000, transcode it, and push it is: |
| | 94 | ffmpeg -i 'udp://localhost:5000?fifo_size=1000000&overrun_nonfatal=1' -crf 30 -preset ultrafast -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 96k -vcodec libx264 -r 25 -b:v 500k -f flv 'rtmp://<wowza server IP>/live/cam0' |
| | 95 | |
| | 96 | -i 'udp://localhost:5000?fifo_size=1000000&overrun_nonfatal=1' tells ffmpeg where to pull the input stream from. The parts after the ? are probably not needed most of the time, but I did need it after all. |
| | 97 | |
| | 98 | -crf 30 sets the Content Rate Factor. That's an x264 argument that tries to keep reasonably consistent video quality. A value of 30 allows somewhat lower quality and bit rate. |
| | 99 | |
| | 100 | -preset ultrafast as the name implies provides for the fastest possible encoding. If some tradeoff between quality and encode speed, go for the speed. This might be needed if you are going to be transcoding multiple streams on one machine. |
| | 101 | |
| | 102 | -acodec aac sets the audio codec (internal AAC encoder) |
| | 103 | |
| | 104 | -strict experimental allows use of some experimental codecs (the internal AAC encoder is experimental) |
| | 105 | |
| | 106 | -ar 44100 set the audio sample rate |
| | 107 | |
| | 108 | -ac 2 specifies two channels of audio |
| | 109 | |
| | 110 | -b:a 96k sets the audio bit rate |
| | 111 | |
| | 112 | -vcodec libx264 sets the video codec |
| | 113 | |
| | 114 | -r 25 set the frame rate |
| | 115 | |
| | 116 | -b:v 500k set the video bit rate |
| | 117 | |
| | 118 | -f flv says to deliver the output stream in an flv wrapper |
| | 119 | |
| | 120 | 'rtmp://<wowza server IP>/live/cam0' is where the transcoded video stream gets pushed to |