Correction d'un bug qui empêchait de retrouver correctement les timestamps initiaux et finaux.
This commit is contained in:
15
panasonic.py
15
panasonic.py
@@ -153,9 +153,11 @@ def dumpFilms(films):
|
|||||||
def getInitialTSFromBuffer(content):
|
def getInitialTSFromBuffer(content):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
with Popen(['ffprobe','/dev/stdin','-loglevel', 'quiet', '-read_intervals', '0%+0.000001', '-show_entries', 'frame=frame_no,best_effort_timestamp_time', '-of','json'], stdout=PIPE, stdin=PIPE) as ffprobe:
|
logger.debug('Determining initial timestamp from content')
|
||||||
|
with Popen(['ffprobe','/dev/stdin','-loglevel', 'quiet', '-read_intervals', '0%+0.1', '-show_entries', 'frame=frame_no,best_effort_timestamp_time', '-of','json'], stdout=PIPE, stdin=PIPE) as ffprobe:
|
||||||
out, _ = ffprobe.communicate(input=content)
|
out, _ = ffprobe.communicate(input=content)
|
||||||
frames = json.load(BytesIO(out))
|
frames = json.load(BytesIO(out))
|
||||||
|
logger.debug('Frames: %s' % frames)
|
||||||
if 'frames' in frames:
|
if 'frames' in frames:
|
||||||
frames = frames['frames']
|
frames = frames['frames']
|
||||||
if len(frames) > 0:
|
if len(frames) > 0:
|
||||||
@@ -173,10 +175,12 @@ def getInitialTSFromBuffer(content):
|
|||||||
def getLastTSFromBuffer(content):
|
def getLastTSFromBuffer(content):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
logger.debug('Determining last timestamp from content.')
|
||||||
length = len(content)
|
length = len(content)
|
||||||
with Popen(['ffprobe', '/dev/stdin', '-loglevel', 'quiet', '-show_entries', 'frame=frame_no,best_effort_timestamp_time', '-of','json'], stdout=PIPE, stdin=PIPE) as ffprobe:
|
with Popen(['ffprobe', '/dev/stdin', '-loglevel', 'quiet', '-show_entries', 'frame=frame_no,best_effort_timestamp_time', '-of','json'], stdout=PIPE, stdin=PIPE) as ffprobe:
|
||||||
out, _ = ffprobe.communicate(input=content[max(0,length-100000):])
|
out, _ = ffprobe.communicate(input=content[max(0,length-200000):])
|
||||||
frames = json.load(BytesIO(out))
|
frames = json.load(BytesIO(out))
|
||||||
|
logger.debug('Frames: %s' % frames)
|
||||||
if 'frames' in frames:
|
if 'frames' in frames:
|
||||||
frames = frames['frames']
|
frames = frames['frames']
|
||||||
if len(frames) > 0:
|
if len(frames) > 0:
|
||||||
@@ -247,12 +251,15 @@ def downloadMovie(url, outputFileName, duration):
|
|||||||
if m == None:
|
if m == None:
|
||||||
logger.error('Impossible to parse timestamps' % r.headers['TimeSeekRange.dlna.org'])
|
logger.error('Impossible to parse timestamps' % r.headers['TimeSeekRange.dlna.org'])
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
total = int(m.group('totalsecs'))+(int(m.group('totalms')))/1000
|
total = int(m.group('totalsecs'))+(int(m.group('totalms')))/1000
|
||||||
total = timedelta(seconds=total)
|
total = timedelta(seconds=total)
|
||||||
|
logger.debug('Header: %s' % r.headers)
|
||||||
|
|
||||||
initialTS = getInitialTSFromBuffer(r.content)
|
initialTS = getInitialTSFromBuffer(r.content)
|
||||||
|
logger.debug('Initial timestamp: %s' % initialTS)
|
||||||
lastTS = getLastTSFromBuffer(r.content)
|
lastTS = getLastTSFromBuffer(r.content)
|
||||||
|
logger.debug('Last timestamp: %s' % lastTS)
|
||||||
delta = lastTS-initialTS
|
delta = lastTS-initialTS
|
||||||
ratio = delta/total
|
ratio = delta/total
|
||||||
estimatedLength = ceil(len(r.content)/ratio)
|
estimatedLength = ceil(len(r.content)/ratio)
|
||||||
|
|||||||
Reference in New Issue
Block a user