From d72cd7a5e6174516c5e9fdfd1323eb2cb6a57847 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 23 Feb 2011 12:55:40 +0100 Subject: [PATCH] audio only --- pandora_client/__init__.py | 17 +++++++++-------- pandora_client/extract.py | 37 +++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 8d37be0..77c5dea 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -29,14 +29,15 @@ def encode(filename, prefix, profile): return None oshash = info['oshash'] frames = [] - for pos in utils.video_frame_positions(info['duration']): - frame_name = '%s.png' % pos - cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash))) - frame_f = os.path.join(cache, frame_name) - if not os.path.exists(frame_f): - print frame_f - extract.frame(filename, frame_f, pos) - frames.append(frame_f) + cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash))) + if info['video']: + for pos in utils.video_frame_positions(info['duration']): + frame_name = '%s.png' % pos + frame_f = os.path.join(cache, frame_name) + if not os.path.exists(frame_f): + print frame_f + extract.frame(filename, frame_f, pos) + frames.append(frame_f) video_f = os.path.join(cache, profile) if not os.path.exists(video_f): print video_f diff --git a/pandora_client/extract.py b/pandora_client/extract.py index b4a2f50..0eff604 100644 --- a/pandora_client/extract.py +++ b/pandora_client/extract.py @@ -58,7 +58,9 @@ def video(video, target, profile, info): if not os.path.exists(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 lag @@ -68,7 +70,6 @@ def video(video, target, profile, info): token_partitions=4 level / speedlevel bt? - ''' profile, format = profile.split('.') @@ -109,16 +110,26 @@ def video(video, target, profile, info): audiochannels = 1 bpp = 0.17 - fps = AspectRatio(info['video'][0]['framerate']) + if info['video']: + fps = AspectRatio(info['video'][0]['framerate']) - width = int(dar * height) - width += width % 2 + width = int(dar * height) + width += width % 2 - bitrate = height*width*fps*bpp/1000 - aspect = dar.ratio - #use 1:1 pixel aspect ratio if dar is close to that - if abs(width/height - dar) < 0.02: - aspect = '%s:%s' % (width, height) + bitrate = height*width*fps*bpp/1000 + aspect = dar.ratio + #use 1:1 pixel aspect ratio if dar is close to that + if abs(width/height - dar) < 0.02: + 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']: audio_settings = ['-ar', str(audiorate), '-aq', str(audioquality)] @@ -130,12 +141,6 @@ def video(video, target, profile, info): else: 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] \ + audio_settings \ + video_settings \