MCPcopy Create free account
hub / github.com/FastLED/FastLED / openMpeg1Video

Method openMpeg1Video

src/fl/codec/file_system_codecs.cpp.hpp:81–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79};
80
81Video 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
103FramePtr FileSystem::loadJpeg(const char *path, const JpegConfig &config,
104 fl::string *error_message) {

Callers

nothing calls this directly

Calls 7

stringClass · 0.50
is_openMethod · 0.45
setErrorMethod · 0.45
appendMethod · 0.45
beginMethod · 0.45
rdbufMethod · 0.45
hasErrorMethod · 0.45

Tested by

no test coverage detected