Skip to content

Commit 914bce1

Browse files
author
Clement Champetier
committed
properties: display nan values as N/A
Same behavior as ffprobe.
1 parent d8f283c commit 914bce1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/AvTranscoder/properties/util.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "util.hpp"
22

3+
extern "C" {
4+
#include <libavutil/avutil.h>
5+
}
6+
37
#include <sstream>
48

59
namespace avtranscoder
@@ -8,6 +12,28 @@ namespace avtranscoder
812
namespace detail
913
{
1014

15+
template <>
16+
void add(PropertyVector& propertyVector, const std::string& key, const size_t& value)
17+
{
18+
std::stringstream ss;
19+
if(value == (size_t)AV_NOPTS_VALUE)
20+
ss << "N/A";
21+
else
22+
ss << value;
23+
add(propertyVector, key, ss.str());
24+
}
25+
26+
template <>
27+
void add(PropertyVector& propertyVector, const std::string& key, const float& value)
28+
{
29+
std::stringstream ss;
30+
if(value <= AV_NOPTS_VALUE || value >= AV_NOPTS_VALUE)
31+
ss << "N/A";
32+
else
33+
ss << value;
34+
add(propertyVector, key, ss.str());
35+
}
36+
1137
template <>
1238
void add(PropertyVector& propertyVector, const std::string& key, const std::string& value)
1339
{

src/AvTranscoder/properties/util.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ void add(PropertyVector& propertyVector, const std::string& key, const T& value)
4545
add(propertyVector, key, ss.str());
4646
}
4747

48+
template <>
49+
void add(PropertyVector& propertyVector, const std::string& key, const size_t& value);
50+
51+
template <>
52+
void add(PropertyVector& propertyVector, const std::string& key, const float& value);
53+
4854
template <>
4955
void add(PropertyVector& propertyVector, const std::string& key, const std::string& value);
5056

0 commit comments

Comments
 (0)