# FFmpeg consumer constant failure - cannot allocate memory

**URL:** <https://casparcgforum.org/t/ffmpeg-consumer-constant-failure-cannot-allocate-memory/6531>\
**Category:** General\
**Tags:** server\
**Created:** [April 17, 2024, 7:53am UTC](https://casparcgforum.org/t/ffmpeg-consumer-constant-failure-cannot-allocate-memory/6531 "2024-04-17T07:53:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paveltonev](https://casparcgforum.org/letter_avatar_proxy/v4/letter/p/bcef8e/32.png) [@paveltonev](https://casparcgforum.org/u/paveltonev)\
**Post date:** [April 17, 2024, 7:53am UTC](https://casparcgforum.org/t/ffmpeg-consumer-constant-failure-cannot-allocate-memory/6531/1 "2024-04-17T07:53:26Z")

</div>

Hi,

I use [**CasparCG server v2.4.0-rc1**](https://github.com/CasparCG/server/releases/tag/v2.4.0-rc1) and start ffmpeg consumer started via:

```auto
<consumers>
    <ffmpeg>
        <path>udp://127.0.0.1:9094?pkt_size=1316&bitrate=8000000&reuse=1&overrun_nonfatal=1&max_interleave_delta=1000000&fifo_size=xxxxxxx&buffer_size=yyyyyyyyy</path>
        <args>-codec:v h264_nvenc -preset:v p7 -profile:v high -tune:v ll -level:v 4.2 -g:v 50 -rc:v cbr -b_ref_mode:v middle -temporal-aq:v 1 -rc-lookahead:v 20 -i_qfactor:v 0.75 -b_qfactor:v 1.1 -bufsize:v 0.7M -max_delay 0.7M -pcr_period 30 -minrate:v 7M -maxrate:v 7M -b:v 7M -bf:v 2 -qmin:v 0 -ac:a 2 -channel_layout:a stereo -codec:a aac -ar:a 48000 -b:a 256K -bufsize:a 128K -minrate:a 256K -maxrate:a 256K -format mpegts -muxrate 8M -mpegts_flags +system_b -fflags +genpts+nofillin -flush_packets 0 -mpegts_pmt_start_pid 0x1500 -mpegts_start_pid 0x150 -mpegts_service_type advanced_codec_digital_hdtv</args>
    </ffmpeg>
</consumers>

```

with [CasparCG client v2.3.0-rc1](https://github.com/CasparCG/client/releases/tag/v2.3.0-rc1) executing a 48 hours playlist. Everything started as expected and on the **12th minute** the ffmpeg cosumer _ **terminates** _ with **Cannot allocate memory** issue described [here](https://casparcgforum.org/t/cannot-allocate-memory-on-casparq-version-2-3-2/5665). It appeared that this error has already been reported as issue on ffmpeg trac system [here](https://trac.ffmpeg.org/ticket/6463).

I **increased 10 times** the default **fifo\_size** and **buffer\_size** values, as a result the ffmpeg consumer **failed** in around **120 minutes**.

I **increased 20 times** the default **fifo\_size** and **buffer\_size** values, as a result the ffmpeg consumer **failed** in around **240 minutes**.

As a conclusion it appeared that ffmpeg consumer termination depends on fifo\_size and buffer\_size values.

Before fixing, if possible, this issue one possible solution is to stop the existing consumer and start a new one on each entry in the playlist.

Do you have other suggestions?

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [April 17, 2024, 8:09am UTC](https://casparcgforum.org/t/ffmpeg-consumer-constant-failure-cannot-allocate-memory/6531/2 "2024-04-17T08:09:50Z")

</div>

> [@paveltonev](#):
>
> Before fixing, if possible, this issue one possible solution is to stop the existing consumer and start a new one on each entry in the playlist.

Yes, I would try that. Just play the next clip on another layer and clear the old one. Afterwards you can reuse the first.

---

<div class="post-metadata">

**Author:** ![paveltonev](https://casparcgforum.org/letter_avatar_proxy/v4/letter/p/bcef8e/32.png) [@paveltonev](https://casparcgforum.org/u/paveltonev)\
**Post date:** [April 17, 2024, 1:18pm UTC](https://casparcgforum.org/t/ffmpeg-consumer-constant-failure-cannot-allocate-memory/6531/3 "2024-04-17T13:18:51Z")

</div>

Thank you for the direction!  
My plan was to use:

```auto
1) ADD 1-700 STREAM ........
2) PLAY 1-10 MY_CLIP
3) REMOVE 1-700
4) ADD 1-700 STREAM ........
5) PLAY 1-10 MY_NEXT_CLIP

```

With regards to playing next clip on another layer, how it will look like from AMCP standpoint? Should I create a second consumer while the first is running to take the second clip?

Is it possible your proposal to be integrated in any of the available platforms like Sofie, Nebula or SuperConductor ?

Thank you!

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [April 17, 2024, 3:04pm UTC](https://casparcgforum.org/t/ffmpeg-consumer-constant-failure-cannot-allocate-memory/6531/4 "2024-04-17T15:04:32Z")

</div>

Aha, sorry, I did not realize, that you want to stream. So my comment does not make any sense…
