Skip to content

Commit

Permalink
more video properties on About box
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakseis committed Jan 29, 2020
1 parent 3f73f38 commit ca7b1eb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Player/Player.rc
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,16 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM
CAPTION "About Player"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,14,14,20,20,SS_REALSIZEIMAGE
ICON IDR_MAINFRAME,IDC_STATIC,9,14,21,20,SS_REALSIZEIMAGE
DEFPUSHBUTTON "OK",IDOK,284,157,50,14,WS_GROUP
LTEXT "Player, Version 1.0",IDC_STATIC,183,14,114,8,SS_NOPREFIX
LTEXT "Copyright (C) 2015-2019",IDC_STATIC,183,26,114,8
LTEXT "Icons: www.danieledesantis.net",IDC_STATIC,183,38,114,8
LTEXT "www.iconfinder.com/Rudityas",IDC_STATIC,183,50,97,8
LTEXT "YouTube: github.com/nficano/pytube",IDC_STATIC,183,62,122,8
LTEXT "github.com/jdepoix/youtube-transcript-api",IDC_STATIC,183,74,141,8
LTEXT "Pitch shifting by Stephan M. Bernsee",IDC_STATIC,183,86,141,8
LTEXT "",IDC_VIDEO_PROPERTIES,183,109,151,38
LTEXT "Player, Version 1.0",IDC_STATIC,178,14,114,8,SS_NOPREFIX
LTEXT "Copyright (C) 2015-2019",IDC_STATIC,178,26,114,8
LTEXT "Icons: www.danieledesantis.net",IDC_STATIC,178,38,114,8
LTEXT "www.iconfinder.com/Rudityas",IDC_STATIC,178,50,97,8
LTEXT "YouTube: github.com/nficano/pytube",IDC_STATIC,178,62,122,8
LTEXT "github.com/jdepoix/youtube-transcript-api",IDC_STATIC,178,74,141,8
LTEXT "Pitch shifting by Stephan M. Bernsee",IDC_STATIC,178,86,141,8
LTEXT "",IDC_VIDEO_PROPERTIES,178,109,156,48
END

IDD_DIALOGBAR_PLAYER_CONTROL DIALOGEX 0, 0, 372, 22
Expand Down
41 changes: 41 additions & 0 deletions video/ffmpegdecoder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ffmpegdecoder.h"

#include <climits>
#include <cstdint>

Expand All @@ -14,6 +15,11 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/log/trivial.hpp>

extern "C"
{
#include "libavutil/pixdesc.h"
}

#define USE_HWACCEL

// http://stackoverflow.com/questions/34602561
Expand Down Expand Up @@ -924,8 +930,43 @@ std::vector<std::string> FFmpegDecoder::getProperties()

if (m_formatContext && m_formatContext->iformat && m_formatContext->iformat->long_name)
result.push_back(m_formatContext->iformat->long_name);

if (m_videoCodec && m_videoCodec->long_name)
result.push_back(m_videoCodec->long_name);

if (m_videoStream && m_videoCodecContext)
{
const auto eps_zero = 0.000025;

double fps = 0;
if (m_videoStream->r_frame_rate.den)
fps = av_q2d(m_videoStream->r_frame_rate);

if (fps < eps_zero && m_videoStream->avg_frame_rate.den)
fps = av_q2d(m_videoStream->avg_frame_rate);

if (fps < eps_zero && m_videoStream->time_base.num && m_videoStream->time_base.den)
fps = 1.0 / av_q2d(m_videoStream->time_base);

int bpp = 0;
int depth = 0;
if (auto av_pix_fmt_desc = av_pix_fmt_desc_get(
(m_videoCodecContext->sw_pix_fmt == AV_PIX_FMT_NONE)
? m_videoCodecContext->pix_fmt : m_videoCodecContext->sw_pix_fmt))
{
bpp = av_get_bits_per_pixel(av_pix_fmt_desc);
for (int i = 0; i < av_pix_fmt_desc->nb_components; ++i)
if (av_pix_fmt_desc->comp[i].depth > depth)
depth = av_pix_fmt_desc->comp[i].depth;
}

char buffer[1000];
sprintf_s(buffer, sizeof(buffer) / sizeof(buffer[0]),
"%d / %d @ %.2f FPS %d BPP %d bits",
m_videoCodecContext->width, m_videoCodecContext->height, fps, bpp, depth);
result.push_back(buffer);
}

if (m_audioCodec && m_audioCodec->long_name)
result.push_back(m_audioCodec->long_name);

Expand Down

0 comments on commit ca7b1eb

Please # to comment.