[FFmpeg-user] Facing issues in streaming videos

Ted Park kumowoon1025 at gmail.com
Tue Mar 17 09:24:09 EET 2020


Hi,

So it starts out like this:
> top - 11:02:19 up 16:48,  3 users,  load average: 0.04, 0.01, 0.00

> KiB Mem : 16423264 total, 14990164 free,   642272 used,   790828 buff/cache
> KiB Swap:   999420 total,   999420 free,        0 used. 15408016 avail Mem
> 
>  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
> 5979 root      20   0   76104  23360  10300 R   2.2  0.1   0:00.50 ffmpeg

And looks like this in an hour..
> top - 11:59:05 up 17:45,  3 users,  load average: 0.82, 0.56, 0.24

> KiB Mem : 16423264 total, 11981684 free,   645936 used,  3795644 buff/cache
> KiB Swap:   999420 total,   999420 free,        0 used. 15363132 avail Mem
> 
>  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
> 5979 root      20   0   76104  23360  10300 S   2.0  0.1   1:09.99 ffmpeg
> 6305 root      20   0   49120   4044   3188 R   0.3  0.0   0:00.02 top
> 
> 
> In one hour of duration it used memory is gradually increasing.
> 
> Kindly give us solution for this.

In ~1hr buff/cache used (probably buffers mostly) increased by (3795644-790828)KiB=3004816KiB
So an average of about 900KiB/s

I assume this only happens when streaming with ffmpeg?

It does look like they are closely related if so,
> And console output of the streaming as follows
> 
> 
> 
> root at TESTING-FFMPEG:/var/www/html/hls/live/mobile/testing#  ffmpeg -threads
> 1 -i udp://231.1.1.108:1026 -c:v copy -c:a copy -f mpegts
> /home/user/ffmpeg-4.2.2/Ajk_live_Telecast.m3u8

> Output #0, mpegts, to '/home/user/ffmpeg-4.2.2/Ajk_live_Telecast.m3u8':
>  Metadata:
>    encoder         : Lavf58.29.100
>    Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(top
> first), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 50 tbr, 90k tbn, 90k
> tbc
>    Stream #0:1: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo,
> fltp, 128 kb/s
> Stream mapping:
>  Stream #0:0 -> #0:0 (copy)
>  Stream #0:1 -> #0:1 (copy)
> 
> Stream #0:1 -> #0:1 (copy)
> Press [q] to stop, [?] for help
> frame=  447 fps=0.0 q=-1.0 size=    7680kB time=00:00:07.80
> bitrate=8059.7kbits/s speed=15.4x
> frame=  477 fps=474 q=-1.0 size=    8448kB time=00:00:08.30
> bitrate=8332.0kbits/s speed=8.25x

> frame= 1281 fps= 89 q=-1.0 size=   22784kB time=00:00:21.70
> bitrate=8598.8kbits/s speed=1.51x
> frame= 1290 fps= 88 q=-1.0 Lsize=   23163kB time=00:00:21.85
> bitrate=8681.7kbits/s speed= 1.5x


The stream bitrate reaches ~1000kB/s which is similar so it’s probably the disk buffer that’s taking up the memory.

But if you look at the available memory, it only drops from 15408016 KiB to 15363132KiB, about 50MB. If you start another program that requires a lot of memory, that buffer would probably be cleared immediately.

The other situation where you are downloading the stream and starting a dozen transcoding jobs is different, in that case that memory is taken. 

What I mean is this doesn’t seem out of the ordinary at all.


Regards,
Ted Park



More information about the ffmpeg-user mailing list