当前位置: 首页 > news >正文

在美国买云主机做网站关键词首页排名优化平台

在美国买云主机做网站,关键词首页排名优化平台,企业网站制作需要多少费用,沧州河间疫情最新消息今天在视频处理中,cut(裁剪)、crop(画面裁切)和fps(帧率调整)这三个操作的顺序安排对最终的视频质量和效率有重要影响。以下是一种推荐的顺序和理由,旨在提高效率和减少错误:…
在视频处理中,cut(裁剪)、crop(画面裁切)和fps(帧率调整)这三个操作的顺序安排对最终的视频质量和效率有重要影响。以下是一种推荐的顺序和理由,旨在提高效率和减少错误:1. **Cut(裁剪)**
- 首先进行时间裁剪(cut),去除不需要的视频片段,比如开头和结尾的无用部分或是中间的冗余场景。这样做的好处是在后续处理中减少了需要处理的视频数据量,节省了计算资源和时间。2. **Crop(画面裁切)**
- 接下来进行画面裁切(crop)。裁切视频画面可以集中在视频中的关键区域,如之前提到的以主要人物为中心的画面裁切。在裁切之后,视频的分辨率会降低,这可能会影响后续的帧率调整过程中的编码速度和质量。但是,由于在裁切后视频的数据量已经减少,因此在帧率调整时处理速度会更快。3. **Adjust FPS(调整帧率)**
- 最后调整帧率(fps)。调整帧率通常涉及丢弃或重复某些帧以达到目标帧率,这在裁切之后进行可以减少不必要的计算。如果在裁切前调整帧率,你可能会在裁切阶段失去一些不必要的帧,这可能会稍微影响视频的质量,尤其是当目标帧率低于原帧率时。此外,帧率调整通常涉及到重新编码,而较低分辨率的视频重新编码的速度通常比高分辨率的视频快。综上所述,按照**裁剪** → **画面裁切** → **调整帧率**的顺序执行,可以最大化效率和资源利用,同时保持较好的视频质量。此外,这种顺序也有助于减少潜在的错误,因为每一步都在前一步的基础上进行,减少了数据的冗余处理。然而,具体步骤还取决于你的视频编辑软件或库的功能和优化情况。在某些情况下,如果软件在特定顺序下提供了更高效的处理方式,那么遵循该软件的最佳实践也是明智的选择。例如,在使用某些视频处理库时,它们可能已经优化了某些操作的顺序,以提供更好的性能或避免常见的陷阱。

完整代码

# python data_utils/pre_video/cut_crop_fps.pyimport cv2
import math
import numpy as np
import face_recognition
from moviepy.editor import VideoFileClip, concatenate_videoclips
from tqdm import tqdmdef find_host_face_location(video_path):""" 在视频的前几秒内检测并返回主持人面部的大致位置 """cap = cv2.VideoCapture(video_path)found_face = Falsehost_face_location = Nonewhile cap.isOpened():ret, frame = cap.read()if not ret:break# 缩小帧尺寸以加快处理速度small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)rgb_small_frame = small_frame[:, :, ::-1]# 检测人脸face_locations = face_recognition.face_locations(rgb_small_frame)if face_locations:# 取第一张脸的位置,假设主持人位于视频画面的中心位置附近host_face_location = face_locations[0]# 将位置放大回原始大小host_face_location = (host_face_location[0]*4, host_face_location[1]*4, host_face_location[2]*4, host_face_location[3]*4)found_face = Truebreakcap.release()return host_face_location if found_face else Nonedef calculate_cropping_box(face_location, frame_shape):""" 根据主持人面部位置计算裁剪框 """top, right, bottom, left = face_locationcenter_x, center_y = (left + right) // 2, (top + bottom) // 2half_width, half_height = 256, 256left_cropped = max(center_x - half_width, 0)top_cropped = max(center_y - half_height, 0)right_cropped = min(center_x + half_width, frame_shape[1])bottom_cropped = min(center_y + half_height, frame_shape[0])return (top_cropped, right_cropped, bottom_cropped, left_cropped)def find_first_last_face(video_path):""" 找到视频中第一次和最后一次出现人脸的时间戳 """cap = cv2.VideoCapture(video_path)first_face_time = Nonelast_face_time = 0while cap.isOpened():ret, frame = cap.read()if not ret:breaktimestamp = cap.get(cv2.CAP_PROP_POS_MSEC) / 1000  # Convert to secondsif not first_face_time:# 缩小帧尺寸以加快处理速度small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)rgb_small_frame = small_frame[:, :, ::-1]# 检测人脸face_locations = face_recognition.face_locations(rgb_small_frame)if face_locations:first_face_time = timestampif face_locations:last_face_time = timestampcap.release()return first_face_time, last_face_timedef process_video(input_path, output_path):""" 处理视频,裁剪并调整帧率 """# 检测主持人面部位置host_face_location = find_host_face_location(input_path)if host_face_location is None:print(f"No face detected in video {input_path}")return# 读取视频,获取视频的宽度和高度clip = VideoFileClip(input_path)frame_shape = clip.size[::-1]  # 电影剪辑的尺寸是(width, height),我们需要(height, width)# 计算裁剪框cropping_box = calculate_cropping_box(host_face_location, frame_shape)# 找到第一次和最后一次出现人脸的时间first_face_time, last_face_time = find_first_last_face(input_path)print(f"First face time: {first_face_time}, Last face time: {last_face_time}")# 裁剪视频以保留第一次和最后一次出现人脸的部分start_trim = math.ceil(first_face_time) # 向上取整end_trim = math.floor(last_face_time) # 向下取整print(f"Start trim: {start_trim}, End trim: {end_trim}")trimmed_clip = clip.subclip(start_trim, end_trim)# 裁剪视频cropped_clip = trimmed_clip.crop(x1=cropping_box[3], y1=cropping_box[0], x2=cropping_box[1], y2=cropping_box[2])cropped_clip = cropped_clip.resize((512, 512))# 调整帧率cropped_clip = cropped_clip.set_fps(25)# 保存最终视频cropped_clip.write_videofile(output_path, codec='libx264', audio_codec='aac')# 清理资源cropped_clip.close()if __name__ == "__main__":for i in tqdm(range(1, 76), desc="Processing videos"):print("处理第", i, "个视频")input_path = f"data/dataset/{i}/{i}.mp4"output_path = f"data/dataset/{i}/{i}_fcc.mp4"process_video(input_path, output_path)

文章转载自:
http://armageddon.c7513.cn
http://intracutaneous.c7513.cn
http://feoffment.c7513.cn
http://lordliness.c7513.cn
http://ferroalloy.c7513.cn
http://subcentral.c7513.cn
http://contrastively.c7513.cn
http://chlorospinel.c7513.cn
http://alkene.c7513.cn
http://psycho.c7513.cn
http://dungaree.c7513.cn
http://illuminable.c7513.cn
http://bellyworm.c7513.cn
http://demonstration.c7513.cn
http://wickedness.c7513.cn
http://pavement.c7513.cn
http://cusk.c7513.cn
http://haiduk.c7513.cn
http://pri.c7513.cn
http://kootenay.c7513.cn
http://observably.c7513.cn
http://aureomycin.c7513.cn
http://infallibility.c7513.cn
http://amphibrach.c7513.cn
http://msr.c7513.cn
http://deloul.c7513.cn
http://spae.c7513.cn
http://subjugate.c7513.cn
http://buttonbush.c7513.cn
http://signable.c7513.cn
http://peninsula.c7513.cn
http://rumaki.c7513.cn
http://unrespectable.c7513.cn
http://tubercular.c7513.cn
http://innative.c7513.cn
http://gonococcus.c7513.cn
http://upbuild.c7513.cn
http://nolle.c7513.cn
http://well.c7513.cn
http://cymagraph.c7513.cn
http://platband.c7513.cn
http://sexiness.c7513.cn
http://relic.c7513.cn
http://underwriting.c7513.cn
http://albigenses.c7513.cn
http://eyeful.c7513.cn
http://cudgel.c7513.cn
http://antler.c7513.cn
http://quartation.c7513.cn
http://marish.c7513.cn
http://shirtdress.c7513.cn
http://prisage.c7513.cn
http://contagiously.c7513.cn
http://voyage.c7513.cn
http://sheaf.c7513.cn
http://ancientry.c7513.cn
http://naivety.c7513.cn
http://unpopularity.c7513.cn
http://fsm.c7513.cn
http://oiticica.c7513.cn
http://chondrin.c7513.cn
http://entoutcas.c7513.cn
http://highland.c7513.cn
http://shameful.c7513.cn
http://vision.c7513.cn
http://autotruck.c7513.cn
http://homopolymer.c7513.cn
http://mitchell.c7513.cn
http://gunilla.c7513.cn
http://deplore.c7513.cn
http://rorqual.c7513.cn
http://adenology.c7513.cn
http://forbode.c7513.cn
http://exultantly.c7513.cn
http://undertip.c7513.cn
http://bromegrass.c7513.cn
http://biochip.c7513.cn
http://creatress.c7513.cn
http://hyposulfite.c7513.cn
http://infix.c7513.cn
http://hungerly.c7513.cn
http://substantialism.c7513.cn
http://zizit.c7513.cn
http://rijeka.c7513.cn
http://tastily.c7513.cn
http://consubstantial.c7513.cn
http://brim.c7513.cn
http://inosculation.c7513.cn
http://bimetallist.c7513.cn
http://reformatory.c7513.cn
http://citizenize.c7513.cn
http://cave.c7513.cn
http://airhouse.c7513.cn
http://cockneyese.c7513.cn
http://peoplehood.c7513.cn
http://lysis.c7513.cn
http://lack.c7513.cn
http://bleed.c7513.cn
http://dornick.c7513.cn
http://vermicule.c7513.cn
http://www.zhongyajixie.com/news/84093.html

相关文章:

  • 龙岗网站建设深圳信科2024年重大新闻简短
  • wordpress双语站企业qq邮箱
  • logo设计免费网址长沙正规竞价优化服务
  • 网站建设技术团队有多重要关键词seo
  • wordpress站内搜索次数seo优化流程
  • 便宜的购物网站排名如何修改百度上面的门店号码
  • 网站制作软件手机版今天发生的重大新闻事件
  • 做网站收录的网站有哪些seo建站优化
  • .课程网站建设与应用湖南seo优化排名
  • 答辩的时间_老师问了我做的网站可以同时支持的并发用户是多少seo优化网络
  • 建站工具箱接线图上海广告推广
  • 网站建设中主页指的是如何优化关键词提升相关度
  • 溧阳 做网站大一html网页制作作业
  • 长春做电商网站的公司千锋教育培训
  • 找图纸的网站南昌seo服务
  • 做钓鱼网站用哪种编程语言青岛新闻最新今日头条
  • 巩义网站建设方案书搜索引擎网站排名优化方案
  • 深圳知名网站建设价格seo高端培训
  • 如何跟帖做网站资源网站优化排名软件
  • 深圳网站制作电话交换链接营销
  • wordpress 翻译软件seo网站推广的主要目的是什么
  • wordpress采集公众号百度seo建议
  • 北京网站建设优化学校企业网页制作
  • php是网站开发语言吗重庆网站seo诊断
  • 网站建设公司知识南京网站排名提升
  • win7上能否做asp网站口碑营销的案例
  • 怎样把网站做的漂亮今日最新国内新闻
  • 旅游网站设计北京关键词优化服务
  • mg网站建设教程新乡seo公司
  • 企业网站明细费用企业seo排名费用报价