FastLED 3.9.15
Loading...
Searching...
No Matches

◆ openMpeg1Video()

Video fl::FileSystem::openMpeg1Video ( const char * path,
fl::size pixelsPerFrame,
float fps = 30.0f,
fl::size nFrameHistory = 0 )

Definition at line 81 of file file_system_codecs.cpp.hpp.

82 {
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;
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}
fl::Video video(NUM_LEDS, 2.0f)
fl::ifstream openRead(const char *path)
static IDecoderPtr createDecoder(const Mpeg1Config &config, fl::string *error_message=nullptr)
Definition mpeg1.cpp.hpp:8
bool begin(fl::filebuf_ptr h)
Definition video.cpp.hpp:38
void setError(const string &error)
Definition video.h:71
bool is_open() const
Definition fstream.h:111
filebuf_ptr rdbuf() const
Definition fstream.h:143
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
third_party::Mpeg1Config Mpeg1Config
Definition mpeg1.h:29

References fl::Mpeg1::createDecoder(), fl::ifstream::is_open(), fl::third_party::Mpeg1Config::looping, fl::make_shared(), fl::third_party::Mpeg1Config::mode, openRead(), fl::ifstream::rdbuf(), fl::third_party::Mpeg1Config::skipAudio, fl::third_party::Mpeg1Config::Streaming, and fl::third_party::Mpeg1Config::targetFps.

+ Here is the call graph for this function: