File size: 4,477 Bytes
4384839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
export interface VideoInfo {
    height: number;
    width: number;
    channels: number;
    codec: string;
    pix_fmt: string;
    is_depth_map: boolean;
    has_audio: boolean;
}

/**
 * Metadata parameters interface
 */
interface MetadataParams {
    total_episodes: number;
    total_frames: number;
    total_tasks: number;
    chunks_size: number;
    fps: number;
    splits: { [key: string]: string };
    features: { [key: string]: any };
    videos_info: VideoInfo[];
    data_files_size_in_mb: number;
    video_files_size_in_mb: number;
}

/**
 * Generates and returns a metadata information dictionary
 * Needs some named parameters passed as parameters
 */
function getMetadataInfo(params: MetadataParams) {
    return {
        "codebase_version": "v2.1",
        "robot_type": "so100",
        "total_episodes": params.total_episodes,
        "total_frames": params.total_frames,
        "total_tasks": params.total_tasks,
        "total_videos": params.videos_info.length,
        "total_chunks": 1,
        "chunks_size": params.chunks_size,
        "fps": params.fps,
        "splits": {
            "train": `0:${params.total_episodes}`
        },
        "data_path": "data/chunk-{episode_chunk:03d}/episode_{episode_index:06d}.parquet",
        "video_path": "videos/chunk-{episode_chunk:03d}/{video_key}/episode_{episode_index:06d}.mp4",
        "features": {
            "action": {
                "dtype": "float32",
                "shape": [
                    6
                ],
                "names": [
                    "main_shoulder_pan",
                    "main_shoulder_lift",
                    "main_elbow_flex",
                    "main_wrist_flex",
                    "main_wrist_roll",
                    "main_gripper"
                ],
                "fps": params.fps
            },
            "observation.state": {
                "dtype": "float32",
                "shape": [
                    6
                ],
                "names": [
                    "main_shoulder_pan",
                    "main_shoulder_lift",
                    "main_elbow_flex",
                    "main_wrist_flex",
                    "main_wrist_roll",
                    "main_gripper"
                ],
                "fps": params.fps
            },
            "observation.images.front": {
                "dtype": "video",
                "shape": [
                    480,
                    640,
                    3
                ],
                "names": [
                    "height",
                    "width",
                    "channels"
                ],
                "info": {
                    "video.fps": params.fps,
                    "video.height": 480,
                    "video.width": 640,
                    "video.channels": 3,
                    "video.codec": "av1",
                    "video.pix_fmt": "yuv420p",
                    "video.is_depth_map": false,
                    "has_audio": false
                }
            },
            "timestamp": {
                "dtype": "float32",
                "shape": [
                    1
                ],
                "names": null,
                "fps": params.fps
            },
            "frame_index": {
                "dtype": "int64",
                "shape": [
                    1
                ],
                "names": null,
                "fps": params.fps
            },
            "episode_index": {
                "dtype": "int64",
                "shape": [
                    1
                ],
                "names": null,
                "fps": params.fps
            },
            "index": {
                "dtype": "int64",
                "shape": [
                    1
                ],
                "names": null,
                "fps": params.fps
            },
            "task_index": {
                "dtype": "int64",
                "shape": [
                    1
                ],
                "names": null,
                "fps": params.fps
            }
        },
        "data_files_size_in_mb": 100,
        "video_files_size_in_mb": 500
    }
}

export function getVideoInfo(width: number, height: number): VideoInfo {
    return {
        height,
        width, 
        channels: 3,
        codec: "h264",
        pix_fmt: "yuv420p",
        is_depth_map: false,
        has_audio: false
    };
}

export default getMetadataInfo;