FFMPEG: Stream a file with original playing rate

18,630

Solution 1

-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.

Solution 2

The answer is to use option -re. It should be put with the input options (before -i).

-re (input)

Read input at native frame rate. Mainly used to simulate a grab device, or live input stream (e.g. when reading from a file). Should not be used with actual grab devices or live input streams (where it can cause packet loss). By default ffmpeg attempts to read the input(s) as fast as possible. This option will slow down the reading of the input(s) to the native frame rate of the input(s). It is useful for real-time output (e.g. live streaming).

Share:
18,630

Related videos on Youtube

sajad
Author by

sajad

Updated on September 18, 2022

Comments

  • sajad
    sajad over 1 year

    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.