I want to add moving txt in the JPG,but after i create the video,the JPG will be vague.
I don't know why and how to fix this!
Thank you for your help,next are my situation and code!

# -*- coding: utf-8 -*-
"""
Created on Mon Apr 27 01:46:10 2020
@author: HPN
"""
'''
I want to add moving txt in the JPG,but after i create the video,the JPG will be vague.
I don't know why and how to fix this!
Thank you for your help,next is my code!
'''
import numpy as np
from moviepy.editor import *
from moviepy.video.tools.segmenting import findObjects
# WE CREATE THE TEXT THAT IS GOING TO MOVE, WE CENTER IT.
URL_PANGMEN = './font/pangmen.ttf' #旁门正道
image = ImageClip('./BG.jpg',duration = 5).set_pos('center')
screensize = (1280,720)
txtClip = TextClip('This is a test',color='white',font =URL_PANGMEN,
kerning = 5, fontsize=80)
cvc = CompositeVideoClip( [txtClip.set_pos('center')], #将不是videoclip的clip变成videoclip
size=screensize)
# THE NEXT FOUR FUNCTIONS DEFINE FOUR WAYS OF MOVING THE LETTERS
# helper function
rotMatrix = lambda a: np.array( [[np.cos(a),np.sin(a)],
[-np.sin(a),np.cos(a)]] )
def vortex(screenpos,i,nletters): #涡进
d = lambda t : 1.0/(0.3+t**8) #damping #阻尼
a = i*np.pi/ nletters # angle of the movement #移动的角度
v = rotMatrix(a).dot([-1,0])
if i%2 : v[1] = -v[1]
return lambda t: screenpos+400*d(t)*rotMatrix(0.5*d(t)*a).dot(v)
# WE USE THE PLUGIN findObjects TO LOCATE AND SEPARATE EACH LETTER
letters = findObjects(cvc) # a list of ImageClips
# WE ANIMATE THE LETTERS
def moveLetters(letters, funcpos):
return [ letter.set_pos(funcpos(letter.screenpos,i,len(letters)))
for i,letter in enumerate(letters)]
clips = CompositeVideoClip( moveLetters(letters,vortex),
size = screensize).set_duration(5)
final_clip = CompositeVideoClip([image,clips])
应该是码率的问题,你试着把码率调高一下,write_vidrofile里加参数bitrate='4000000'
That s probably due to the low bitrate, I think you should add keyword parameter bitrate='4000000'to write_vidrofile.
Thanks for the response @ODtian, it looks like a good solution. We'd appreciate it if you wrote in English (as well as other languages if you like), which means that more people can search for and use your answers. :)
十分感激,尽然有中文的回答,谢谢,问题已经解决了,的确是码率的原因!感谢!!!
It works after i try you suggestion,Thank you very much,happy everyday!!!
Most helpful comment
Thanks for the response @ODtian, it looks like a good solution. We'd appreciate it if you wrote in English (as well as other languages if you like), which means that more people can search for and use your answers. :)