當前位置: 首頁>>代碼示例>>Python>>正文


Python VideoFileClip.write_videofile方法代碼示例

本文整理匯總了Python中moviepy.video.io.VideoFileClip.VideoFileClip.write_videofile方法的典型用法代碼示例。如果您正苦於以下問題:Python VideoFileClip.write_videofile方法的具體用法?Python VideoFileClip.write_videofile怎麽用?Python VideoFileClip.write_videofile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moviepy.video.io.VideoFileClip.VideoFileClip的用法示例。


在下文中一共展示了VideoFileClip.write_videofile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_toimageclip

# 需要導入模塊: from moviepy.video.io.VideoFileClip import VideoFileClip [as 別名]
# 或者: from moviepy.video.io.VideoFileClip.VideoFileClip import write_videofile [as 別名]
def test_toimageclip():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.6)
    clip = clip.to_ImageClip(t=0.1, duration=0.4)
    location = os.path.join(TMP_DIR, "toimageclip.mp4")
    clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
開發者ID:Zulko,項目名稱:moviepy,代碼行數:9,代碼來源:test_VideoClip.py

示例2: test_setopacity

# 需要導入模塊: from moviepy.video.io.VideoFileClip import VideoFileClip [as 別名]
# 或者: from moviepy.video.io.VideoFileClip.VideoFileClip import write_videofile [as 別名]
def test_setopacity():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.6)
    clip = clip.set_opacity(0.5)
    clip = clip.on_color(size=(1000, 1000), color=(0, 0, 255), col_opacity=0.8)
    location = os.path.join(TMP_DIR, "setopacity.mp4")
    clip.write_videofile(location)
    assert os.path.isfile(location)
    close_all_clips(locals())
開發者ID:Zulko,項目名稱:moviepy,代碼行數:10,代碼來源:test_VideoClip.py

示例3: test_check_codec

# 需要導入模塊: from moviepy.video.io.VideoFileClip import VideoFileClip [as 別名]
# 或者: from moviepy.video.io.VideoFileClip.VideoFileClip import write_videofile [as 別名]
def test_check_codec():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
    location = os.path.join(TMP_DIR, "not_a_video.mas")
    try:
        clip.write_videofile(location)
    except ValueError as e:
        assert "MoviePy couldn't find the codec associated with the filename." \
               " Provide the 'codec' parameter in write_videofile." in str(e)
    close_all_clips(locals())
開發者ID:Zulko,項目名稱:moviepy,代碼行數:11,代碼來源:test_VideoClip.py

示例4: download_and_convert

# 需要導入模塊: from moviepy.video.io.VideoFileClip import VideoFileClip [as 別名]
# 或者: from moviepy.video.io.VideoFileClip.VideoFileClip import write_videofile [as 別名]
def download_and_convert(url):
	print("converting url " + url)
	source = pafy.new(url)
	best = source.getbest(preftype="mp4")
	ts = datetime.datetime.fromtimestamp(time.time()).strftime('%Y%m%d-%H%M%S')
	input_filename = "/tmp/" + ts + "." + best.extension

	best.download(filepath=input_filename)
	output = VideoFileClip(input_filename)
	duration = output.duration
	
	output_filename="/tmp/" + best.title + "." + best.extension

	output = output.set_audio(audio).fl_time(lambda t: t * accel, apply_to='mask').set_duration(duration / accel)
	output.write_videofile(output_filename)

	print("uploading to s3")

	s3 = boto.connect_s3()
	bucket = s3.get_bucket('bennyhill')
	key = Key(bucket)
	key.key = best.title + "-" + ts
	key.set_contents_from_filename(output_filename)

	output_url = key.generate_url(expires_in=3600)

	print("complete")

	# save the results
	try:
		result = Result(
			url=url,
			youtube_url=output_url
		)
		db.session.add(result)
		db.session.commit()
		return result.id
	except:
		errors.append("Unable to add item to database.")
		return {"error": errors}
開發者ID:xuloo,項目名稱:bennyhillmachine,代碼行數:42,代碼來源:app.py


注:本文中的moviepy.video.io.VideoFileClip.VideoFileClip.write_videofile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。