35

I cloned a project about real-time image processing on a web browser from this link: Then I could not allow my browser to access my camera. I got this javascript alert:

Uh-oh, the webcam didn't start. Do you have a webcam? Did you give it permission? Refresh to try again. And the allow button is not shown as if I access his site.

max taldykin
  • 12,459
  • 5
  • 45
  • 64
Methuz Kaewsai-kao
  • 1,176
  • 2
  • 10
  • 22
  • Did you give your website the media permission in your browser? (click the icon next to the URL to see) **edit** sometimes local files have even tighter security – Paul S. May 30 '13 at 11:55
  • This [link](https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339) might help someone. – Ishaan Jan 27 '21 at 08:05

9 Answers9

52

To ignore Chrome’s secure origin policy, follow these steps.

Navigate to chrome://flags/#unsafely-treat-insecure-origin-as-secure in Chrome.

Find and enable the Insecure origins treated as secure section (see below).

Add any addresses you want to ignore the secure origin policy for. Remember to include the port number too (if required).

Save and restart Chrome.

I found solution from below link.Hope it will help to someone

https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339

DKR
  • 5,426
  • 1
  • 19
  • 21
30

Are you accessing the webpage that is served over HTTP, on localhost? If you are accessing it from http://localhost/... , Chrome will ask for your permission to use the camera.

Chrome accessing camera on localhost

If you are opening the web page directly, i.e. /Users/Methuz/Documents/index.html then it will not work, even if you explicitly allows it permission

Chrome cannot access camera over file protocol


In this case, the workaround I use is to host the HTML file on a webserver. A quick hack is to use python, in the folder where the HTML page is lcoated: python -m SimpleHTTPServer

Hanxue
  • 12,243
  • 18
  • 88
  • 130
  • 2
    I use this solution too, but at every refresh it asks me camera permissions again, any idea how to "save" those permissions for "localhost:8000" ? – ricricucit Mar 04 '14 at 16:12
  • That's exactly what I do too! – Adrian Lynch May 07 '15 at 15:22
  • http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python for more info on how to access the site after setting up the server – Tariq Aug 07 '15 at 18:43
  • 1
    I know we're not supposed to "thank you" but that python command is awesome, thanks. – dmgig Nov 25 '16 at 18:13
  • 1
    Try `python -m http.server []` for python 3 (https://stackoverflow.com/questions/17351016/set-up-python-simplehttpserver-on-windows) and/or try `py` instead of `python` – Justin Mar 10 '20 at 20:55
12

Chrome now only allows https:// servers to persistent list (version 39.xx)

https://support.google.com/chrome/answer/2693767?hl=en

Allow: This allows the site to access your camera and microphone at this time and a notification will appear confirming that you’ve granted access. If you select Allow on a "http" URL your preference will not be remembered in future visits. If you select Allow on a "https" URL, your preference will be remembered in future visits.

Maybe this link helps to set your local secure server if you are using Wamp. http://forum.wampserver.com/read.php?2,32986

Then you can add your local server to persistent allow list of chrome.

effe
  • 1,335
  • 3
  • 17
  • 26
11

Step 1: Find your chrome preferences file: http://www.forensicswiki.org/wiki/Google_Chrome#Configuration

Step 2: Open it and Find the "profile" key

Step3: Under profile there will be a "content_settings" hash, that will have a "pattern_pairs" hash Add this to it:

  "*,*": {
    "media-stream-camera": 1
  }

Final example:

"profile": {
   ....
   "content_settings": {
      ....
      "pattern_pairs": {
         "*,*": {
            "media-stream-camera": 1
         },
         ....
      }
    }
}

WARNING: This will allow all websites access to your camera

Erik Petersen
  • 2,347
  • 14
  • 17
0

Got this problem for days, only this helped:

Reinstall Chrome by removing configuration as well. And try not to sync all the extensions, as they may interfere.

sudo apt-get purge google-chrome-stable
rm -rf ~/.config/google-chrome

Then install from official.

Victor Timoftii
  • 2,717
  • 1
  • 16
  • 15
-2

Another solution is to use iframe tag. Jest deploy your page on server (localhost or external) and include it in your local html. Example:

<iframe src="http://localhost/your_project/index.html"></iframe>
ZimaXXX
  • 1,255
  • 11
  • 11
-2

Chrome on HTTP or any other port won't save the preference of Camara share choice.

To save the selection you will need to run on HTTPs, even if you don't have SSL certificate on localhost that fine. Just add https before the localhost url and it will ask you its unsafe, if you want to proceed add it as an exception under Advance options. Do that and then Chrome will save you camera sharing preference for this website. and won't ask you to select allow

quaidj
  • 1
-3

You can choose a different default permission setting and manage exceptions in Content settings.

  1. Click the Chrome menu Chrome menu on the browser toolbar.
  2. Select Settings.
  3. Click Show advanced settings.
  4. In the "Privacy" section, click Content settings.
  5. In the "Media" section:

* Ask me when a site requires access to my camera and microphone: Select this option if you want Chrome to alert you whenever a site requests access to your camera and microphone.

* Do not allow sites to access my camera and microphone: Select this option to automatically deny any site requests to access your camera and microphone.

Or click Manage exceptions to remove previously-granted permissions for specific sites. Source: https://support.google.com/chrome/answer/2696491?hl=en

P/D: the link you provided has an error. I can't access.

gal007
  • 6,911
  • 8
  • 47
  • 70
-5

Open localhost/webcam.swf then right click on the flash file then allow the webcam and tick remember that will add exception for localhost

monir
  • 1