diff --git a/README.md b/README.md index 5c94fee..76f8e81 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,7 @@ Using `miniaudio` and `ffmpeg` together. +## Resources + + - Audio Sample Frames - + diff --git a/ffmini.cpp b/ffmini.cpp index 7b848ee..8605fc0 100644 --- a/ffmini.cpp +++ b/ffmini.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "fmt/format.h" #include "miniaudio.h" @@ -93,7 +94,6 @@ public: private: std::size_t m_frame_count{0}; }; -using audio_track_ref_t = std::shared_ptr; auto ffmpeg_error_str(int err) { static char str[AV_ERROR_MAX_STRING_SIZE]{}; @@ -162,7 +162,7 @@ public: while (frame_read < frame_count) { auto track = std::static_pointer_cast(m_tracks[0]); if (track->empty()) read(track); - frame_read += track->read_pcm_frame(output, frame_count); + frame_read += track->read_pcm_frame(output, frame_count - frame_read); } } @@ -225,9 +225,12 @@ auto callback([[maybe_unused]]ma_device* device, [[maybe_unused]]void* output, [ auto entry() -> void { media decoder{}; - decoder.load("C:/Users/miku/Downloads/Porter Robinson - Trying to Feel Alive (Official Audio).webm"); - fmt::print("{}\n", decoder.str()); + decoder.load("/Users/k/Downloads/tryingtofeelalive.mp4"); + fmt::print("{}", decoder.str()); + if (decoder.tracks().empty()) + throw std::runtime_error("There are no tracks readable."); + // TODO: Deocde and cache it in the background. auto track = std::static_pointer_cast(decoder.tracks()[0]); ma_device device;