{"id":19660717,"url":"https://github.com/mconverti/media-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","last_synced_at":"2026-05-15T21:33:44.933Z","repository":{"id":142062763,"uuid":"105777795","full_name":"mconverti/media-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","owner":"mconverti","description":"A Frame Rate and Timecode Calculator Plugin for Azure Media Player","archived":false,"fork":false,"pushed_at":"2017-10-04T14:28:43.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-31T11:38:11.103Z","etag":null,"topics":["azure","azure-media-player","azure-media-services","framerate","javascript","timecode"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/mconverti.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,"zenodo":null}},"created_at":"2017-10-04T14:23:10.000Z","updated_at":"2017-12-08T14:34:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"82b1554d-cbd4-4ad8-8389-a6e3b806fef0","html_url":"https://github.com/mconverti/media-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mconverti/media-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mconverti","download_url":"https://codeload.github.com/mconverti/media-services-javascript-azure-media-player-framerate-timecode-calculator-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33080777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["azure","azure-media-player","azure-media-services","framerate","javascript","timecode"],"created_at":"2024-11-11T16:05:11.378Z","updated_at":"2026-05-15T21:33:44.928Z","avatar_url":"https://github.com/mconverti.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nservices: media-services\nplatforms: javascript\nauthor: @mconverti\n---\n\n# Media Services: Frame Rate and Timecode Calculator Plugin for Azure Media Player\n\n## Information\nAttributions:  Southworks 2017 \n\n# Introduction\nThis plugin calculates the frame rate of the current video source based on the `tfhd`/`trun` MP4 boxes of the first MPEG-DASH video fragment, parses the time scale value from the MPEG-DASH client manifest, and also provides a way to generate the timecode for a given absolute time from the player (and the other way around).\n\nIn order to expose these features, the plugin adds the following methods and events to the Azure Media Player (AMP) API:\n\n\u003e **IMPORTANT:** The frame rate calculation does not support Advanced Encryption Standard (AES) clear key encrypted content. For this scenario, the default frame rate value from the plugin configuration options will be used or you can manually override the frame rate value.\n\n### `frameRate` method\nThis method returns the frame rate value of the current video source based on the `tfhd`/`trun` MP4 boxes of the first MPEG-DASH video fragment. If the calculation fails, it returns the default value configured in the plugin options.\n\nThis method also lets the user override the frame rate value manually.\n\n```\n// Get frame rate value\nvar frameRate = player.frameRate();\n\n// Manually override frame rate value to 24 fps\nplayer.frameRate(24);\n```\n\n### `timeScale` method\n\nThis method exposes the time scale value parsed from the MPEG-DASH client manifest of the current video source. If the parsing fails, it returns the default value configured in the plugin options.\n\n```\n// Get time scale value\nvar timeScale = player.timeScale();\n```\n\n### `dropFrame` method\n\nThis method lets the user get or set a flag to enable/disable drop frame timecodes for 29.97fps. It takes the default value from the plugin configuration options.\n\n```\n// Get drop frame flag value for 29.97fps\nvar dropFrameFlag = player.dropFrame();\n\ndropFrameFlag = !dropFrameFlag;\n\n// Update drop frame flag value for 29.97fps\nplayer.dropFrame(dropFrameFlag);\n```\n\n### `toTimecode` method\n\nThis method lets the user obtain the timecode string from a given absolute time; the method internally uses the frame rate value and the drop frame flag. If the absolute time value is invalid, it returns `null`.\n\n```\n// Get the current absolute time from the player\nvar absoluteTime = player.toPresentationTime(player.currentTime());\n\n// Convert the absolute time into timecode\nvar timecode = player.toTimecode(absoluteTime);\n```\n\n### `fromTimecode` method\n\nThis method lets the user obtain an absolute time based on a given timecode string; the method internally uses the frame rate value and the drop frame flag. If the timecode value is invalid, it returns `null`.\n\n```\n// Get the absolute time for the timecode\nvar timecode = \"0:01:07:12:20\";\nvar absoluteTime = player.fromTimecode(timecode);\n\n// Seek to the absolute time represented by the timecode\nplayer.currentTime(player.fromPresentationTime(absoluteTime));\n```\n\n### `framerateready` event\n\nThe calculation and parsing logic are asynchronous operations that start when loading a video source into the player; in order to be notified when the frame rate and time scale values are available, you can register a listener for the `amp.eventName.framerateready` event.\n\n### `framerateerror` event\n\nIf there is an error while calculating the frame rate value (for example, the input is an AES encrypted source), the `amp.eventName.framerateerror` event is fired in order to notify the user about the error and that the default configuration values will be used.\n\n### `dropframechanged` event\n\nThe `amp.eventName.dropframechanged` event lets the user to get a notification every time the drop frame flag value changes.\n\n# Getting Started\nInclude the plugin JavaScript file *after* the AMP script in the `\u003chead\u003e` of your html page:\n\n```\u003cscript src=\"amp-frameRateTimecodeCalculator.js\"\u003e\u003c/script\u003e```\n\nThen add a listener for the `amp.eventName.framerateready` event in order to be notified when the frame rate value is available. It's also recommended to add a listner for the `amp.eventName.framerateerror` event in order to be notified if there is an error during the calculation process (meaning that default values in configuration will be used).\n\n```\n\u003cscript\u003e\n    var player = amp('azuremediaplayer', {\n        \"nativeControlsForTouch\": false,\n        \"plugins\": {\n            // Enable plugin\n            \"frameRateTimecodeCalculator\": {\n                // Optional: default frame rate value to use if calculation fails\n                // If not provided, the default value is 30\n                \"default\": 30,\n                // Optional: default time scale value to use if client manifest parsing fails\n                // If not provided, the default value is 10000000\n                \"timeScale\": 10000000,\n                // Optional: Flag to determine whether to use drop frame timecode or not for 29.97fps\n                // If not provided, the default value is false (non-drop frame timecode)\n                \"dropFrame\": false\n            }\n        }\n    });\n\n    player.src([{\n        src: \"//amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest\",\n        type: \"application/vnd.ms-sstr+xml\"\n    }]);\n\n    player.ready(function () {\n        // Listen the \"framerateready\" event to be notified when the frame rate and timecode \n        // calculations are available\n        player.addEventListener(amp.eventName.framerateready, function () {\n            onFrameRateReady();\n        });\n\n        // Listen the \"framerateerror\" event to be notified if there is an error during the \n        // calculation process and the default frame rate and time scales values is configuation\n        // will be used\n        player.addEventListener(amp.eventName.framerateerror, function () {\n            alert(\"There was an error calculating the Frame Rate and Time Scale. Using default values in configuration.\");\n\n            onFrameRateReady();\n        });\n\n        function onFrameRateReady() {\n            // Frame rate value available\n            var framerate = player.frameRate();\n            // Time scale value available\n            var timeScale = player.timeScale();\n\n            player.addEventListener(amp.eventName.timeupdate, function () {\n                // Convert the player absolute time into timecode\n                var timecode = player.toTimecode(player.toPresentationTime(player.currentTime()));\n            });\n\n            // Listen the \"dropframechanged\" event to be notified when the drop frame flag changes\n            player.addEventListener(amp.eventName.dropframechanged, function () {\n                // Convert the player absolute time into timecode\n                var timecode = player.toTimecode(player.toPresentationTime(player.currentTime()));\n            });\n        }\n    });\n\n    // ...\n\n    function onSeekToTimecode() {\n        // Convert the timecode into player absolute time\n        var timecode = \"0:01:27:47:20\";\n        var absoluteTime = player.fromTimecode(timecode);\n\n        player.currentTime(player.fromPresentationTime(absoluteTime));\n    }\n\u003c/script\u003e\n```\n\nSee `example.html` for a full example on how to enable and use the plugin.\n\n## Options\nCurrently supported JSON options: \n\n```\n{\n    // Optional: default frame rate value to use if calculation fails\n    // If not provided, the default value is 30\n    \"default\": 30,\n    // Optional: default time scale value to use if client manifest parsing fails\n    // If not provided, the default value is 10000000\n    \"timeScale\": 10000000,\n    // Optional: Flag to determine whether to use drop frame timecode or not for 29.97fps\n    // If not provided, the default value is false (non-drop frame timecode)\n    \"dropFrame\": false\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmconverti%2Fmedia-services-javascript-azure-media-player-framerate-timecode-calculator-plugin/lists"}