| 79 | }; |
| 80 | |
| 81 | Video FileSystem::openMpeg1Video(const char *path, fl::size pixelsPerFrame, float fps, |
| 82 | fl::size nFrameHistory) { |
| 83 | Video video(pixelsPerFrame, fps, nFrameHistory); |
| 84 | fl::ifstream file = openRead(path); |
| 85 | if (!file.is_open()) { video.setError(fl::string("Could not open MPEG1 file: ").append(path)); return video; } |
| 86 | Mpeg1Config config; |
| 87 | config.mode = Mpeg1Config::Streaming; |
| 88 | config.targetFps = static_cast<fl::u16>(fps); |
| 89 | config.looping = false; |
| 90 | config.skipAudio = true; |
| 91 | fl::string error_message; |
| 92 | IDecoderPtr decoder = Mpeg1::createDecoder(config, &error_message); |
| 93 | if (!decoder) { video.setError(fl::string("Failed to create MPEG1 decoder: ").append(error_message)); return video; } |
| 94 | if (!decoder->begin(file.rdbuf())) { |
| 95 | fl::string decoder_error; decoder->hasError(&decoder_error); |
| 96 | video.setError(fl::string("Failed to initialize MPEG1 decoder: ").append(decoder_error)); return video; |
| 97 | } |
| 98 | fl::shared_ptr<Mpeg1FileHandle> mpeg1Stream = fl::make_shared<Mpeg1FileHandle>(decoder, pixelsPerFrame, path); |
| 99 | if (!video.begin(mpeg1Stream)) { video.setError(fl::string("Failed to initialize video with MPEG1 stream")); return video; } |
| 100 | return video; |
| 101 | } |
| 102 | |
| 103 | FramePtr FileSystem::loadJpeg(const char *path, const JpegConfig &config, |
| 104 | fl::string *error_message) { |