Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add snapshot filter mark#4571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
PioLing wants to merge5 commits intoZLMediaKit:master
base:master
Choose a base branch
Loading
fromPioLing:coding
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add code comments.
  • Loading branch information
@PioLing
PioLing committedNov 28, 2025
commitdba7de2ede5615e53a72a3ce26bdd2ecbe9dc513

Some comments aren't visible on the classic Files Changed page.

28 changes: 14 additions & 14 deletionssrc/Codec/Transcode.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -760,11 +760,11 @@ std::tuple<bool, std::string> FFmpegUtils::saveFrame(const FFmpegFrame::Ptr &fra
std::shared_ptr<AVFilterGraph> _filter_graph;
AVFilterContext *buffersrc_ctx = nullptr;
AVFilterContext *buffersink_ctx = nullptr;
const AVFilter *buffersrc;
const AVFilter *buffersink;
const string mark = "ZLMediakit";
const AVFilter *buffersrc = nullptr;
const AVFilter *buffersink = nullptr;
// kServerName
const string mark = "ZLMediakit";
char drawtext_args1[512];

_StrPrinter ss;

std::unique_ptr<FILE, void (*)(FILE *)> tmp_save_file_jpg(File::create_file(filename, "wb"), [](FILE *fp) {
Expand All@@ -773,12 +773,18 @@ std::tuple<bool, std::string> FFmpegUtils::saveFrame(const FFmpegFrame::Ptr &fra
}
});

if (!tmp_save_file_jpg) {
ss << "Could not open the file " << filename;
DebugL << ss;
return make_tuple<bool, std::string>(false, ss.data());
}

std::string fontfile("");
if (font_path && File::fileExist(font_path)) {
fontfile = font_path;
} else {
// Fallback to common system fonts
const char *common_fonts[] = { "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",
const char *common_fonts[] = { "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
"/System/Library/Fonts/Helvetica.ttc", // macOS
"C:/Windows/Fonts/arial.ttf", // Windows
nullptr };
Expand All@@ -791,15 +797,9 @@ std::tuple<bool, std::string> FFmpegUtils::saveFrame(const FFmpegFrame::Ptr &fra
}

if (!fontfile.empty()) {
snprintf(drawtext_args1, sizeof(drawtext_args1), "text='%s':fontfile='%s':fontcolor=white@0.1:fontsize=100:x=30:y=h-th-30", mark.data(), fontfile.c_str());
snprintf(drawtext_args1, sizeof(drawtext_args1), "text='%s':fontfile='%s':fontcolor=white@0.1:fontsize=50:x=30:y=h-th-30", mark.data(), fontfile.c_str());
} else {
snprintf(drawtext_args1, sizeof(drawtext_args1), "text='%s':fontcolor=white&0.1:fontsize=100:x=30:y=h-th-30", mark.data());
}

if (!tmp_save_file_jpg) {
ss << "Could not open the file " << filename;
DebugL << ss;
return make_tuple<bool, std::string>(false, ss.data());
snprintf(drawtext_args1, sizeof(drawtext_args1), "text='%s':fontcolor=white&0.1:fontsize=50:x=30:y=h-th-30", mark.data());
}

const AVCodec *jpeg_codec = avcodec_find_encoder(fmt == AV_PIX_FMT_YUVJ420P ? AV_CODEC_ID_MJPEG : AV_CODEC_ID_PNG);
Expand DownExpand Up@@ -827,7 +827,7 @@ std::tuple<bool, std::string> FFmpegUtils::saveFrame(const FFmpegFrame::Ptr &fra
FFmpegSws sws(fmt, jpeg_codec_ctx->width, jpeg_codec_ctx->height);
auto new_frame = sws.inputFrame(frame);
if (!new_frame) {
ss << "Could not scale the frame: " << ffmpeg_err(ret);
ss << "Could not scale the frame";
DebugL << ss;
return make_tuple<bool, std::string>(false, ss.data());
}
Expand Down
2 changes: 2 additions & 0 deletionssrc/Codec/Transcode.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,6 +174,8 @@ class FFmpegUtils {
* @param frame 解码后的帧
* @param filename 保存文件路径
* @param fmt jpg:AV_PIX_FMT_YUVJ420P,PNG:AV_PIX_FMT_RGB24
* @param w h 图片大小,默认和输入源一致
* @param font_path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The@param font_path documentation is incomplete. It should describe what the parameter is for (e.g., "Path to custom font file for watermark text. If not provided or invalid, falls back to system default fonts.").

Suggested change
* @paramfont_path
* @paramfont_pathPathtocustomfontfileforwatermarktext.Ifnotprovidedorinvalid,fallsbacktosystemdefaultfonts.

Copilot uses AI. Check for mistakes.
* @return
*/
static std::tuple<bool, std::string> saveFrame(const FFmpegFrame::Ptr &frame, const char *filename, AVPixelFormat fmt = AV_PIX_FMT_YUVJ420P, int w = 0, int h = 0, const char *font_path = nullptr);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp