2017-12-31 180 views
12

https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints पर "छवि ट्रैक की गुण" नामक एक अनुभाग है। मैं इन सेटिंग्स को कैसे समायोजित करूं?मैं छवि ट्रैक सेटिंग्स को कैसे कार्यान्वित करूं

जब मैं navigator.mediaDevices.getSupportedConstraints() चलाने मैं निम्नलिखित मिल:

{ 
    "aspectRatio": true, 
    "brightness": true, 
    "channelCount": true, 
    "colorTemperature": true, 
    "contrast": true, 
    "depthFar": true, 
    "depthNear": true, 
    "deviceId": true, 
    "echoCancellation": true, 
    "exposureCompensation": true, 
    "exposureMode": true, 
    "facingMode": true, 
    "focalLengthX": true, 
    "focalLengthY": true, 
    "focusMode": true, 
    "frameRate": true, 
    "groupId": true, 
    "height": true, 
    "iso": true, 
    "latency": true, 
    "pointsOfInterest": true, 
    "sampleRate": true, 
    "sampleSize": true, 
    "saturation": true, 
    "sharpness": true, 
    "torch": true, 
    "videoKind": true, 
    "volume": true, 
    "whiteBalanceMode": true, 
    "width": true, 
    "zoom": true 
} 

मैं "वीडियो ट्रैक की गुण" video

navigator.mediaDevices.getUserMedia({ 
    video: { 
    aspectRatio: 1.5, 
    width: 1280, 
    }, 
}) 

के तहत समायोजित कर सकते हैं लेकिन मुझे यकीन है कि कैसे focalLengthX की तरह गुण समायोजित करने के लिए नहीं कर रहा हूँ या exposureCompensation। मैं उन्हें कहां समायोजित करूंगा?

+0

आप वस्तु '.getUserMedia()' के लिए पारित पर संपत्ति और मान सेट की कोशिश की? – guest271314

उत्तर

2

एमएसएन से मुझे प्रक्रिया का वर्णन करने वाले कुछ दस्तावेज़ मिले। अनिवार्य रूप से, आप न्यूनतम और अधिकतम स्वीकार्य मान निर्दिष्ट कर सकते हैं प्रति न्यूनतम और अधिकतम मूल्य प्रति बाधा के साथ। केवल बाधा विकल्प ऑब्जेक्ट में जोड़े गए मान बदले जाएंगे।

const constraints = { 
    width: {min: 640, ideal: 1280, max: 1920}, 
    height: {min: 480, ideal: 720} 
}; 

navigator.mediaDevices.getUserMedia({ video: true }) 
.then(mediaStream => { 
    const track = mediaStream.getVideoTracks()[0]; 
    track.applyConstraints(constraints) 
    .then(() => { 
    // Do something with the track such as using the Image Capture API. 
    } 
    .catch(e => { 
    // The constraints could not be satisfied by the available devices. 
    } 
} 

https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/applyConstraints

संबंधित मुद्दे