os.system 开启windows App命令camera,video等

CMD启动windows系统应用程序
通过powershell来获取AUMID,需要用get-appxpackage,如获取相机的AUMID get-appxpackage Microsoft.ZuneVideo

Name : Microsoft.ZuneVideo
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 10.20022.11011.0
PackageFullName : Microsoft.ZuneVideo_10.20022.11011.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.ZuneVideo_10.20022.11011.0_x64__8wekyb3d8bbwe
IsFramework : False
PackageFamilyName : Microsoft.ZuneVideo_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
Dependencies:{Microsoft.VCLibs.140.00_14.0.27810.0_x64__8wekyb3d8bbwe, Microsoft.ZuneVideo_10.20022.11011.0_neut
ral_split.language-zh-hans_8wekyb3d8bbwe, Microsoft.ZuneVideo_10.20022.11011.0_neutral_split.scale-
125_8wekyb3d8bbwe}
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok

在powershell窗口中输入:Get-StartApps就可以获得App的AUMID(应用程序用户模型)

有些APP会很长有"..."

Get-StartApps -ft autosize

在CMD窗口键入:

Camera

方法二:
比如我需要打开edge浏览器,只需要在cmd中输入
start microsoft-edge: “网址:

参考网址:Windows 10 移动版中的产品 ID (Windows) | Microsoft Learn

闹钟和时钟44F7D2B4-553D-4BEC-A8B7-634CE897ED5FMicrosoft.WindowsAlarms_8wekyb3d8bbwe!App
计算器B58171C6-C70C-4266-A2E8-8F9C994F4456Microsoft.WindowsCalculator_8wekyb3d8bbwe!App
相机F0D8FEFD-31CD-43A1-A45A-D0276DB069F1Microsoft.WindowsCamera_8wekyb3d8bbwe!App
联系支持人员0DB5FCFF-4544-458A-B320-E352DFD9CA2BWindows.ContactSupport_cw5n1h2txyewy!App
CortanaFD68DCF4-166F-4C55-A4CA-348020F71B94Microsoft.Windows.Cortana_cw5n1h2txyewy!CortanaUI
ExcelEAD3E7C0-FAE6-4603-8699-6A448138F4DCMicrosoft.Office.Excel_8wekyb3d8bbwe!microsoft.excel
Facebook82A23635-5BD9-DF11-A844-00237DE2DB9EMicrosoft.MSFacebook_8wekyb3d8bbwe!x82a236355bd9df11a84400237de2db9e
文件资源管理器C5E2524A-EA46-4F67-841F-6A9465D9D515c5e2524a-ea46-4f67-841f-6a9465d9d515_cw5n1h2txyewy!App
调频广播F725010E-455D-4C09-AC48-BCDEF0D4B626不适用
入门B3726308-3D74-4A14-A84C-867C8C735C3CMicrosoft.Getstarted_8wekyb3d8bbwe!App
Groove 音乐D2B6A184-DA39-4C9A-9E0A-8B589B03DEC0Microsoft.ZuneMusic_8wekyb3d8bbwe!Microsoft.ZuneMusic
地图ED27A07E-AF57-416B-BC0C-2596B622EF7DMicrosoft.WindowsMaps_8wekyb3d8bbwe!App
消息27E26F40-E031-48A6-B130-D1F20388991AMicrosoft.Messaging_8wekyb3d8bbwe!x27e26f40ye031y48a6yb130yd1f20388991ax
Microsoft Edge395589FB-5884-4709-B9DF-F7D558663FFDMicrosoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge
财经1E0440F1-7ABF-4B9A-863D-177970EEFB5EMicrosoft.BingFinance_8wekyb3d8bbwe!AppexFinance
电影和电视6AFFE59E-0467-4701-851F-7AC026E21665Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo
新闻9C3E8CAD-6702-4842-8F61-B8B33CC9CAF1Microsoft.BingNews_8wekyb3d8bbwe!AppexNews
OneDriveAD543082-80EC-45BB-AA02-FFE7F4182BA8Microsoft.MicrosoftSkydrive_8wekyb3d8bbwe!App
OneNoteCA05B3AB-F157-450C-8C49-A1F127F5E71DMicrosoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
Outlook 日历

A558FEBA-85D7-4665-B5D8-A2FF9C19799B

Microsoft.WindowsCommunicationsApps_8wekyb3d8bbwe!Microsoft.WindowsLive.Calendar

Outlook 邮件

A558FEBA-85D7-4665-B5D8-A2FF9C19799B

Microsoft.WindowsCommunicationsApps_8wekyb3d8bbwe!Microsoft.WindowsLive.Mail

人脉60BE1FB8-3291-4B21-BD39-2221AB166481Microsoft.People_8wekyb3d8bbwe!xb94d6231y84ddy49a8yace3ybc955e769e85x
电话(拨号程序)F41B5D0E-EE94-4F47-9CFE-3D3934C5A2C7Microsoft.CommsPhone_8wekyb3d8bbwe!App
照片FCA55E1B-B9A4-4289-882F-084EF4145005Microsoft.Windows.Photos_8wekyb3d8bbwe!App
播客C3215724-B279-4206-8C3E-61D1A9D63ED3Microsoft.MSPodcast_8wekyb3d8bbwe!xc3215724yb279y4206y8c3ey61d1a9d63ed3x
PowerpointB50483C4-8046-4E1B-81BA-590B24935798Microsoft.Office.PowerPoint_8wekyb3d8bbwe!microsoft.pptim
设置2A4E62D8-8809-4787-89F8-69D0F01654FB2a4e62d8-8809-4787-89f8-69d0f01654fb_8wekyb3d8bbwe!App
SkypeC3F8E570-68B3-4D6A-BDBB-C0A3F4360A51Microsoft.SkypeApp_kzf8qxf38zg5c!Skype.AppId
Skype 视频27E26F40-E031-48A6-B130-D1F20388991AMicrosoft.Messaging_8wekyb3d8bbwe!App
体育0F4C8C7E-7114-4E1E-A84C-50664DB13B17Microsoft.BingSports_8wekyb3d8bbwe!AppexSports
存储5B04B775-356B-4AA0-AAF8-6491FFEA564D不适用
应用商店7D47D89A-7900-47C5-93F2-46EB6D94C159Microsoft.WindowsStore_8wekyb3d8bbwe!App
语音录音机7311B9C5-A4E9-4C74-BC3C-55B06BA95AD0Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App
电子钱包587A4577-7868-4745-A29E-F996203F1462Microsoft.MicrosoftWallet_8wekyb3d8bbwe!App
天气63C2A117-8604-44E7-8CEF-DF10BE3A57C8Microsoft.BingWeather_8wekyb3d8bbwe!App
Windows 反馈7604089D-D13F-4A2D-9998-33FC02B63CE3Microsoft.WindowsFeedback_8wekyb3d8bbwe!App
Word258F115C-48F4-4ADB-9A68-1387E634459BMicrosoft.Office.Word_8wekyb3d8bbwe!microsoft.word
XboxB806836F-EEBE-41C9-8669-19E243B81B83Microsoft.XboxApp_8wekyb3d8bbwe!Microsoft.XboxApp
以下是用Java在Android应用程序中将H264视频流保存到本地的示例代码: 首先,你需要创建一个类来处理视频编码和保存: ``` import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.media.MediaMuxer; import android.os.Environment; import java.io.IOException; import java.nio.ByteBuffer; public class VideoEncoder { private static final String MIME_TYPE = "video/avc"; // H.264 Advanced Video Coding private static final int FRAME_RATE = 30; // 帧率 private static final int I_FRAME_INTERVAL = 1; // I帧间隔(单位秒) private static final int BIT_RATE = 125000; // 比特率(单位bps) private MediaCodec mediaCodec; private MediaMuxer mediaMuxer; private int trackIndex; private boolean isMuxerStarted; public VideoEncoder() throws IOException { MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, 640, 480); format.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE); format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Flexible); mediaCodec = MediaCodec.createEncoderByType(MIME_TYPE); mediaCodec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); mediaCodec.start(); mediaMuxer = new MediaMuxer(Environment.getExternalStorageDirectory() + "/output.mp4", MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4); } public void encode(byte[] data) { long presentationTimeUs = System.nanoTime() / 1000; ByteBuffer[] inputBuffers = mediaCodec.getInputBuffers(); int inputBufferIndex = mediaCodec.dequeueInputBuffer(-1); if (inputBufferIndex >= 0) { ByteBuffer inputBuffer = inputBuffers[inputBufferIndex]; inputBuffer.clear(); inputBuffer.put(data); mediaCodec.queueInputBuffer(inputBufferIndex, 0, data.length, presentationTimeUs, 0); } MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo(); int outputBufferIndex = mediaCodec.dequeueOutputBuffer(bufferInfo, 0); while (outputBufferIndex >= 0) { ByteBuffer outputBuffer = mediaCodec.getOutputBuffers()[outputBufferIndex]; if (!isMuxerStarted) { MediaFormat outputFormat = mediaCodec.getOutputFormat(); trackIndex = mediaMuxer.addTrack(outputFormat); mediaMuxer.start(); isMuxerStarted = true; } mediaMuxer.writeSampleData(trackIndex, outputBuffer, bufferInfo); mediaCodec.releaseOutputBuffer(outputBufferIndex, false); outputBufferIndex = mediaCodec.dequeueOutputBuffer(bufferInfo, 0); } } public void release() { mediaCodec.stop(); mediaCodec.release(); mediaMuxer.stop(); mediaMuxer.release(); } } ``` 这个类使用MediaCodec API对视频进行编码,并使用MediaMuxer API将编码后的视频写入文件。 在你的Activity中,你可以使用Camera API或其他方法来捕获视频帧,并将它们传递给VideoEncoder对象进行编码和保存。以下是使用Camera API捕获视频帧并将它们传递给VideoEncoder对象的示例代码: ``` import android.Manifest; import android.app.Activity; import android.content.pm.PackageManager; import android.hardware.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import java.io.IOException; public class MainActivity extends Activity implements SurfaceHolder.Callback, Camera.PreviewCallback { private static final int CAMERA_PERMISSION_REQUEST_CODE = 100; private static final String TAG = "MainActivity"; private Camera camera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private VideoEncoder videoEncoder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); surfaceView = findViewById(R.id.surfaceView); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); } @Override public void surfaceCreated(SurfaceHolder holder) { openCamera(); try { videoEncoder = new VideoEncoder(); } catch (IOException e) { Log.e(TAG, "Failed to create VideoEncoder", e); } } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } @Override public void surfaceDestroyed(SurfaceHolder holder) { releaseCamera(); videoEncoder.release(); } private void openCamera() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_REQUEST_CODE); } else { camera = Camera.open(); try { camera.setPreviewDisplay(surfaceHolder); camera.setPreviewCallback(this); Camera.Parameters parameters = camera.getParameters(); Camera.Size size = parameters.getPreviewSize(); int bufferSize = size.width * size.height * 3 / 2; camera.addCallbackBuffer(new byte[bufferSize]); camera.startPreview(); } catch (IOException e) { Log.e(TAG, "Failed to start preview", e); } } } private void releaseCamera() { if (camera != null) { camera.stopPreview(); camera.setPreviewCallback(null); camera.release(); camera = null; } } @Override public void onPreviewFrame(byte[] data, Camera camera) { if (videoEncoder != null) { videoEncoder.encode(data); } camera.addCallbackBuffer(data); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == CAMERA_PERMISSION_REQUEST_CODE) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { openCamera(); } } } } ``` 在这个示例中,MainActivity类使用SurfaceView来显示摄像头预览,并使用Camera API来捕获视频帧。当收到预览帧时,它将它们传递给VideoEncoder对象进行编码和保存。 请注意,这只是一个基本示例,你需要根据你的需求进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值