
Słowem miałem ciekawy trip i chyba go za jakiś czas powtórzę ]:)
mp4-for-SE.py(Toggle Plain Text)
#!/usr/bin/python # -*- coding: utf-8 -*- # FLV-to-MP4 converter for Sony-Ericsson K550i # # Depends on ffmpeg and exiftool import sys import os import re add=0 episode = 300 # 5 minutes width=220 height=176 DONT_SPLIT=False # Get input & output try: fin=sys.argv[1] p=re.compile(r'\.\w*$') m=p.search(fin) fout=fin.replace(m.group(0),"") except: fin="" if fin=="": print "Usage: mp4-for-SE.py INPUT" else: # Get aspect ratio stdout_handle = os.popen("exiftool -Image\Width "+fin, "r") iwidth = stdout_handle.read() stdout_handle = os.popen("exiftool -Image\Height "+fin, "r") iheight = stdout_handle.read() try: p1=re.compile(r'Image Width\s*:\s*') p2=re.compile(r'Image Height\s*:\s*') m1=p1.match(iwidth) m2=p2.match(iheight) iwidth=iwidth.replace(m1.group(0),"") iheight=iheight.replace(m2.group(0),"") iwidth=iwidth.replace("\n","") iheight=iheight.replace("\n","") src_aspect=float(iwidth)/float(iheight) dest_aspect=float(width)/float(height) if src_aspect>dest_aspect: height=int(float(width)/src_aspect) if (height % 2 <> 0): height+=1 else: width=int(float(height)/src_aspect) if (width % 2 <> 0): width+=1 except: pass stdout_handle = os.popen("exiftool -Duration "+fin, "r") str_duration = stdout_handle.read() # Basic preparation try: p=re.compile(r'Duration\s*:\s*') m=p.match(str_duration) str_duration=str_duration.replace(m.group(0),"") str_duration=str_duration.replace("\n","") except: print "Error: Can't get movie duration. Converting whole movie." DONT_SPLIT=True exit if DONT_SPLIT: counter=0 else: # Format some youtube movies outputing duration as "xx:xx.xxxx s" p=re.compile(r'\.\d*\s*s') m=p.search(str_duration) try: str_duration=str_duration.replace(m.group(0),"") add=1 except: pass duration=str_duration.split(":") s=int(duration[-1]) try: m=int(duration[-2]) except: m=0 try: h=int(duration[-3]) except: h=0 total=h*3600+m*60+s+add print "\033[1;32mTotal time:\033[1;31m",total,"\033[1;39ms" counter = total/episode print "\033[1;32mTotal parts:\033[1;31m",counter+1,"\033[1;39m" for i in range(0,counter+1): if counter==0: os.system("ffmpeg -i "+fin+" -s "+str(width)+"x"+str(height)+" -ss "+str(i*episode)+" -t "+str(episode)+" -vcodec mpeg4 "+fout+".mp4") else: os.system("ffmpeg -i "+fin+" -s "+str(width)+"x"+str(height)+" -ss "+str(i*episode)+" -t "+str(episode)+" -vcodec mpeg4 "+fout+"["+str(i+1)+"].mp4")
Niespodziewana radość tak samo człowieka ogłusza jak nagłe nieszczęście.
~ Charles Dickens
Popatrz jak wszystko szybko się zmienia, coś jest a później tego nie ma
człowiek jest tylko sumą oddechów, wiec nie mów mi że jest jakiś sposób
~ Sidney Polak feat. Pezet, "Otwieram wino"
So where is the passion when you need it the most?