{"id":18136257,"url":"https://github.com/purarue/mlength","last_synced_at":"2026-05-02T06:40:07.852Z","repository":{"id":193998082,"uuid":"689889450","full_name":"purarue/mlength","owner":"purarue","description":"gets the length of media files and caches the result","archived":false,"fork":false,"pushed_at":"2024-10-25T17:28:59.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T23:34:05.293Z","etag":null,"topics":["ffmpeg","ffprobe","media"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purarue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-11T05:56:45.000Z","updated_at":"2024-10-25T17:29:03.000Z","dependencies_parsed_at":"2024-11-01T14:41:34.266Z","dependency_job_id":"faf404d8-30ce-4ba9-b916-03c62a10b28f","html_url":"https://github.com/purarue/mlength","commit_stats":null,"previous_names":["seanbreckenridge/mlength"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fmlength","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fmlength/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fmlength/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fmlength/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purarue","download_url":"https://codeload.github.com/purarue/mlength/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517919,"owners_count":20951719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffmpeg","ffprobe","media"],"created_at":"2024-11-01T14:41:26.477Z","updated_at":"2026-05-02T06:40:07.847Z","avatar_url":"https://github.com/purarue.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mlength\n\ngets the length of media files and caches the result\n\n## Installation\n\nRequires `python3.10+`\n\nTo install with pip, run:\n\n```\npip install mlength\n```\n\nThis requires either `ffprobe` (from `ffmpeg`) or [`mediainfo`](https://mediaarea.net/en/MediaInfo) to be installed.\n\n## Usage\n\n```\nUsage: mlength [OPTIONS] MEDIA...\n\n  Compute the duration of media files\n\n  This caches the duration of media files in a cache directory, so that\n  subsequent runs are faster. If media files are modified, the cache is recomputed\n\n  MEDIA is a list of media files to compute the duration of\n\nOptions:\n  --cache-dir PATH                Cache directory  [default: ~/.cache/mlength]\n  --lib [mediainfo|ffprobe]       Library to use for parsing media files  [env\n                                  var: MLENGTH_LIB; default: ffprobe]\n  --cache / --no-cache            Enable/disable caching  [default: cache]\n  -o, --operation [sum|max|min|avg]\n                                  Operation to perform on the durations\n  -d, --display [ms|s|m|human|path|all]\n                                  Display format for durations\n  --debug                         Enable debug mode\n  --help                          Show this message and exit.\n```\n\n```bash\n$ mlength sound.mpeg\n00:00:02.95\n$ mlength -d all sound.mpeg\n2951|2.95|0.05|00:00:02.95|sound.mpeg\n```\n\nI use this in lots of small scripts:\n\nGet the shortest media file in a directory, with the [list-movies](https://github.com/purarue/pura-utils/blob/main/shellscripts/list-movies) script:\n\n- `list-music -X mlength -o sum` (find length of an album in current directory)\n- `list-movies -X mlength -d path -o min` (find shortest movie in current directory)\n- `list-movies -X mlength -d all | sort -n` (sort results by length)\n\nIf the media file is modified, the cache is recomputed.\n\n### Tests\n\n```bash\ngit clone 'https://github.com/purarue/mlength'\ncd ./mlength\npip install '.[testing]'\nflake8 ./mlength\nmypy ./mlength\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Fmlength","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurarue%2Fmlength","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Fmlength/lists"}