avcpp
3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Toggle main menu visibility
Loading...
Searching...
No Matches
api2-timestamp.cpp
Timestamp arithmetic.
Timestamp arithmetic.
api2-timestamp <args>
// Exercises Timestamp and Rational arithmetic without touching any media.
//
// Shows: constructing timestamps from time bases and chrono durations,
// converting between time bases, comparing and printing them.
//
// Usage: api2-timestamp
#include <iostream>
#include <chrono>
#include <cassert>
#include "
avcpp/timestamp.h
"
using namespace
std
;
using namespace
av
;
int
main()
{
{
Timestamp
a = {1, {1, 1000}};
Timestamp
b = {2, {1, 3}};
auto
c = a + b;
cout << c <<
" = "
<< c.
seconds
() << endl;
auto
d = c - b;
cout << d <<
" = "
<< d.
seconds
() << endl;
auto
e = a * b;
cout << e <<
" = "
<< e.
seconds
() << endl;
auto
f = a / b;
cout << f <<
" = "
<< f.
seconds
() << endl;
auto
g =
Timestamp
{300, {1, 2}} /
Timestamp
{150, {1, 3}};
cout << g <<
" = "
<< g.
seconds
() << endl;
}
{
Timestamp
ts = std::chrono::microseconds(500);
cout << ts <<
" = "
<< ts.
seconds
() << endl;
auto
ts2 = ts + std::chrono::seconds(5);
cout << ts2 <<
" = "
<< ts2.seconds() << endl;
auto
dur1 = ts2.toDuration<std::chrono::milliseconds>();
cout << dur1.count() << endl;
auto
ts3 = std::chrono::seconds(5) + ts;
cout << ts3 <<
" = "
<< ts3.
seconds
() << endl;
}
}
av::Timestamp
The Timestamp class represents timestamp value and it timebase.
Definition
timestamp.h:25
av::Timestamp::seconds
double seconds() const noexcept
The timestamp in seconds.
av
Root namespace of the library.
Definition
audioresampler.h:19
std
STL namespace.
timestamp.h
Frame timestamps and their arithmetic.
Generated by
1.18.0