audio only

This commit is contained in:
j 2011-02-23 12:55:40 +01:00
parent a6a685f532
commit d72cd7a5e6
2 changed files with 30 additions and 24 deletions

View File

@ -29,14 +29,15 @@ def encode(filename, prefix, profile):
return None return None
oshash = info['oshash'] oshash = info['oshash']
frames = [] frames = []
for pos in utils.video_frame_positions(info['duration']): cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash)))
frame_name = '%s.png' % pos if info['video']:
cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash))) for pos in utils.video_frame_positions(info['duration']):
frame_f = os.path.join(cache, frame_name) frame_name = '%s.png' % pos
if not os.path.exists(frame_f): frame_f = os.path.join(cache, frame_name)
print frame_f if not os.path.exists(frame_f):
extract.frame(filename, frame_f, pos) print frame_f
frames.append(frame_f) extract.frame(filename, frame_f, pos)
frames.append(frame_f)
video_f = os.path.join(cache, profile) video_f = os.path.join(cache, profile)
if not os.path.exists(video_f): if not os.path.exists(video_f):
print video_f print video_f

View File

@ -58,7 +58,9 @@ def video(video, target, profile, info):
if not os.path.exists(fdir): if not os.path.exists(fdir):
os.makedirs(fdir) os.makedirs(fdir)
dar = AspectRatio(info['video'][0]['display_aspect_ratio']) if info['video']:
dar = AspectRatio(info['video'][0]['display_aspect_ratio'])
''' '''
look into look into
lag lag
@ -68,7 +70,6 @@ def video(video, target, profile, info):
token_partitions=4 token_partitions=4
level / speedlevel level / speedlevel
bt? bt?
''' '''
profile, format = profile.split('.') profile, format = profile.split('.')
@ -109,16 +110,26 @@ def video(video, target, profile, info):
audiochannels = 1 audiochannels = 1
bpp = 0.17 bpp = 0.17
fps = AspectRatio(info['video'][0]['framerate']) if info['video']:
fps = AspectRatio(info['video'][0]['framerate'])
width = int(dar * height) width = int(dar * height)
width += width % 2 width += width % 2
bitrate = height*width*fps*bpp/1000 bitrate = height*width*fps*bpp/1000
aspect = dar.ratio aspect = dar.ratio
#use 1:1 pixel aspect ratio if dar is close to that #use 1:1 pixel aspect ratio if dar is close to that
if abs(width/height - dar) < 0.02: if abs(width/height - dar) < 0.02:
aspect = '%s:%s' % (width, height) aspect = '%s:%s' % (width, height)
video_settings = [
'-vb', '%dk'%bitrate, '-g', '%d' % int(fps*2),
'-s', '%dx%d'%(width, height),
'-aspect', aspect,
'-vf', 'yadif',
]
else:
video_settings = ['-vn']
if info['audio']: if info['audio']:
audio_settings = ['-ar', str(audiorate), '-aq', str(audioquality)] audio_settings = ['-ar', str(audiorate), '-aq', str(audioquality)]
@ -130,12 +141,6 @@ def video(video, target, profile, info):
else: else:
audio_settings = ['-an'] audio_settings = ['-an']
video_settings = [
'-vb', '%dk'%bitrate, '-g', '%d' % int(fps*2),
'-s', '%dx%d'%(width, height),
'-aspect', aspect,
'-vf', 'yadif',
]
cmd = ['ffmpeg', '-y', '-threads', '2', '-i', video] \ cmd = ['ffmpeg', '-y', '-threads', '2', '-i', video] \
+ audio_settings \ + audio_settings \
+ video_settings \ + video_settings \