diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 14c6a61c07de70c500d52cc37c0aa58853921b39..0c6e54512ca42590e18c40117bb9eea19ac626d2 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -357,6 +357,7 @@ Value makeMediaSourceJson(MediaSource &media){ } case TrackVideo : { auto video_track = dynamic_pointer_cast(track); + video_track->flush(); obj["width"] = video_track->getVideoWidth(); obj["height"] = video_track->getVideoHeight(); obj["fps"] = round(video_track->getVideoFps()); diff --git a/src/Extension/H264.cpp b/src/Extension/H264.cpp index 3426f5cc955e261ff11d9e11c189befbdba05f8b..4587f0be57de41ff4c1f4eb2be8be24ed6950526 100644 --- a/src/Extension/H264.cpp +++ b/src/Extension/H264.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -142,6 +142,17 @@ float H264Track::getVideoFps() const { return _fps; } +void H264Track::flush() const { + int w = 0; + int h = 0; + float fps = 0.0; + if(getAVCInfo(_sps, w, h, fps)){ + _width = w; + _height = h; + _fps = fps; + } +} + bool H264Track::ready() { return !_sps.empty() && !_pps.empty(); } diff --git a/src/Extension/H264.h b/src/Extension/H264.h index 4f7a3e90bfd27135851a7caf2feb1fd05c097346..3a202b5478239ae8422ee003b23e8ac320c325fa 100644 --- a/src/Extension/H264.h +++ b/src/Extension/H264.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -128,6 +128,7 @@ public: int getVideoHeight() const override; int getVideoWidth() const override; float getVideoFps() const override; + void flush() override; bool inputFrame(const Frame::Ptr &frame) override; private: diff --git a/src/Extension/H265.cpp b/src/Extension/H265.cpp index 8877371deaf5adadfad82a4e687263dc286b3845..6c610c96eaede052a8a774a3f6c57ffcc028d43e 100644 --- a/src/Extension/H265.cpp +++ b/src/Extension/H265.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -88,6 +88,17 @@ float H265Track::getVideoFps() const { return _fps; } +void H265Track::flush() { + int w = 0; + int h = 0; + float fps = 0.0; + if(getHEVCInfo(_vps,_sps, w, h, fps)){ + _width = w; + _height = h; + _fps = fps; + } +} + bool H265Track::ready() { return !_vps.empty() && !_sps.empty() && !_pps.empty(); } diff --git a/src/Extension/H265.h b/src/Extension/H265.h index 59913c81d6472c0fa33131c468937d20ba416179..a1b24375ded90b605b8f5a87e5f6f9b194e63fda 100644 --- a/src/Extension/H265.h +++ b/src/Extension/H265.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -150,6 +150,7 @@ public: int getVideoWidth() const override; int getVideoHeight() const override; float getVideoFps() const override; + void flush() override; bool inputFrame(const Frame::Ptr &frame) override; private: diff --git a/src/Extension/Track.h b/src/Extension/Track.h index 0bada492a3e4346d4e88076f97cc0b5fe06e2109..d09c989a0d86b64b9b444026ccc26b80371893a9 100644 --- a/src/Extension/Track.h +++ b/src/Extension/Track.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -92,6 +92,12 @@ public: * 返回视频fps */ virtual float getVideoFps() const {return 0;}; + + /** + * 刷新宽高帧率 + */ + + virtual void flush() {return;}; }; /**