Skip to content

Commit 2d32561

Browse files
committed
3.1.0
1. Fix some bugs caused by av_log. 2. Update the readme file.
1 parent d0a6f87 commit 2d32561

File tree

8 files changed

+32
-28
lines changed

8 files changed

+32
-28
lines changed

MpegCoder.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26730.16
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31410.357
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpegCoder", "MpegCoder\MpegCoder.vcxproj", "{57C5DB39-2AA7-40DD-B7E1-162B3E7F7044}"
77
EndProject

MpegCoder/MpegCoder.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ int cmpc::CMpegDecoder::_SaveFrame(PyObject *PyFrameList, AVFrame *&frame, AVFra
469469
str_data << "video_frame" << (cached ? "(cached)" : "") << " n:" << PVideoFrameCount <<
470470
" coded_n:" << frame->coded_picture_number << endl;
471471
auto str_data_s = str_data.str();
472-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
472+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
473473
}
474474

475475
/* copy decoded frame to destination buffer:
@@ -556,7 +556,7 @@ int cmpc::CMpegDecoder::_SaveFrameForGOP(PyObject *PyFrameList, AVFrame *&frame,
556556
str_data << "video_frame" << (cached ? "(cached)" : "") << " n:" << PVideoFrameCount <<
557557
" coded_n:" << frame->coded_picture_number << endl;
558558
auto str_data_s = str_data.str();
559-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
559+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
560560
}
561561

562562
/* copy decoded frame to destination buffer:
@@ -680,7 +680,7 @@ bool cmpc::CMpegDecoder::ExtractGOP(PyObject* PyFrameList) {
680680
std::ostringstream str_data;
681681
str_data << "Demuxing video from file '" << videoPath << "' into Python-List" << endl;
682682
auto str_data_s = str_data.str();
683-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
683+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
684684
}
685685

686686
/* Reset the contex to remove the flushed state. */
@@ -743,7 +743,7 @@ bool cmpc::CMpegDecoder::ExtractGOP(PyObject* PyFrameList) {
743743
std::ostringstream str_data;
744744
str_data << "Succeed in convert GOP into Python_List, got " << count << " frames." << endl;
745745
auto str_data_s = str_data.str();
746-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
746+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
747747
}
748748

749749
//av_free(RGBbuffer);
@@ -792,7 +792,7 @@ bool cmpc::CMpegDecoder::ExtractFrame(PyObject* PyFrameList, int64_t framePos, i
792792
std::ostringstream str_data;
793793
str_data << "Demuxing video from file '" << videoPath << "' into Python-List" << endl;
794794
auto str_data_s = str_data.str();
795-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
795+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
796796
}
797797

798798
/* Reset the contex to remove the flushed state. */
@@ -852,7 +852,7 @@ bool cmpc::CMpegDecoder::ExtractFrame(PyObject* PyFrameList, int64_t framePos, i
852852
std::ostringstream str_data;
853853
str_data << "Succeed in convert frames into Python_List" << endl;
854854
auto str_data_s = str_data.str();
855-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
855+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
856856
}
857857

858858
if (frameRGB) {
@@ -1037,7 +1037,7 @@ void cmpc::CMpegEncoder::__log_packet(){
10371037
str_data << "pts:" << av_ts2str(Ppacket->pts) << " pts_time:" << av_ts2timestr(Ppacket->pts, time_base)
10381038
<< " dts:" << av_ts2str(Ppacket->dts) << " dts_time:" << av_ts2timestr(Ppacket->dts, time_base) << endl;
10391039
auto str_data_s = str_data.str();
1040-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1040+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
10411041
}
10421042

10431043
int cmpc::CMpegEncoder::__write_frame(){
@@ -1299,7 +1299,7 @@ int cmpc::CMpegEncoder::__avcodec_encode_video2(AVCodecContext *enc_ctx, AVPacke
12991299
std::ostringstream str_data;
13001300
str_data << "Send frame " << frame->pts << endl;
13011301
auto str_data_s = str_data.str();
1302-
av_log(nullptr, AV_LOG_DEBUG, str_data_s.c_str());
1302+
av_log(nullptr, AV_LOG_DEBUG, "%s", str_data_s.c_str());
13031303
}
13041304
}
13051305
else{
@@ -1321,7 +1321,7 @@ int cmpc::CMpegEncoder::__avcodec_encode_video2(AVCodecContext *enc_ctx, AVPacke
13211321
std::ostringstream str_data;
13221322
str_data << "Write packet " << pkt->pts << " (size=" << pkt->size << "), ";
13231323
auto str_data_s = str_data.str();
1324-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1324+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
13251325
}
13261326

13271327
if (!ret) {
@@ -1342,7 +1342,7 @@ int cmpc::CMpegEncoder::__avcodec_encode_video2_flush(AVCodecContext *enc_ctx, A
13421342
std::ostringstream str_data;
13431343
str_data << "Flush all packets" << endl;
13441344
auto str_data_s = str_data.str();
1345-
av_log(nullptr, AV_LOG_DEBUG, str_data_s.c_str());
1345+
av_log(nullptr, AV_LOG_DEBUG, "%s", str_data_s.c_str());
13461346
}
13471347

13481348
ret = avcodec_send_frame(enc_ctx, nullptr);
@@ -1361,7 +1361,7 @@ int cmpc::CMpegEncoder::__avcodec_encode_video2_flush(AVCodecContext *enc_ctx, A
13611361
std::ostringstream str_data;
13621362
str_data << "Write packet " << pkt->pts << " (size=" << pkt->size << "), ";
13631363
auto str_data_s = str_data.str();
1364-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1364+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
13651365
}
13661366
if (!ret) {
13671367
wfret = __write_frame();
@@ -1862,7 +1862,7 @@ void cmpc::CMpegEncoder::FFmpegClose(){
18621862
std::ostringstream str_data;
18631863
str_data << "All frames are flushed from cache, the video would be closed." << endl;
18641864
auto str_data_s = str_data.str();
1865-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1865+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
18661866
}
18671867
}
18681868
if (PFormatCtx) {

MpegCoder/MpegCoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define MPEGCODER_DEBUG
1313

14-
// 此类导出自 MpegCoder.dll
14+
// Exported from MpegCoder.dll
1515
namespace cmpc {
1616

1717
extern int8_t __dumpControl;

MpegCoder/MpegCoder.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
<ItemGroup>
184184
<None Include="..\.gitattributes" />
185185
<None Include="..\.gitignore" />
186+
<None Include="..\CHANGELOG.md" />
186187
<None Include="..\LICENSE" />
187188
<None Include="..\README.md" />
188189
</ItemGroup>

MpegCoder/MpegCoder.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
<None Include="..\LICENSE" />
5757
<None Include="..\.gitignore" />
5858
<None Include="..\.gitattributes" />
59+
<None Include="..\CHANGELOG.md" />
5960
</ItemGroup>
6061
</Project>

MpegCoder/MpegStreamer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ int cmpc::CMpegClient::__save_frame(AVFrame *&frame, AVPacket *&pkt, bool &got_f
333333
str_data << "video_frame" << (cached ? "(cached)" : "") << " n:" << PVideoFrameCount <<
334334
" coded_n:" << frame->coded_picture_number << endl;
335335
auto str_data_s = str_data.str();
336-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
336+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
337337
}
338338

339339
/* copy decoded frame to destination buffer:
@@ -371,7 +371,7 @@ void cmpc::CMpegClient::__client_holder() {
371371
std::ostringstream str_data;
372372
str_data << "Demuxing video from address '" << videoPath << "' into Python-List" << endl;
373373
auto str_data_s = str_data.str();
374-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
374+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
375375
}
376376

377377
/* Reset the contex to remove the flushed state. */
@@ -420,7 +420,7 @@ void cmpc::CMpegClient::__client_holder() {
420420
std::ostringstream str_data;
421421
str_data << "End of stream client." << endl;
422422
auto str_data_s = str_data.str();
423-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
423+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
424424
}
425425

426426
if (frame) {
@@ -1150,7 +1150,7 @@ void cmpc::CMpegServer::__log_packet() {
11501150
str_data << "pts:" << av_ts2str(Ppacket->pts) << " pts_time:" << av_ts2timestr(Ppacket->pts, time_base)
11511151
<< " dts:" << av_ts2str(Ppacket->dts) << " dts_time:" << av_ts2timestr(Ppacket->dts, time_base) << endl;
11521152
auto str_data_s = str_data.str();
1153-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1153+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
11541154
}
11551155

11561156
int cmpc::CMpegServer::__write_frame() {
@@ -1420,7 +1420,7 @@ int cmpc::CMpegServer::__avcodec_encode_video2(AVCodecContext* enc_ctx, AVPacket
14201420
std::ostringstream str_data;
14211421
str_data << "Send frame " << frame->pts << endl;
14221422
auto str_data_s = str_data.str();
1423-
av_log(nullptr, AV_LOG_DEBUG, str_data_s.c_str());
1423+
av_log(nullptr, AV_LOG_DEBUG, "%s", str_data_s.c_str());
14241424
}
14251425
}
14261426
else {
@@ -1442,7 +1442,7 @@ int cmpc::CMpegServer::__avcodec_encode_video2(AVCodecContext* enc_ctx, AVPacket
14421442
std::ostringstream str_data;
14431443
str_data << "Write packet " << pkt->pts << " (size=" << pkt->size << "), ";
14441444
auto str_data_s = str_data.str();
1445-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1445+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
14461446
}
14471447

14481448
if (!ret) {
@@ -1463,7 +1463,7 @@ int cmpc::CMpegServer::__avcodec_encode_video2_flush(AVCodecContext* enc_ctx, AV
14631463
std::ostringstream str_data;
14641464
str_data << "Flush all packets" << endl;
14651465
auto str_data_s = str_data.str();
1466-
av_log(nullptr, AV_LOG_DEBUG, str_data_s.c_str());
1466+
av_log(nullptr, AV_LOG_DEBUG, "%s", str_data_s.c_str());
14671467
}
14681468

14691469
ret = avcodec_send_frame(enc_ctx, nullptr);
@@ -1482,7 +1482,7 @@ int cmpc::CMpegServer::__avcodec_encode_video2_flush(AVCodecContext* enc_ctx, AV
14821482
std::ostringstream str_data;
14831483
str_data << "Write packet " << pkt->pts << " (size=" << pkt->size << "), ";
14841484
auto str_data_s = str_data.str();
1485-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
1485+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
14861486
}
14871487
if (!ret) {
14881488
wfret = __write_frame();
@@ -2084,7 +2084,7 @@ void cmpc::CMpegServer::FFmpegClose() {
20842084
std::ostringstream str_data;
20852085
str_data << "All frames are flushed from cache, the video would be closed." << endl;
20862086
auto str_data_s = str_data.str();
2087-
av_log(nullptr, AV_LOG_INFO, str_data_s.c_str());
2087+
av_log(nullptr, AV_LOG_INFO, "%s", str_data_s.c_str());
20882088
}
20892089
}
20902090
__start_time = 0;

MpegCoder/stdafx.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
#include "targetver.h"
99

1010
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
11-
// Windows 头文件:
12-
#define _CRT_SECURE_NO_WARNINGS
11+
// Numpy header:
1312
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
13+
// Windows header:
14+
#define _CRT_SECURE_NO_WARNINGS
1415
#include <windows.h>
1516

1617

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FFmpeg-Encoder-Decoder-for-Python
22

3-
This is a mpegcoder adapted from FFmpeg & Python-c-api. Using it you could get access to processing video easily. Just use it as a common module in python like this.
3+
This is a mpegCoder adapted from FFmpeg & Python-c-api. Using it you could get access to processing video easily. Just use it as a common module in python like this.
44

55
```python
66
import mpegCoder
@@ -9,7 +9,7 @@ import mpegCoder
99
| Branch | Description |
1010
| :-------------: | :-----------: |
1111
| `master` :link: | The source project of `mpegCoder`, Windows version. |
12-
| `master-linux` :link: | The source project of `mpegCoder`, Linux version. |
12+
| [`master-linux` :link:][git-linux] | The source project of `mpegCoder`, Linux version. |
1313
| [`example-client-check` :link:][exp1] | A testing project of the online video stream demuxing. |
1414
| [`example-client-player` :link:][exp2] | A testing project of the simple online video stream player. |
1515

@@ -69,5 +69,6 @@ Current FFMpeg version is `4.4`.
6969
| `libswresample` | `3.9.100.0` |
7070
| `libswscale` | `5.9.100.0` |
7171

72+
[git-linux]:https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/tree/master-linux "master (Linux)"
7273
[exp1]:https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/tree/example-client-check "check the client"
7374
[exp2]:https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/tree/example-client-player "client with player"

0 commit comments

Comments
 (0)