Maya动画如何拍四个屏幕
好酷屋教程网小编为您收集和整理了Maya动画如何拍四个屏幕的相关教程:因为自己用FFmpeg合成视频的时候,费了很大劲,查了大量资料才弄好,希望别人在遇到类似的情况不用绞尽脑汁。思路是:先拍四个视图的屏,然后将这四个视屏合起来并带有声音。里面包含有FFmpeg的
因为自己用FFmpeg合成视频的时候,费了很大劲,查了大量资料才弄好,希望别人在遇到类似的情况不用绞尽脑汁。
思路是:先拍四个视图的屏,然后将这四个视屏合起来并带有声音。 里面包含有FFmpeg的路径可以自己下载最新版的设置下路径就行了。 详细代码如下:import osimport subprocessimport maya.cmds as cmdsdef split_list_by_chuck(userList, chuck): for i in xrange(0, len(userList), chuck): yield userListdef get_timeSlinder_current_sound(): import maya.mel gplayBackSlider = maya.mel.eval($tmpVar=$gplayBackSlider) sound = cmds.timeControl(gplayBackSlider, q=1, s=1, ds=1) if sound: return sound return Nonedef compostion_multiple_videos(videos, output_video, start_number, duration, rate, sound=None, column=2): ffmpeg_path = //storage1.of3d.com/centralizedTools/third_party/exe/ffmpeg/win/3.3.1/bin/ffmpeg.exe temp_videos = [] videos_num = len(videos) if column > videos_num: print >>> The amount of videos must be larger than column return False for index, video in enumerate(split_list_by_chuck(videos, column)): input_videos = [] num = len(video) for i in xrange(num): input_videos.append(-i %s % video) composition_video_temp = os.path.join(os.path.dirname(output_video), temp_%s.mov % index).replace(\\, /) if os.path.exists(composition_video_temp): os.remove(composition_video_temp) all_input = .join(input_videos) command_temp = {ffmpeg} {input_videos} -filter_complex ”pad=iw*{column}:ih; overlay=w” {output_video_temp}.format( ffmpeg=ffmpeg_path, input_videos=all_input, column=column, output_video_temp=composition_video_temp) print >>> Command: %s % command_temp state = subprocess.call(command_temp, shell=True) temp_videos.append(composition_video_temp) if temp_videos: input_videos = [] num = len(temp_videos) for i in xrange(num): input_videos.append(-i %s % temp_videos) final_video_temp = os.path.join(os.path.dirname(output_video), %s_temp.mov % os.path.basename(output_video).split(.)).replace(\\, /) all_input = .join(input_videos) command = {ffmpeg} {input_videos_temp} -preset ultrafast -filter_complex vstack {output_video}.format( ffmpeg=ffmpeg_path, input_videos_temp=all_input, output_video=final_video_temp) print >>> Command: %s % command if os.path.exists(final_video_temp): os.remove(final_video_temp) state = subprocess.call(command, shell=True) if sound: command = {ffmpeg} -t {duration} -i {final_video_temp} -i {audio} -shortest {output_video}.format( ffmpeg=ffmpeg_path, duration=str(duration), final_video_temp=final_video_temp, audio=sound, output_video=output_video) print >>> Command: %s % command if os.path.exists(output_video): os.remove(output_video) state = subprocess.call(command, shell=True) temp_videos.append(final_video_temp) all_temp_video = set(temp_videos).union(set(videos)) for video in all_temp_video: if os.path.exists(video): os.remove(video) if state == 0: return True else: return Falsedef get_rate(): rate_data = {game: 15, film: 24, pal: 25, ntsc: 30, show: 48, palf: 50, ntscf: 60, 100fps: 100} current_rate = cmds.currentUnit(q=1, t=1) rate = rate_data.get(current_rate, 24) return ratedef playblast_from_multiple_views(videopath, widthHeight, frameRange, videoFormat=Qt, compression=H.264, sound=None): viewpanels = cmds.getpanel(typ=modelpanel) visiblepanels = cmds.getpanel(vis=1) renderpanels = list(set(viewpanels) & set(visiblepanels)) video_paths = [] camera_names = [] sound_file = None frange_range = frameRange - frameRange + 1 scene_rate = get_rate() duration = %.03f % (frange_range * 1.0 / scene_rate) if sound: sound_file = sound else: audio = get_timeSlinder_current_sound() if audio: audio_file = cmds.getAttr(%s.filename % audio) if audio_file.startswith($): env_variable = os.environ.get(audio_file.split(/, 1).strip($)) sound_file = os.path.join(env_variable, audio_file.split(/, 1)).replace(\\, /) else: sound_file = audio_file print >>>, sound_file for panel in renderpanels: cmds.setFocus(panel) camera_name = cmds.modelEditor(panel, q=1, cam=1) if camera_name in camera_names: continue single_view_video_path = os.path.join(os.path.dirname(videopath), %s.mov % camera_name) # hardcode print >>> camera: %s; videopath: %s % (camera_name, single_view_video_path) cmds.modelEditor(panel, e=1, hud=1, da=smoothShaded, dtx=1, dl=default, alo=0, pm=1, ns=1) cmds.playblast(startTime=frameRange, endTime=frameRange, fmt=videoFormat, filename=single_view_video_path, forceOverwrite=1, sequenceTime=0, clearCache=1, viewer=0, showOrnaments=1, offScreen=1, fp=4, percent=100, compression=compression, quality=100, widthHeight=(1280, 720)) print >>> playblast camera: %s % camera_name camera_names.append(camera_name) video_paths.append(single_view_video_path) state = compostion_multiple_videos(video_paths, videopath, frameRange, duration, scene_rate, sound_file) if state: print >>> Finish playblasting multiple views else: print >>> Something wrong, please check carefully if __name__ == __main__: video_path = F:/Multiple_View/all.mov playblast_from_multiple_views(video_path, (1280, 720), , sound=None)稍微解释下:command_temp = {ffmpeg} {input_videos} -filter_complex ”pad=iw*{column}:ih; overlay=w” {output_video_temp}.format( ffmpeg=ffmpeg_path, input_videos=all_input, column=column, output_video_temp=composition_video_temp)12这句的意思是将多个视频横向合起来,其中column代表几列,如2,就表示两个视频并列,在视频个数已知的情况,那么行数也就可知了。command = {ffmpeg} {input_videos_temp} -preset ultrafast -filter_complex vstack {output_video}.format( ffmpeg=ffmpeg_path, input_videos_temp=all_input, output_video=final_video_temp)12这句是将视频纵向合起来,有几个合几个。command = {ffmpeg} -t {duration} -i {final_video_temp} -i {audio} -shortest {output_video}.format( ffmpeg=ffmpeg_path, duration=str(duration), final_video_temp=final_video_temp, audio=sound, output_video=output_video)12这个是最后将音频合最终的总的视频合起来的命令,主要是那个shortest这个参数表示,如果在合得时候,音频比视频长的情况就按视频长度为最终的长度时间。
以上就是好酷屋教程网小编为您收集和整理的Maya动画如何拍四个屏幕相关内容,如果对您有帮助,请帮忙分享这篇文章^_^
本文来源: https://www.haoku5.com/IT/641aa20c31e734dc130dd54f.html
相关推荐
热门专题
PS快捷键_PS快捷键大全
经典的Photoshop快捷键大全,如果你是入门阶段的水平,熟读此文并掌握,马上进阶为中级水平。matlab怎么换行?matlab换行教程
今天小编为大家带来的是matlab换行的教程,想知道怎么换行的小伙伴来看看接下来的这篇文章吧,相信一定会帮到你们的。matlab怎么换行?matlab换行教程1、首先在matlab主页面板中点击【Matlab求矩阵的乘积的操作方法
很多用户在使用Matlab的时候,不是很熟悉其中怎么求矩阵的乘积的?本期为你们带来的教程就描述了Matlab求矩阵的乘积的操作方法。Matlab求矩阵的乘积的操作方法打Matlab,在命令行窗口分区工具diskgenius强制删除文件的具体使用流程
很多人不知道分区工具diskgenius如何强制删除文件?今日为你们带来的文章是关于分区工具diskgenius强制删除文件的具体含义讲解,还有不清楚小伙伴和小编一起去学习一下吧。分区工具diskggoldwave怎么启用延迟录制计时器?goldwave启用延迟录制计时器教程
很多小伙伴在使用goldwave的时候,想知道怎么启用延迟录制计时器,下面小编就为大家分享教程,感兴趣的小伙伴不要错过哦!goldwave怎么启用延迟录制计时器?goldwave启用延迟录制计时器教pycharm使用技巧
今天小编给大家讲解pycharm使用技巧,有需要或者有兴趣的朋友们可以看一看下文,相信对大家会有所帮助的。pycharm使用技巧使用PyCharm软件需要python运行环境,这里我已经下载好。CAD看图软件哪个好用?如何使用CAD看图软件
在CAD中,大家都知道CAD图纸是使用CAD制图软件来绘制完成的,那保存的格式就是为dwg格式和dxf格式的。那需要对图纸内容进行查看的时候,就要适用到CAD看图软件。但看图软件有很多,那么CAD看图diskgenius怎么将分区中的文件复制到指定目录?diskgenius将分区中的文件复制到指定目录方法
使用diskgenius的时候,很多小伙伴不知道怎么将分区中的文件复制到指定目录,下面小编就给大家带来方法,有需要的小伙伴不要错过哦。diskgenius怎么将分区中的文件复制到指定目录?diskg分区工具diskgenius将硬盘合并分区的详细流程
说起分区工具diskgenius伙伴们都不陌生,那么使用怎么使用分区工具将硬盘合并分区呢?下面一起看看关于分区工具diskgenius将硬盘合并分区的详细流程吧。分区工具diskgenius将硬盘合WPS HarmonyOS版上线服务中心 PPT新特性一览
7月22日,WPS鸿蒙HarmonyOS版已经上线服务中心,鸿蒙版支持流转,目前只能查看不能编辑,WPSOfficeforHarmonyOS的PPT显示了WPS鸿蒙版的新特性,一起