| 1 | // Video is the object containing all the information needed for |
| 2 | // conversion to ascii. |
| 3 | struct Video { |
| 4 | pub: |
| 5 | // path may be URL or path on local file system. |
| 6 | path string |
| 7 | tmp_dir string |
| 8 | frame_count int |
| 9 | frame_format FrameFormat |
| 10 | pub mut: |
| 11 | // TODO: once V fixes bug #19281 replace the type here |
| 12 | // with `thread !`. And the return type on the corresponding |
| 13 | // function that is spawned. |
| 14 | extract_frames_thread thread string |
| 15 | frames [][]u8 |
| 16 | framerate f64 = 24.0 |
| 17 | } |
| 18 | |
| 19 | enum FrameFormat { |
| 20 | bmp |
| 21 | jpg |
| 22 | } |
| 23 | |
| 24 | fn (video Video) extract_frames() string { |
| 25 | // try to extract frames os.execute() |
| 26 | // if os.execute() returns with an exit |
| 27 | // code other than 0, return an error. |
| 28 | if true { |
| 29 | return 'Failed to extract frames: os.execute() cmd output' |
| 30 | } |
| 31 | // do something else |
| 32 | return '1234' |
| 33 | } |
| 34 | |
| 35 | fn main() { |
| 36 | mut video := Video{ |
| 37 | path: '/path/to/some/mp4' |
| 38 | tmp_dir: '/tmp' |
| 39 | } |
| 40 | video.extract_frames_thread = spawn video.extract_frames() |
| 41 | println(video.extract_frames_thread.wait()) |
| 42 | println(video) |
| 43 | flush_stdout() |
| 44 | } |
| 45 | |