Skip to content

Commit a2b16ad

Browse files
author
Clement Champetier
committed
FileProperties: added getFileSize method
1 parent 5e5e52d commit a2b16ad

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/AvTranscoder/properties/FileProperties.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <stdexcept>
88
#include <sstream>
9+
#include <fstream>
910

1011
namespace avtranscoder
1112
{
@@ -199,6 +200,12 @@ size_t FileProperties::getBitRate() const
199200
return _avFormatContext->bit_rate;
200201
}
201202

203+
size_t FileProperties::getFileSize() const
204+
{
205+
std::ifstream in(getFilename().c_str(), std::ios::binary | std::ios::ate);
206+
return in.tellg();
207+
}
208+
202209
size_t FileProperties::getPacketSize() const
203210
{
204211
if(!_avFormatContext)

src/AvTranscoder/properties/FileProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AvExport FileProperties
4848
double getStartTime() const;
4949
float getDuration() const; ///< in seconds, 0 if not available
5050
size_t getBitRate() const; ///< total stream bitrate in bit/s, 0 if not available (result of a computation by ffmpeg)
51+
size_t getFileSize() const; ///< in bytes
5152
size_t getPacketSize() const;
5253

5354
const PropertyVector& getMetadatas() const { return _metadatas; }

0 commit comments

Comments
 (0)