[FFmpeg-user] Optimization

Marcus Lim drakeskywing at gmail.com
Thu Nov 1 04:31:49 EET 2018


Hey all,
New to the list and trying to get my head around ffmpeg a bit still.
So I am using ffmpeg to create slideshows out of individual images, with an
audio backing track (usually mp3), and then encoding as MP4 (video is h264
and audio is acc), but for some reason the process is taking up to 1.4Gb of
memory which is blowing me away.
Now I am using a complex filter to achieve this, with multiple inputs, and
example of my command is below:

ffmpeg \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf8912937006552540487.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf5351513282402727883.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf9204204500598689609.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf1241593939921003895.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf6231405065182432206.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf4783563520441940155.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf823726872837129805.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf4148893068919936811.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf6815991692415841819.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf553287365250808111.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf6763129487770212040.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf4160943340255327277.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf8834606975865492644.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf9160476045329137307.tmp \
-loop 1 -t 4 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf8917976550433767102.tmp \
-stream_loop -1 -t 60 -i
test/ed141148-9b79-494b-a26d-f5c84535eeaf6379741644027890621.tmp  \
-filter_complex \
"[0:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v0];\
 [1:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v1];\
 [2:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v2];\
 [3:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v3];\
 [4:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v4];\
 [5:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v5];\
 [6:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v6];\
 [7:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v7];\
 [8:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v8];\
 [9:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v9];\
 [10:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v10];\
 [11:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v11];\
 [12:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v12];\
 [13:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v13];\
 [14:v]scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v14];\
 [v0][v1][v2][v3][v4][v5][v6][v7][v8][v9][v10][v11][v12][v13][v14]concat=n=15:v=1:a=0,format=yuv420p[v]"
-map "[v]" -map 15:a test/fcd2b1a9-f3c8-4cdc-8355-51c08b088ee3.mp4

Each loop is on a 4Mb Jpeg, and the stream_loop was the only way I could
figure out to get the audio track to loop in the background, which is about
4Mb as well.

I'm kinda stumped as to why this would be with my limited understanding of
ffmpeg, I have some theories surrounding the -loop filling memory with
copies of the img in a lossless format but any help would be most welcome.


More information about the ffmpeg-user mailing list