Fix casting issues on times and durations (#18)

This commit is contained in:
Kévin Liagre
2022-07-12 07:07:19 +02:00
committed by GitHub
parent 9d1a14520f
commit e74891b245

View File

@@ -34,12 +34,12 @@ typedef struct Tag {
typedef struct Stream { typedef struct Stream {
int id; int id;
int start_time; float start_time;
int duration; float duration;
int codec_type; int codec_type;
std::string codec_name; std::string codec_name;
std::string format; std::string format;
int bit_rate; float bit_rate;
std::string profile; std::string profile;
int level; int level;
int width; int width;
@@ -53,8 +53,8 @@ typedef struct Stream {
typedef struct Chapter { typedef struct Chapter {
int id; int id;
std::string time_base; std::string time_base;
int start; float start;
int end; float end;
std::vector<Tag> tags; std::vector<Tag> tags;
} Chapter; } Chapter;
@@ -69,8 +69,8 @@ typedef struct Frame {
typedef struct FileInfoResponse { typedef struct FileInfoResponse {
std::string name; std::string name;
int bit_rate; float bit_rate;
int duration; float duration;
std::string url; std::string url;
int nb_streams; int nb_streams;
int flags; int flags;
@@ -83,7 +83,7 @@ typedef struct FramesResponse {
std::vector<Frame> frames; std::vector<Frame> frames;
int nb_frames; int nb_frames;
int gop_size; int gop_size;
int duration; float duration;
double time_base; double time_base;
double avg_frame_rate; double avg_frame_rate;
} FramesResponse; } FramesResponse;
@@ -116,8 +116,8 @@ FileInfoResponse get_file_info(std::string filename) {
// Initialize response struct with format data. // Initialize response struct with format data.
FileInfoResponse r = { FileInfoResponse r = {
.name = pFormatContext->iformat->name, .name = pFormatContext->iformat->name,
.bit_rate = (int)pFormatContext->bit_rate, .bit_rate = (float)pFormatContext->bit_rate,
.duration = (int)pFormatContext->duration, .duration = (float)pFormatContext->duration,
.url = pFormatContext->url, .url = pFormatContext->url,
.nb_streams = (int)pFormatContext->nb_streams, .nb_streams = (int)pFormatContext->nb_streams,
.flags = pFormatContext->flags, .flags = pFormatContext->flags,
@@ -139,12 +139,12 @@ FileInfoResponse get_file_info(std::string filename) {
Stream stream = { Stream stream = {
.id = (int)pFormatContext->streams[i]->id, .id = (int)pFormatContext->streams[i]->id,
.start_time = (int)pFormatContext->streams[i]->start_time, .start_time = (float)pFormatContext->streams[i]->start_time,
.duration = (int)pFormatContext->streams[i]->duration, .duration = (float)pFormatContext->streams[i]->duration,
.codec_type = (int)pLocalCodecParameters->codec_type, .codec_type = (int)pLocalCodecParameters->codec_type,
.codec_name = fourcc, .codec_name = fourcc,
.format = av_get_pix_fmt_name((AVPixelFormat)pLocalCodecParameters->format), .format = av_get_pix_fmt_name((AVPixelFormat)pLocalCodecParameters->format),
.bit_rate = (int)pLocalCodecParameters->bit_rate, .bit_rate = (float)pLocalCodecParameters->bit_rate,
.profile = avcodec_profile_name(pLocalCodecParameters->codec_id, pLocalCodecParameters->profile), .profile = avcodec_profile_name(pLocalCodecParameters->codec_id, pLocalCodecParameters->profile),
.level = (int)pLocalCodecParameters->level, .level = (int)pLocalCodecParameters->level,
.width = (int)pLocalCodecParameters->width, .width = (int)pLocalCodecParameters->width,
@@ -180,8 +180,8 @@ FileInfoResponse get_file_info(std::string filename) {
Chapter c = { Chapter c = {
.id = (int)chapter->id, .id = (int)chapter->id,
.time_base = buf.str, .time_base = buf.str,
.start = (int)chapter->start, .start = (float)chapter->start,
.end = (int)chapter->end, .end = (float)chapter->end,
}; };
// Add tags to chapter. // Add tags to chapter.