Hello,
I am facing a situation where memory grows too much to execute a
'complex_filter'. I found a workaround but I'd like to have your thoughts on a
more elegant solution.
The pipeline is basically (see attached file script_no_bench.txt):
- one input stream
- preprocess (eg. eq=saturation=1.1)
- split the input stream in K parts
- trim each part in disjoint temporal segments (eg. frames 0 to 9, 10 to 19, 20
to 29 ...)
- eventually process each segment independently (eg. crop)
- join each processed stream (eg. hstack)
- output
The problem comes from the fact that ffmpeg is processing and *buffering* all
frames from the (K-1) parts before being able to output the first one from the
join part. And it can grow fast (with a toy example of 10 slices, 100xRGBAxHD
frames each, it goes around 7GB).
As far as I understand ffmpeg only has one "read pointer" on the file and
process it sequentially, hence the current behavior.
One workaround would be to open the input file in K streams, each shifted by
some time with '-ss' option, but this would require to duplicate the
(potentially long) preprocessing part, and the '-ss' option is not frame
accurate.
The workaround I currently use is to render each splited/trimmed/processed part
in a first pass, then open all inputs and join/postprocess them in a second
pass. But I am not very satisfied by the intermediate rendering to disk.
On a side note, the preprocess/process/postprocess parts given are only
examples, for the sake of illustration. It can potentially be long processes,
some of which might happens on GPU VRAM (OpenCL), hence the memory constraints.
So, do you have a more elegant solution to propose, which would avoid memory
grow and intermediate rendering to disk?
Adrien F
[0:v]scale=w=-8:h=512:flags=bicubic[c426e043];
[split0-0]trim=start_frame=0:end_frame=1442, loop=0:1442:0,
setpts=PTS-STARTPTS[86db30b3];
[86db30b3]crop=iw/8:512:0:0[4d01ec93];
[split0-1]trim=start_frame=1442:end_frame=2884, loop=0:1442:0,
setpts=PTS-STARTPTS[c4e7185d];
[c4e7185d]crop=iw/8:512:0:0[28ed01c2];
[split0-2]trim=start_frame=2884:end_frame=4326, loop=0:1442:0,
setpts=PTS-STARTPTS[62945e35];
[62945e35]crop=iw/8:512:0:0[06809959];
[split0-3]trim=start_frame=4326:end_frame=5768, loop=0:1442:0,
setpts=PTS-STARTPTS[710f32bd];
[710f32bd]crop=iw/8:512:0:0[8188daaf];
[split0-4]trim=start_frame=5768:end_frame=7210, loop=0:1442:0,
setpts=PTS-STARTPTS[016a59e9];
[016a59e9]crop=iw/8:512:0:0[282ddbad];
[split0-5]trim=start_frame=7210:end_frame=8652, loop=0:1442:0,
setpts=PTS-STARTPTS[194c8b9a];
[194c8b9a]crop=iw/8:512:0:0[9c16fe2f];
[split0-6]trim=start_frame=8652:end_frame=10094, loop=0:1442:0,
setpts=PTS-STARTPTS[5117d40d];
[5117d40d]crop=iw/8:512:0:0[1f25ac57];
[split0-7]trim=start_frame=10094:end_frame=11536, loop=0:1442:0,
setpts=PTS-STARTPTS[e632b599];
[e632b599]crop=iw/8:512:0:0[8fdf41ab];
[4d01ec93][28ed01c2][06809959][8188daaf][282ddbad][9c16fe2f][1f25ac57][8fdf41ab]hstack=inputs=8[458940bb];
[c426e043]split=8[split0-0][split0-1][split0-2][split0-3][split0-4][split0-5][split0-6][split0-7]
_______________________________________________
ffmpeg-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".