launcher: Make --update-media-info check if generating frames info or not

This commit is contained in:
Thibault Saunier 2016-12-22 10:08:30 -03:00
parent a4aa5c60bb
commit 5fc11cf389
3 changed files with 27 additions and 4 deletions

View file

@ -682,9 +682,15 @@ not been tested and explicitely activated if you set use --wanted-tests ALL""")
self.info("%s not present. Use --generate-media-info", media_info)
return True
include_frames = 0
if self.options.update_media_info:
include_frames = 2
elif self.options.generate_info_full:
include_frames = 1
media_descriptor = GstValidateMediaDescriptor.new_from_uri(
uri, True,
self.options.generate_info_full)
include_frames)
if media_descriptor:
self._add_media(media_descriptor, uri)
else:

View file

@ -1896,15 +1896,32 @@ class GstValidateMediaDescriptor(MediaDescriptor):
self.set_protocol(urllib.parse.urlparse(urllib.parse.urlparse(self.get_uri()).scheme).scheme)
@staticmethod
def new_from_uri(uri, verbose=False, full=False):
def new_from_uri(uri, verbose=False, include_frames=False):
"""
include_frames = 0 # Never
include_frames = 1 # always
include_frames = 2 # if previous file included them
"""
media_path = utils.url2path(uri)
descriptor_path = "%s.%s" % (
media_path, GstValidateMediaDescriptor.MEDIA_INFO_EXT)
if include_frames == 2:
try:
media_xml = ET.parse(descriptor_path).getroot()
frames = media_xml.findall('streams/stream/frame')
include_frames = bool(frames)
except FileNotFoundError:
pass
else:
include_frames = bool(include_frames)
args = GstValidateMediaDescriptor.DISCOVERER_COMMAND.split(" ")
args.append(uri)
args.extend(["--output-file", descriptor_path])
if full:
if include_frames:
args.extend(["--full"])
if verbose:

View file

@ -431,7 +431,7 @@ Note that all testsuite should be inside python modules, so the directory should
help="Set it in order to generate the missing .media_infos files")
parser.add_argument("--update-media-info", dest="update_media_info",
action="store_true",
help="Set it in order to update exising .media_infos files")
help="Set it in order to update existing .media_infos files")
parser.add_argument(
"-G", "--generate-media-info-with-frame-detection", dest="generate_info_full",
action="store_true",