[FFmpeg-user] Combining download of ts stream with geometry modification into mp4?

Bo Berglund bo.berglund at gmail.com
Mon Apr 19 09:20:36 EEST 2021


This is about speeding up my video download process.
It runs on an Ubuntu server (no GUI on the Ubuntu machine).

So I have a working solution to do these tasks:
1) Download during a fixed time from a streaming source into a ts file
2) When done process ts file(s) into mp4 while also changing geometry from
1280x720 to 640x320 px.

The two commands used are as follows:
1) Download:
ffmpeg -hide_banner -user_agent \"Mozilla\" -i <VIDEOURL> -t <CAPTURETIME> -c
copy <TSOUTPUTFILE>

The CAPTURETIME argument in seconds limits the time span of the video

2) Process geometry and file format:
ffmpeg -hide_banner -threads 1 -i <TSINFILE> -vf scale=w=-4:h=$360 -c:v libx264
-preset fast -crf 32 -c:a copy <MP4OUTFILE>

To process the downloaded file takes about 30% of the playing time so for a 60
min download it takes an additional 20 minutes to process.

Question:
---------
Can I combine these two operations into a single ffmpeg command such that there
is no intermediate ts file created and the mp4 is available essentially when the
download completes?

As it is now I download nightly and then I have to run a batch job in the
morning to convert all the successfully downloaded ts videos into mp4, which
takes several hours...


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list