28
28
RecordingOpts : RecordingOptions {
29
29
FPS : 30 ,
30
30
CaptureMouse : true ,
31
- AudioDevice : "" ,
32
31
},
33
32
HotkeyConfig : hotkeyConfig {
34
33
Modkeys : []string {"ctrl" , "shift" },
@@ -61,7 +60,6 @@ func extractFFmpegExe(zipPath, destDir string) error {
61
60
defer outFile .Close ()
62
61
63
62
_ , err = io .Copy (outFile , rc )
64
- os .Remove (zipPath )
65
63
return err
66
64
}
67
65
}
@@ -75,11 +73,17 @@ type hotkeyConfig struct {
75
73
Note string `json:"note"`
76
74
}
77
75
76
+ type streamConfig struct {
77
+ YoutubeStreamKey string `json:"ytstreamkey"`
78
+ TwitchStreamKey string `json:"twitchstreamkey"`
79
+ }
80
+
78
81
type Config struct {
79
82
SaveLocation string `json:"save_location"`
80
83
RecordFunc bool `json:"record_func_enabled"`
81
84
RecordingOpts RecordingOptions `json:"recording_options,omitempty"`
82
85
HotkeyConfig hotkeyConfig `json:"hotkey_config"`
86
+ StreamConfig streamConfig `json:"stream_config"`
83
87
}
84
88
85
89
type RecordingOptions struct {
@@ -111,7 +115,7 @@ func initConfig() {
111
115
}
112
116
var loadedConfig Config
113
117
if err := json .Unmarshal (data , & loadedConfig ); err != nil {
114
- panic ( err )
118
+ os . WriteFile ( configFilePath , [] byte { '{' , '}' }, 0644 )
115
119
}
116
120
117
121
config = mergeConfig (defaultConfig , loadedConfig )
@@ -186,6 +190,7 @@ func initDownloads() {
186
190
tasks .Add ("https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n7.1-latest-win64-gpl-7.1.zip" , filepath .Join (dwnPath , "ffmpeg_captr.zip" ), progressbar .WithBarSpinner (51 ))
187
191
tasks .Add ("https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/checksums.sha256" , filepath .Join (dwnPath , "checksums.sha256" ), progressbar .WithBarSpinner (51 ))
188
192
tasks .Wait ()
193
+ tasks .Close ()
189
194
fmt .Println ("Checking sha256 hash of the downloaded file." )
190
195
file , err := os .ReadFile (filepath .Join (dwnPath , "checksums.sha256" ))
191
196
if err != nil {
@@ -200,20 +205,22 @@ func initDownloads() {
200
205
shaHash := strings .Split (line , " " )[0 ]
201
206
f , err := os .Open (filepath .Join (dwnPath , "ffmpeg_captr.zip" ))
202
207
if err != nil {
208
+ f .Close ()
203
209
fmt .Println (err )
204
210
fmt .Println ("Cannot match checksum file of the download. Aborting install..." )
205
211
os .Remove (filepath .Join (dwnPath , "checksums.sha256" ))
206
212
os .Remove (filepath .Join (dwnPath , "ffmpeg_captr.zip" ))
207
213
os .Exit (1 )
208
214
}
209
- defer f .Close ()
210
215
h := sha256 .New ()
211
216
if _ , err := io .Copy (h , f ); err != nil {
217
+ f .Close ()
212
218
fmt .Println ("Cannot generate sha256 for the download. Aborting install..." )
213
219
os .Remove (filepath .Join (dwnPath , "checksums.sha256" ))
214
220
os .Remove (filepath .Join (dwnPath , "ffmpeg_captr.zip" ))
215
221
os .Exit (1 )
216
222
}
223
+ f .Close ()
217
224
if shaHash != fmt .Sprintf ("%x" , h .Sum (nil )) {
218
225
fmt .Println ("SHA256 hash unmatched for the downloaded file. Install aborted." )
219
226
fmt .Printf ("Expected hash: %s\n Hash got: %x" , shaHash , h .Sum (nil ))
@@ -223,7 +230,19 @@ func initDownloads() {
223
230
}
224
231
}
225
232
}
226
- extractFFmpegExe (filepath .Join (dwnPath , "ffmpeg_captr.zip" ), dwnPath )
233
+ err = extractFFmpegExe (filepath .Join (dwnPath , "ffmpeg_captr.zip" ), dwnPath )
234
+ if err != nil {
235
+ fmt .Println (err )
236
+ return
237
+ }
238
+ err = os .Remove (filepath .Join (dwnPath , "checksums.sha256" ))
239
+ if err != nil {
240
+ fmt .Println (err )
241
+ }
242
+ err = os .Remove (filepath .Join (dwnPath , "ffmpeg_captr.zip" ))
243
+ if err != nil {
244
+ fmt .Println (err )
245
+ }
227
246
fmt .Printf ("FFMPEG has been downloaded to %s" , dwnPath )
228
247
} else {
229
248
setConfig ("record_func_enabled" , false )
@@ -300,7 +319,7 @@ v1.0.2
300
319
301
320
` )
302
321
fmt .Println ("Open config file by passing the --config flag" )
303
- capture_ops := []string {"Record full screen" , "Record specific window" , "Screenshot specific window" , "Screenshot full screen" }
322
+ capture_ops := []string {"Record full screen" , "Record specific window" , "Screenshot specific window" , "Screenshot full screen" , "Stream a display" }
304
323
var i int
305
324
err := survey .AskOne (& survey.Select {
306
325
Message : "Select Action" ,
@@ -315,9 +334,13 @@ v1.0.2
315
334
switch i {
316
335
case 0 :
317
336
RecordDisplay ()
337
+ case 1 :
338
+ RecordWindow ()
318
339
case 2 :
319
340
Screenshot_Window ()
320
341
case 3 :
321
342
Screenshot_Display ()
343
+ case 4 :
344
+ StreamDisp ()
322
345
}
323
346
}
0 commit comments