Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P PyAV
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 37
    • Issues 37
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 26
    • Merge requests 26
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyAV
  • PyAV
  • Merge requests
  • !581

updated examples, added container.close()

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Ihor Liubymov requested to merge github/fork/mastak/update-examples into develop Dec 12, 2019
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 4

I took code from example as a base and got a memory leak. Reason: there is no close method for the container.

I verified on small video: 2sec, 360:

without close: without_close

with close: with_close

Simplified code:

import av
import av.datasets
import psutil

current_process = psutil.Process()

get_mem_uss = lambda: current_process.memory_full_info().uss

PATH = '...'


def read_frames(path):
    container = av.open(path)
    return [frame.to_ndarray(format='yuv420p') for frame in container.decode(video=0)]


started_with = get_mem_uss()
for i in range(15000):
    read_frames(PATH)
    if i % 50:
        print(f'Used memory {(get_mem_uss() - started_with) / 1024 / 1024}')
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/mastak/update-examples