{"id":13835479,"url":"https://github.com/4ndrs/PureMPV","last_synced_at":"2025-07-10T07:32:19.075Z","repository":{"id":62774578,"uuid":"527142137","full_name":"4ndrs/PureMPV","owner":"4ndrs","description":"Get the file path, timestamps, and cropping coordinates, for ffmpeg, all from within mpv with just one copy 🎉❤️","archived":false,"fork":false,"pushed_at":"2024-08-17T21:48:41.000Z","size":437,"stargazers_count":28,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-08-18T17:49:26.370Z","etag":null,"topics":["ffmpeg","mpv","mpv-script","purewebm","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/4ndrs.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":"2022-08-21T08:00:13.000Z","updated_at":"2024-08-17T21:48:45.000Z","dependencies_parsed_at":"2023-02-04T13:00:15.741Z","dependency_job_id":"207b7556-1333-43a6-94be-4c853037cf75","html_url":"https://github.com/4ndrs/PureMPV","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4ndrs%2FPureMPV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4ndrs%2FPureMPV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4ndrs%2FPureMPV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4ndrs%2FPureMPV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4ndrs","download_url":"https://codeload.github.com/4ndrs/PureMPV/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225627386,"owners_count":17498975,"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","mpv","mpv-script","purewebm","typescript"],"created_at":"2024-08-04T14:01:02.972Z","updated_at":"2024-11-20T20:31:29.314Z","avatar_url":"https://github.com/4ndrs.png","language":"TypeScript","readme":"# PureMPV\n\nScript to get the timestamps, cropping coordinates, and file path of the playing video, for ffmpeg, all from within mpv.\n\n## Installation\nThe script currently supports Linux/macOS and depends on `xclip` or `wl-clipboard` on Linux and `pbcopy` on macOS to copy the data to the primary/clipboard selections. To install, change directory to your mpv scripts folder, and git clone this repository. An appropriate folder will be created:\n```console\n$ cd ~/.config/mpv/scripts\n$ git clone https://github.com/4ndrs/PureMPV.git\n```\n\nOr if just the script is preferred without downloading the whole source code, downloading the ```main.js``` file from the repository (or one of GitHub's automatic releases) and putting it in your mpv scripts folder is enough.\n\n\u003e[!NOTE]\n\u003eThe ```main.js``` in the repository does not get updated on every commit. For a bleeding-edge release of the file, [click here](https://github.com/4ndrs/PureMPV/releases/download/bleeding-edge/main.js), or if cloned, see [Building](#building).\n\nIt would probably be advisable to rename the ```main.js``` file when downloaded individually to avoid conflicts with other scripts in the folder.\n\n## Usage\n\n[usage_preview.webm](https://github.com/4ndrs/PureMPV/assets/31898900/a6ac3832-e086-4d4e-90bd-e625578296e8)\n\n\n\nThe script by default registers the start and end times by pressing \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ee\u003c/kbd\u003e, and waits until the user presses \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ew\u003c/kbd\u003e to copy the data to the **primary** selection.\n\nThe script can copy the following by default (PureMode):\n\n- Start \u0026 end time - \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ee\u003c/kbd\u003e\n- End time - \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eshift\u003c/kbd\u003e + \u003ckbd\u003ee\u003c/kbd\u003e\n- Cropping coordinates - \u003ckbd\u003ec\u003c/kbd\u003e\n- File path - \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ew\u003c/kbd\u003e\n\nTo copy in this mode, triggering the file path combination is necessary. If none of the above key combinations are omitted (or cancelled), the copied string will be formatted like the following:\n```console\nffmpeg -ss hh:mm:ss -to hh:mm:ss -i \"/path/to/file\" -lavfi crop=w:h:x:y\n```\nWhen omitting key combinations, the resulting string will have the values omitted as well, for example triggering just start time, and then the file path will yield the following string:\n```console\nffmpeg -ss hh:mm:ss -i \"/path/to/file\"\n```\n\nTo get just the end time the \u003ckbd\u003ectrl\u003c/kbd\u003e+\u003ckbd\u003eshift\u003c/kbd\u003e+\u003ckbd\u003ee\u003c/kbd\u003e key combination must be pressed with **PureMode** activated.\n\nThe default mode, and the selection to copy to can be changed creating a configuration file under ```$HOME/.config/mpv/script-opts/``` with the name **PureMPV.conf**, and inserting the following:\n```console\npure_mode=no\nselection=clipboard\n```\nWith the PureMode deactivated, the script will copy the resulting value of the key combination right away, without \"ffmpeg -i\", for example triggering \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ee\u003c/kbd\u003e will copy just the current timestamp, the \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ew\u003c/kbd\u003e will copy just the file path, and \u003ckbd\u003ec\u003c/kbd\u003e will copy just the cropping coordinates.\n\nCropping coordinates, and set start \u0026 end times, can be cancelled by pressing their own key combination a third time.\n\nA preview of the currently set settings can be generated pressing \u003ckbd\u003ectrl\u003c/kbd\u003e+\u003ckbd\u003eshift\u003c/kbd\u003e+\u003ckbd\u003ew\u003c/kbd\u003e in PureMode.\n\nOutput seeking can be enabled inserting ```input_seeking=no``` in the configuration file.\n\n## Cropping\nTo crop, it is necessary to put the mouse pointer in the starting position of the crop. After that, pressing the keybinding \u003ckbd\u003ec\u003c/kbd\u003e will start the cropping mode; position the mouse to the desired location to generate the cropping coordinates. To stop the cropping mode, press the keybinding again. The cropbox will be set if PureMode is on, and just copied if it is off.\n\n![vivycropbox_animation](https://user-images.githubusercontent.com/31898900/185887111-207cfa6b-610f-4952-a07e-58adafe7a3f9.gif)\n\n## Shared Data API\nOther scripts can access PureMPV's internal data (cropbox and timestamps), which is available using mpv's `user-data` property. It can be requested any time using `mp.get_property_native(\"user-data/PureMPV\")`. The returned object will have the following properties:\n\n```typescript\ninterface PureMPVData {\n  cropbox: {\n    w: number | null;\n    h: number | null;\n    x: number | null;\n    y: number | null;\n  };\n\n  timestamps: {\n    start: string | null;\n    end: string | null;\n  };\n}\n````\n\nAn example of its usage can be seen in [pwebm-helper](https://github.com/4ndrs/pwebm-helper), which uses PureMPV's data to encode video segments.\n\n## Keybindings summary\n|Keybinding|Name|Action|\n|----------|----|------|\n|\u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ep\u003c/kbd\u003e| ```toggle-puremode```| Activate/deactivate PureMode.\n|\u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ew\u003c/kbd\u003e| ```get-file-path```| Copy the file path with no formatting. \u003cbr /\u003e**PureMode**: copy the currently set parameters formatted with ffmpeg.\n|\u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eshift\u003c/kbd\u003e + \u003ckbd\u003ew\u003c/kbd\u003e| ```generate-preview```| **PureMode**: Generate a preview of the currently set parameters.\n|\u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ee\u003c/kbd\u003e| ```get-timestamp```| Copy the current time position with the format HH:MM:SS. \u003cbr /\u003e**PureMode**: Set the start time parameter if it is not set to the current time position, otherwise set the end time.\n|\u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eshift\u003c/kbd\u003e + \u003ckbd\u003ee\u003c/kbd\u003e| ```set-endtime```| **PureMode**: Set the end time parameter regardless of whether start time is set or not.\n|\u003ckbd\u003ec\u003c/kbd\u003e| ```get-crop```| Trigger cropping mode, and copy the cropped coordinates in the format W:H:X:Y.  \u003cbr /\u003e**PureMode**: Trigger cropping mode, and set the cropbox parameter.\n\nKeybindings can be changed using the names in this table and modifying your `input.conf`, or changing the relevant option key in the [configuration file](#configuration-file).\n\n## Configuration file\n\nThe configuration file is located in ```$HOME/.config/mpv/script-opts/PureMPV.conf```, and with it, it is possible to change the following options:\n|Option key|Values|Details|\n|----------|----|------|\n|pure_mode| yes\u003cbr\u003eno| Specifies if PureMode will be activated when running. Default is **yes**.\n|executable| executable | Specifies which program to prepend to the copied string in PureMode. Default is **ffmpeg**.\n|ffmpeg_params| params| Specifies which params to append to the copied string. Default is **empty**.\n|selection| primary\u003cbr\u003eclipboard| Specifies where to copy the string. Default is **primary**.\u003csup\u003e1\u003c/sup\u003e\n|copy_utility| detect\u003cbr\u003exclip\u003cbr\u003ewl-copy\u003cbr\u003epbcopy| Specifies which utility to use to copy the string. Default is **detect**.\n|hide_osc_on_crop| yes\u003cbr\u003eno| Specifies if the OSC (On Screen Controller) should be hidden when cropping. Default is **no**.\n|input_seeking| yes\u003cbr\u003eno| Specifies if input seeking should be assumed when formatting the timestamps with the inputs. Default is **yes**.\n|box_color| hex color | Specifies the color of the cropbox represented as an #RRGGBB hexadecimal value. Default is **#FF1493**.\n\n1. On macOS, the selection will always be `clipboard`.\n\n##### Keybinding options\n|Option key|Details|\n|----------|------|\n|key_crop|  default: **c**\n|key_preview|  default: **ctrl+shift+w**\n|key_pure_mode|  default: **ctrl+p**\n|key_file_path|  default: **ctrl+w**\n|key_timestamp|  default: **ctrl+e**\n|key_timestamp_end|  default: **ctrl+shift+e**\n\nAn example of the content of a configuration file could be the following:\n```bash\n# ~/.config/mpv/script-opts/PureMPV.conf\nexecutable=ffmpeg\npure_mode=yes\nselection=primary\ninput_seeking=yes\nhide_osc_on_crop=yes\nffmpeg_params=-map_metadata -1 -map_chapters -1 -f webm -row-mt 1 -speed 0 -c:v libvpx-vp9 -map 0:v -crf 10 -b:v 0 -pass 1 /dev/null -y\u0026\u0026\\\n\nkey_crop=ctrl+c\n```\n\n\n## Building\n\nFor building, having npm installed is necessary. To generate the ```main.js``` file with the latest changes, proceed with the following:\n\n```console\n$ npm ci\n$ npm run build\n```\n","funding_links":[],"categories":["Video Editing","TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4ndrs%2FPureMPV","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4ndrs%2FPureMPV","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4ndrs%2FPureMPV/lists"}