Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creation of longer flims #5

Open
fstark opened this issue Sep 11, 2021 · 1 comment
Open

Support creation of longer flims #5

fstark opened this issue Sep 11, 2021 · 1 comment
Labels
encoder Related to flimmaker, the encoder enhancement New feature or request

Comments

@fstark
Copy link
Owner

fstark commented Sep 11, 2021

Creating flims longer than 10 minutes is impractical, due to the memory consumption of flimmaker.

@fstark fstark added the enhancement New feature or request label Sep 11, 2021
@fstark fstark changed the title Support creation of larger flims Support creation of longer flims Oct 30, 2021
@fstark fstark added the encoder Related to flimmaker, the encoder label Nov 7, 2021
@fstark
Copy link
Owner Author

fstark commented Jan 23, 2022

From this reddit comment: https://www.reddit.com/r/cpp/comments/s980ik/a_highlevel_coroutine_explanation/htsa1m4/

Here is an example of how to implement coroutines for video/audio: https://godbolt.org/z/Y7aEP9aoo

Using the generator from: https://github.com/lewissbaker/cppcoro

Copy of the code:

#include <cppcoro/generator.hpp>
#include <iostream>
#include <random>
#include <tuple>
#include <vector>

using video_frame = int;
using audio_frame = double;
using data_packet = std::tuple<std::vector<video_frame>, audio_frame>;

cppcoro::generator<data_packet> decoder() {
    std::random_device r;
    std::default_random_engine engine{r()};
    std::uniform_int_distribution<video_frame> uniform_dist(-100, 100);

    std::vector<video_frame> buffer{};

    for (std::size_t iter{1}; iter < 100; ++iter) {
        if (iter % 10 != 0) {
            buffer.push_back(uniform_dist(engine));
        } else {
            co_yield data_packet{buffer, 10.6 * iter};
            buffer.clear();
        }
    }
}

int main() {
    for (auto const& [video_buffer, audio_buffer] : decoder()) {
        std::cout << "Audio " << audio_buffer << "\nVideo ";

        for (auto frame : video_buffer) {
            std::cout << frame << ",";
        }

        std::cout << "\n";
    }
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
encoder Related to flimmaker, the encoder enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant