|
| 1 | +--- |
| 2 | +id: video-injection |
| 3 | +title: Video Injection |
| 4 | +sidebar_label: Video Injection |
| 5 | +description: Now you can test image capturing and QR code or Barcode scanning in your app on LambdaTest Real Device Cloud Platform with 3000+ real mobile devices. |
| 6 | +keywords: |
| 7 | + - image injection |
| 8 | + - app test automation |
| 9 | + - camera image |
| 10 | + - QR code scanning |
| 11 | + - Barcode scanning |
| 12 | + - lambdatest capture code |
| 13 | + - framework on lambdatest |
| 14 | + - app testing appium |
| 15 | + - app testing |
| 16 | + - real devices |
| 17 | +url: https://www.lambdatest.com/support/docs/video-injection/ |
| 18 | +site_name: LambdaTest |
| 19 | +slug: video-injection/ |
| 20 | +--- |
| 21 | + |
| 22 | +import CodeBlock from '@theme/CodeBlock'; |
| 23 | +import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys"; |
| 24 | + |
| 25 | +import Tabs from '@theme/Tabs'; |
| 26 | +import TabItem from '@theme/TabItem'; |
| 27 | + |
| 28 | +<script type="application/ld+json" |
| 29 | + dangerouslySetInnerHTML={{ __html: JSON.stringify({ |
| 30 | + "@context": "https://schema.org", |
| 31 | + "@type": "BreadcrumbList", |
| 32 | + "itemListElement": [{ |
| 33 | + "@type": "ListItem", |
| 34 | + "position": 1, |
| 35 | + "name": "Home", |
| 36 | + "item": "https://www.lambdatest.com" |
| 37 | + },{ |
| 38 | + "@type": "ListItem", |
| 39 | + "position": 2, |
| 40 | + "name": "Support", |
| 41 | + "item": "https://www.lambdatest.com/support/docs/" |
| 42 | + },{ |
| 43 | + "@type": "ListItem", |
| 44 | + "position": 3, |
| 45 | + "name": "Camera Image Injection", |
| 46 | + "item": "https://www.lambdatest.com/support/docs/camera-image-injection/" |
| 47 | + }] |
| 48 | + }) |
| 49 | + }} |
| 50 | +></script> |
| 51 | +Video Injection feature enables you to test video-based functionalities such as **live streaming, real-time video capture,** and **video processing** in your app across 10000+ real devices on the LambdaTest Real Device Cloud platform. |
| 52 | + |
| 53 | +This tool is ideal for testing features such as: |
| 54 | + |
| 55 | +- Real-time video streaming and playback |
| 56 | +- Video-based verification (e.g., identity verification using live video) |
| 57 | +- Video capture and upload workflows |
| 58 | +- In-app video recording features |
| 59 | + |
| 60 | +## How It Works |
| 61 | +LambdaTest utilizes **Sensor Instrumentation** to integrate with various mobile sensors, including the camera. When you enable Video Injection for a session, LambdaTest injects its camera code module into your app through Sensor Instrumentation. This module then mocks or overrides the iOS SDK used in your app. |
| 62 | + |
| 63 | +:::warning note |
| 64 | +- This feature is currently available on iOS only. Support for Android will be available soon. |
| 65 | +::: |
| 66 | + |
| 67 | + |
| 68 | +## Video Injection in App Automation |
| 69 | + |
| 70 | +This section explains how to use Video Injection with App automation. This section will also teach you how to use video injection for all the possible test cases for your app along with other useful information. |
| 71 | + |
| 72 | +### Step 1: Upload video to LambdaTest |
| 73 | + |
| 74 | +You can use the following curl command to upload any video of your choice to the LambdaTest cloud. Please note that we support only **MP4 format is only supported and the video can be 50 MB or less**. |
| 75 | + |
| 76 | +<div className="lambdatest__codeblock"> |
| 77 | +<CodeBlock className="language-bash"> |
| 78 | +{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" -X POST "https://mobile-mgm.lambdatest.com/mfs/v1.0/media/upload" -F "media_file=@"/Users/macuser/Downloads/video.mp4"" -F "type="video"" -F "custom_id="SampleVideo""`} |
| 79 | +</CodeBlock> |
| 80 | +</div> |
| 81 | + |
| 82 | +Response of above cURL will be a JSON object containing the `media_url` of the format - lt://MEDIA123456789123456789 as shown below. |
| 83 | + |
| 84 | +```js |
| 85 | +{ |
| 86 | +"media_url":"lt://MEDIA123456789123456789", |
| 87 | +"name":"Video_123.mp4", |
| 88 | +"status":"success", |
| 89 | +"custom_id":"SampleVideo" |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +### Step 2: Enable Video injection in the Appium Session |
| 94 | + |
| 95 | +You can use the appium capability to turn the video injection on in your application. Just add `"enableVideoInjection": True` in the desired capabilities while writing the automation script. By adding this capability the app undergoes Sensor Instrumentation, which was described earlier in the documentation. Also adding media url `"media": "lt://MEDIA123456789123456789"` in the capabilities to inject the video is now optional and can be passed in LambdaHook as mentioned in step 3. |
| 96 | + |
| 97 | +<Tabs className="docs__val"> |
| 98 | + |
| 99 | +<TabItem value="python" label="Python" default> |
| 100 | + <div className="lambdatest__codeblock"> |
| 101 | + <CodeBlock className="language-python"> |
| 102 | + {`desired_capabilities = { |
| 103 | + "enableVideoInjection": True, |
| 104 | + "media": "lt://MEDIAf446d4170cd946aa9ec307d10cb679b9", #Add media_url here (optional) |
| 105 | + }`} |
| 106 | + </CodeBlock> |
| 107 | + </div> |
| 108 | +</TabItem> |
| 109 | + |
| 110 | + |
| 111 | +<TabItem value="JavaScript" label="JavaScript" default> |
| 112 | + <div className="lambdatest__codeblock"> |
| 113 | + <CodeBlock className="language-javascript"> |
| 114 | + {`DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); |
| 115 | +desiredCapabilities.setCapability("enableVideoInjection", "true");`} |
| 116 | + </CodeBlock> |
| 117 | + </div> |
| 118 | +</TabItem> |
| 119 | +</Tabs> |
| 120 | + |
| 121 | +### Step 3: Inject the video |
| 122 | + |
| 123 | +Refer to the code snippets given below to upload the video with the action `VideoInjection`. Please make sure that the video needs to be injected before the camera is triggered in your application. This is due to the fact that the camera only captures the video injected at the last. |
| 124 | + |
| 125 | +<Tabs className="docs__val"> |
| 126 | + |
| 127 | +<TabItem value="python" label="Python" default> |
| 128 | + <div className="lambdatest__codeblock"> |
| 129 | + <CodeBlock className="language-python"> |
| 130 | + {`driver.execute_script("lambda-video-injection=media_url") #Add media_url here`} |
| 131 | + </CodeBlock> |
| 132 | + </div> |
| 133 | +</TabItem> |
| 134 | + |
| 135 | + |
| 136 | +<TabItem value="JavaScript" label="JavaScript" default> |
| 137 | + <div className="lambdatest__codeblock"> |
| 138 | + <CodeBlock className="language-javascript"> |
| 139 | + {`driver.execute_script("lambda-video-injection=media_url") //Add media_url here`} |
| 140 | + </CodeBlock> |
| 141 | + </div> |
| 142 | +</TabItem> |
| 143 | +</Tabs> |
| 144 | + |
| 145 | +:::info |
| 146 | + |
| 147 | +**Use Case**: This feature can be used when you want to test injecting more than one video in single test at different instances. The video injected through above process will replace the video which you put in previous steps. |
| 148 | + |
| 149 | +::: |
| 150 | + |
| 151 | +### Step 4: Capture the desired video through camera |
| 152 | + |
| 153 | +You need to first add a logic to inject the uploaded video in the script. Thereafter add the logic to click the camera button in the mobile app. This will show you the last injected video on your mobile app screen. |
| 154 | + |
| 155 | +> 📕 Check the [documentation for Media Injection](/support/docs/camera-image-injection-on-real-devices/) feature in Manual App Testing on Real devices |
| 156 | +
|
| 157 | + |
| 158 | +<nav aria-label="breadcrumbs"> |
| 159 | + <ul className="breadcrumbs"> |
| 160 | + <li className="breadcrumbs__item"> |
| 161 | + <a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com"> |
| 162 | + Home |
| 163 | + </a> |
| 164 | + </li> |
| 165 | + <li className="breadcrumbs__item"> |
| 166 | + <a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com/support/docs/"> |
| 167 | + Support |
| 168 | + </a> |
| 169 | + </li> |
| 170 | + <li className="breadcrumbs__item breadcrumbs__item--active"> |
| 171 | + <span className="breadcrumbs__link"> |
| 172 | + Camera Image Injection |
| 173 | + </span> |
| 174 | + </li> |
| 175 | + </ul> |
| 176 | +</nav> |
0 commit comments