MCPcopy Create free account
hub / github.com/CapSoftware/Cap / processFile

Function processFile

apps/web/components/tools/TrimmingTool.tsx:99–159  ·  view source on GitHub ↗
(selectedFile: File)

Source from the content-addressed store, hash-verified

97 };
98
99 const processFile = (selectedFile: File) => {
100 cleanupResources();
101
102 setFileState((prev) => ({
103 ...prev,
104 isLoading: true,
105 error: null,
106 }));
107
108 if (!isVideoFile(selectedFile)) {
109 setFileState((prev) => ({
110 ...prev,
111 isLoading: false,
112 error: "Please select a valid video file.",
113 }));
114 trackEvent("trimming_tool_invalid_file_type", {
115 fileType: selectedFile.type,
116 });
117 return;
118 }
119
120 if (selectedFile.size > 500 * 1024 * 1024) {
121 setFileState((prev) => ({
122 ...prev,
123 isLoading: false,
124 error: "File size exceeds 500MB limit.",
125 }));
126 trackEvent("trimming_tool_file_too_large", {
127 fileSize: selectedFile.size,
128 });
129 return;
130 }
131
132 setFileState((prev) => ({
133 ...prev,
134 file: selectedFile,
135 }));
136
137 try {
138 const objectUrl = URL.createObjectURL(selectedFile);
139
140 setTimeout(() => {
141 setFileState((prev) => ({
142 ...prev,
143 videoSrc: objectUrl,
144 }));
145
146 trackEvent("trimming_tool_file_selected", {
147 fileSize: selectedFile.size,
148 fileType: selectedFile.type,
149 });
150 }, 10);
151 } catch (err) {
152 console.error("Error creating object URL:", err);
153 setFileState((prev) => ({
154 ...prev,
155 isLoading: false,
156 error: "Could not load video file. Please try a different file.",

Callers 4

handleFileChangeFunction · 0.85
handleDropFunction · 0.85
handleFileChangeFunction · 0.85
ImportFilePageFunction · 0.85

Calls 3

trackEventFunction · 0.90
cleanupResourcesFunction · 0.85
isVideoFileFunction · 0.85

Tested by

no test coverage detected