首页 文章 精选 留言 我的

精选列表

搜索[video],共2279篇文章
优秀的个人博客,低调大师

iOS Video(视频)

1. 带View的播放器 - (IBAction)moviePlayerViewController:(id)sender { // 带View的播放器的控制器 //1. 获取URL地址 NSURL *url = [[NSBundle mainBundle] URLForResource:@"Cupid_高清.mp4" withExtension:nil]; //2. 创建带View的播放器 MPMoviePlayerViewController *mpVC = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; //3. 模态视图弹出 --> 模态视图的切换应该在View完全展示之后进行 [self presentViewController:mpVC animated:YES completion:nil]; } 2. 不带View的播放器 #import "ViewController.h" #import <MediaPlayer/MediaPlayer.h> #import <AVKit/AVKit.h> @interface ViewController () @property (nonatomic, strong) MPMoviePlayerController *mpC; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //检测视频播放完毕 --> 可以连续播放视频 //注册通知监测视频播放完毕 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackDidFinishNotification:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; } #pragma mark 通知绑定的方法 - (void)moviePlayerPlaybackDidFinishNotification:(NSNotification *)notification { /** MPMovieFinishReasonPlaybackEnded, 播放结束 MPMovieFinishReasonPlaybackError, 播放错误 MPMovieFinishReasonUserExited 退出播放 */ //1. 获取通知结束的状态 NSInteger movieFinishKey = [notification.userInfo[MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue]; //2. 根据状态不同来自行填写逻辑代码 switch (movieFinishKey) { case MPMovieFinishReasonPlaybackEnded: NSLog(@"播放结束"); // 进行视频切换 需要两步 //1. 要想换视频, 就需要更换地址 self.mpC.contentURL = [[NSBundle mainBundle] URLForResource:@"Alizee_La_Isla_Bonita.mp4" withExtension:nil]; // [self.mpC play]; break; case MPMovieFinishReasonPlaybackError: NSLog(@"播放错误"); break; case MPMovieFinishReasonUserExited: NSLog(@"退出播放"); // 如果是不带view的播放器, 那么播放完毕(退出/错误/结束)都应该退出 [self.mpC.view removeFromSuperview]; break; default: break; } } - (void)dealloc { //移除通知 [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (IBAction)moviePlayerController { // 不带View的播放器的控制器 --> 需要强引用, 设置frame, 添加到view上, 开始播放 //1. 获取URL地址 NSURL *url = [[NSBundle mainBundle] URLForResource:@"Cupid_高清.mp4" withExtension:nil]; //2. 创建不带View的播放器 self.mpC = [[MPMoviePlayerController alloc] initWithContentURL:url]; //3. 设置view.frame self.mpC.view.frame = CGRectMake(0, 0, 300, 400); //4. 添加到view上 [self.view addSubview:self.mpC.view]; //5. 准备播放 --> 规范写法, 要写上. 调用play方法时, 会自动调用此方法 [self.mpC prepareToPlay]; //6. 开始播放 [self.mpC play]; //7. 控制模式 self.mpC.controlStyle = MPMovieControlStyleFullscreen; /** MPMovieControlStyleNone, // No controls MPMovieControlStyleEmbedded, // 嵌入式的控制 -- 默认 MPMovieControlStyleFullscreen, // 全屏时的控制样式 */ } @end 3. iOS9 播放视频 #import "ViewController.h" #import <AVKit/AVKit.h> #import <AVFoundation/AVFoundation.h> @implementation ViewController - (IBAction)playerViewController { //1. 获取URL地址 NSURL *url = [[NSBundle mainBundle] URLForResource:@"Cupid_高清.mp4" withExtension:nil]; //2. AV播放视图控制器 AVPlayerViewController *pVC = [AVPlayerViewController new]; //3. 创建player --> 设置时需要传入网址 pVC.player = [AVPlayer playerWithURL:url]; //4. 开始播放 [pVC.player play]; //5. 模态弹出 //[self presentViewController:pVC animated:YES completion:nil]; //5. 如果想要自定义播放器的大小,应该自定义 --> 设置frame / 添加到视图中 pVC.view.frame = CGRectMake(40, 200, 300, 400); [self.view addSubview:pVC.view]; } @end 4. 视频截图 #import "ViewController.h" #import <AVFoundation/AVFoundation.h> @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation ViewController #pragma mark 点击屏幕, 开始截图 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { //1. URL NSURL *url = [[NSBundle mainBundle] URLForResource:@"Cupid_高清.mp4" withExtension:nil]; //2. 获取资源 AVAsset *asset = [AVAsset assetWithURL:url]; //3. 创建 资源图像生成器 AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; //4. 开始生成图像 //Times : 用来表示影片的时间的值 //value: 帧数 //timescale: 当前视频的每秒的帧数 CMTime time = CMTimeMake(60, 1); NSValue *value = [NSValue valueWithCMTime:time]; [imageGenerator generateCGImagesAsynchronouslyForTimes:@[value] completionHandler:^(CMTime requestedTime, CGImageRef _Nullable image, CMTime actualTime, AVAssetImageGeneratorResult result, NSError * _Nullable error) { //5. 主线程中更新UI dispatch_sync(dispatch_get_main_queue(), ^{ self.imageView.image = [UIImage imageWithCGImage:image]; }); }]; } @end 6. 视频录制 #import "ViewController.h" #import <MobileCoreServices/MobileCoreServices.h> #import <MediaPlayer/MediaPlayer.h> #import <AssetsLibrary/AssetsLibrary.h> @interface ViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate> @property (nonatomic, strong) MPMoviePlayerController *mpC; @end @implementation ViewController - (IBAction)movieClick:(id)sender { //1. 判断是否可用 if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { return; } //2. 创建图像选择器 UIImagePickerController *picker = [UIImagePickerController new]; //3. 设置类型 picker.sourceType = UIImagePickerControllerSourceTypeCamera; //4. 设置媒体类型 picker.mediaTypes = @[(NSString *)kUTTypeMovie]; //5. 设置相机检测模式 picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo; //6. 设置视频的质量 picker.videoQuality = UIImagePickerControllerQualityTypeHigh; //7. 设置代理 picker.delegate = self; //8. 模态弹出 [self presentViewController:picker animated:YES completion:nil]; } //UIImagePickerController 代理方法 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info { NSLog(@"info: %@",info); //1. 获取媒体类型 NSString *mediaTyep = info[UIImagePickerControllerMediaType]; //2. 判断是否是视频的媒体类型 id url = info[UIImagePickerControllerMediaURL]; if ([mediaTyep isEqualToString:(NSString *)kUTTypeMovie]) { if (self.mpC == nil) { self.mpC = [MPMoviePlayerController new]; self.mpC.view.frame = self.view.bounds; [self.view addSubview:self.mpC.view]; } self.mpC.contentURL = url; [self.mpC play]; } //3. 保存视频 if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { //3.1 创建ALAssetsLibrary对象 ALAssetsLibrary *assetsLibrary = [ALAssetsLibrary new]; //3.2 调用writeVideoAtPathToSavedPhotosAlbum即可 //前面的URL, 需要传入要保存的视频的URL. [assetsLibrary writeVideoAtPathToSavedPhotosAlbum:url completionBlock:nil]; } [picker dismissViewControllerAnimated:YES completion:nil]; } @end 7. 视频压缩 #import "ViewController.h" #import <MobileCoreServices/MobileCoreServices.h> #import <AVFoundation/AVFoundation.h> @interface ViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate> @end @implementation ViewController - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { //1. 判断是否可用 if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) { return; } //2. 创建图像选择器 UIImagePickerController *picker = [UIImagePickerController new]; //3. 设置类型 picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; //4. 设置媒体类型 picker.mediaTypes = @[(NSString *)kUTTypeMovie]; //5. 设置代理 picker.delegate = self; //6. 模态弹出 [self presentViewController:picker animated:YES completion:nil]; } #pragma mark 选中视频的时候, 进行压缩处理 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info { //1. 获取媒体类型 NSString *mediaTyep = info[UIImagePickerControllerMediaType]; //2. 获取视频的地址 id url = info[UIImagePickerControllerMediaURL]; //3. 开始导出--> 压缩 [self exportWithURL:url]; } - (void)exportWithURL:(NSURL *)url { //1. 获取资源 AVAsset *asset = [AVAsset assetWithURL:url]; //2. 根据资源, 创建资源导出会话对象 //presetName : 压缩的大小 AVAssetExportSession *session = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality]; //3. 设置导出路径 session.outputURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"12345.mov"]]; //4. 设置导出类型 session.outputFileType = AVFileTypeQuickTimeMovie; //5. 开始导出 [session exportAsynchronouslyWithCompletionHandler:^{ NSLog(@"当你看到这句话的时候, 恭喜你已经导出成功"); }]; } @end

优秀的个人博客,低调大师

微软发布由 Sora 驱动的 Bing Video Creator

微软 Bing宣布将在应用中引入全新的视频生成功能,该功能由 OpenAI 的 Sora 模型让用户根据文字提示生成视频。 所有用户只要登录微软账户,就可以使用必应应用程序免费创建 10 个视频片段,而这之后的视频,用户需要为每个视频支付 100 微软奖励积分才能生成。这些积分可通过使用必应搜索或在微软商店购物获得,例如,使用必应在个人电脑上每搜索一次可获得 5 点积分,每天的积分上限为 150 点。 OpenAI 与微软有着长期的合作关系,但只有付费用户才能使用 Sora 的视频生成功能。它与微软必应的整合标志着它将首次免费提供。

优秀的个人博客,低调大师

Android 使WebView支持HTML5 Video(全屏)播放的方法

http://blog.csdn.net/zrzlj/article/details/8050633 1)需要在AndroidManifest.xml文件中声明需要使用HardwareAccelerate, 可以细化到Activity级别,如果不需要的View可以声明不要用加速,但是需要在代码中做,具体如下: a. 如果要声明整个应用都要加速: <application ...android:hardwareAccelerated= "true"> b. 如果要在Activity中声明,则: <activity ...android:hardwareAccelerated= "true">, 还可以更细化到Window, getWindow.setFlags( WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); c. 如果application或者activity都申明了要硬件加速,但是为了某些原因(比如省电?),一些View不需要硬件加速的话, view.setLayerType(View.LAYER_TYPE_SOFTWARE,null); 2)可以说挺奇怪的是,需要在AndroidManifest.xml文件中用上<use-sdk></use-sdk>标签,而且如果是空的还不行,必须写上targetSDK或者minSDK,但是我试验过,不管写版本是多少都没有关系。。。理论上说,Android应该是从3.0( API Level 11)开始可以对2D渲染加速,但是我把targetSDK设置为5都可以使用的,但是这个标签不写还不行。 分类: android solve 本文转自wanqi博客园博客,原文链接:http://www.cnblogs.com/wanqieddy/p/4845640.html,如需转载请自行联系原作者

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册