MCPcopy Index your code
hub / github.com/diffgram/diffgram / build_video_packet

Function build_video_packet

shared/export/export_generation.py:390–477  ·  view source on GitHub ↗

* Serializes video information * Gets all frames *with instances* for the video FILE * Each frame it gets the instance list It assumes that we don't need to say do the width for each image since it's the same for the video. We could also export it by sequence. ie for e

(file, session)

Source from the content-addressed store, hash-verified

388
389
390def build_video_packet(file, session):
391 """
392 * Serializes video information
393 * Gets all frames *with instances* for the video FILE
394 * Each frame it gets the instance list
395
396 It assumes that we don't need to say do the width for each
397 image since it's the same for the video.
398
399 We could also export it by sequence.
400 ie for each video, we export the frames for the sequence...
401
402 """
403
404 # Question, could we use an existing serialize method for this part?
405 # Feels a bit funny to repeat it like this here.
406 file.video.regenerate_url(
407 project = file.project,
408 session = session)
409
410 # For global Attributes
411 parent_instance_list = Instance.list(
412 session = session,
413 file_id = file.id,
414 limit = None
415 )
416 parent_instance_list_serialized = []
417 for instance in parent_instance_list:
418 parent_instance_list_serialized.append(build_instance(instance, file))
419
420 # Context of making it easier to inspect and download media
421 mp4_video_signed_url = file.video.file_signed_url
422
423 if settings.DIFFGRAM_STATIC_STORAGE_PROVIDER == 'gcp':
424 if mp4_video_signed_url:
425 mp4_video_signed_url += ".mp4"
426
427 video_dict = {
428 'width': file.video.width,
429 'height': file.video.height,
430 'frame_rate': file.video.frame_rate,
431 'frame_count': file.video.frame_count,
432 'original_fps': file.video.original_fps,
433 'fps_conversion_ratio': file.video.fps_conversion_ratio,
434 'mp4_video_signed_url': mp4_video_signed_url,
435 'mp4_video_signed_expiry': file.video.url_signed_expiry,
436 'offset_in_seconds': file.video.offset_in_seconds,
437 'global_frame_start': file.video.calculate_global_reference_frame(
438 frame_number = 0)
439 }
440
441 sequence_list = session.query(Sequence).filter(
442 Sequence.video_file_id == file.id).all()
443 sequence_list_serialized = []
444
445 for sequence in sequence_list:
446
447 sequence_dict = sequence.serialize_for_export()

Callers 1

build_packetFunction · 0.85

Calls 5

build_instanceFunction · 0.85
regenerate_urlMethod · 0.80
listMethod · 0.45
serialize_for_exportMethod · 0.45

Tested by

no test coverage detected