Networking – FFMPEG: Stream a file with original playing rate

ffmpegnetworkingstreamingvideo streamingvlc-media-player

I want to stream a file to the network using ffmpeg in it's original frame rate; so I can play the generated UDP stream using some receiver client such as VLC. I used this command:

ffmpeg -i "myfile.mpg" -sameq -re -f mpegts "udp://127.0.0.1:2000"

By using this command the ffmpeg starts streaming the file in a very high rate; such that streaming of a file that has about 30 minutes length, is finished after just about 40 secs. I want to see the file in original rate. Also I want to have control on rate of video to play it faster or slower. Is there any options to do this? thank you.

Best Answer

-re should be used as an input option, otherwise it will probably be ignored. A generalization of the basic syntax is:

ffmpeg [input options] -i input [output options] output

Do not use -sameq. See sameq does not mean "same quality" for a detailed explanation.

Have you tried simply copying the streams instead of re-encoding? Add -map 0 -codec copy as output options.

As for changing the video speed you can try the setpts multimedia filter. Note that you have to re-encode to use this filter. Examples from the documentation:

Apply fast motion effect: -filter:v setpts=0.5*PTS
Apply slow motion effect: -filter:v setpts=2.0*PTS

For audio see the asetpts or atempo filters.

Related Question