Skip to content

Commit

Permalink
extract_gsf: add option to dump all grains
Browse files Browse the repository at this point in the history
  • Loading branch information
philipnbbc committed Jan 25, 2024
1 parent 0d62918 commit a01cb34
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mediagrains/tools/extract_from_gsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def gsf_probe():
parser.add_argument("input_file", help="Input file. Specify - for stdin", type=str)
parser.add_argument("-a", "--all-timestamps", help="Print all the grain timestamps in the file",
action="store_true")
parser.add_argument("-g", "--all-grains", help="Print all the grains in the file",
action="store_true")

args = parser.parse_args()

Expand All @@ -70,12 +72,19 @@ def gsf_probe():
for grain, local_id in decoder.grains(load_lazily=True):
this_segment = file_data["segments"][local_id]

if args.all_grains:
try:
this_segment["grain_data"].append(grain.meta["grain"])
except KeyError:
this_segment["grain_data"] = [grain.meta["grain"]]

try:
this_segment["timerange"] = \
this_segment["timerange"].extend_to_encompass_timerange(grain.origin_timerange())
except KeyError:
this_segment["timerange"] = grain.origin_timerange()
this_segment["grain_data"] = grain.meta["grain"]
if not args.all_grains:
this_segment["grain_data"] = grain.meta["grain"]

if args.all_timestamps:
grain_ts_data = {
Expand Down

0 comments on commit a01cb34

Please sign in to comment.