我第一次看到那個名字!?因爲我相信你能夠從命令行運行ffmpeg並執行基本的Python東西,所以我建議遵循我的示例,因爲它應該避免給定文件中的任何奇怪的directory.connection.stuff(我忽略了它)。 「當天早些時候,」讓我忽略的.py腳本和共享如下: 假設你從windows.command.line跑 ffmpeg -i soccer.mp4 ...stuff... soccer1.mp4
... 倒不如寫 ffmpeg -t 10 -i "Z:\\full\\input\\path.mp4" -c copy "Z:\\full\\output\\path.mp4"
此說,運行ffmpeg
,-t
= input.duration.seconds,-i
= input.file.next, "fullinpath"
引號引起空間等,-c
= all.codecs,copy
= atlantian.magic.trick, "fulloutpath"
也是安全的,沒有別的!
"Piping" through python to windows works great for this:
import subprocess as subprocess
def pegRunner(cmd): #Takes a list of strings we'll pass to windows.
command = [x for x in cmd] # peg short for mpeg, shoulda used meg.gem.gepm.gipper.translyvania.otheroptions
result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output, err = result.communicate()
print result.wait()
return "pegRannered"
#########
# Find the duration from properties or something. If you need to do this
# often it's more complicated. Let's say you found 4mins33secs.
############
leng = 4*60+33 # time in seconds
last_dur = int(leng%60) #remaining time after the 4 one.min.vids
if last_dur == 0: num_vids = int(leng/60)
else: num_vids = int(leng/60)+1
for i in range(num_vids):
da_command = ['ffmpeg']
da_command.append('-ss')
da_command.append(str(i*60))
da_command.append('-t')
if i != num_vids: da_command.append('60')
else: da_command.append(str(last_dur))
da_command.append('-i')
da_command.append('Z:\\full\\input\\path.mp4') #this format!
da_command.append('-c')
da_command.append('copy')
#optionally to overwrite!!!! da_command.append('-y')
da_command.append('Z:\\full\\output\\path\\filename_'+str(i)+'.mp4')
print pegRunner(da_command)
print "Finished "+str(i)+" filez."
這應該處理1.min件,從蟒蛇的ffmpeg提供一個很好的起點。
您是否正在運行Windows?如果是這樣,ffmpeg-split.py將不起作用---它使用(相當懶惰地)一些Windows上不存在的命令/功能 – DoctorSelar