[FFmpeg-user] Possible to play video while it is being downloaded using ffmpeg?

Bo Berglund bo.berglund at gmail.com
Tue Mar 21 22:38:44 EET 2023


I have a script that downloads and re-encodes a live stream into an mp4 video
file with a set geometry. The script runs on Ubuntu 20.04 server.

Is it possible to play from that file while it is being downloaded, i.e. opening
it in some way in a video player?

I have tried using VLC but nothing happens, probably because I am doinmg
something wrong.

I also have a standalone video player I tested with but it thinks the length of
the video is zero so does not play it.

What I am after is a way to play from the start of the file while ffmpeg is
appending new data at the end of the file.

This way the video could be accessed and reviewed before the full download time
has expired and download concluded.

If some extra parameters are needed for the ffmpeg download command then what
could those be?

I have this in my download script, which works fine as is for downloading:

CMD="ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -vf scale=w=-4:h=${VIDEORES}
-c:v libx264 -preset fast -crf 26 -c:a aac -t ${CAPTURETIME} ${TARGETFILE}"

where:

VIDEOURL="<URL to webpage where the streaming video player is located>"
MODE="-referer \"${VIDEOURL}\""
M3U8URL="<m3u8 URL to the actual video stream being played>"
VIDEORES="480"
CAPTURETIME="<recording time in seconds>"
TARGETFILE="<Output mp4 file name>"


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list