Message ID | 4eb92524-1a7e-d0d9-4977-328d062fb895@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 10-06-2019 09:24 PM, Jonathan Baecker wrote: > I created this issue on the bugtracker: > https://trac.ffmpeg.org/ticket/7948 > > Here is now a patch for it. drawtext should ignore the very last > newline character in text files, because many editor add automatically > a newline at the end. Some users may want to deliberately expand the box, so this should not be forced. > What do you think about this solution? > - /* skip the \n in the sequence \r\n */ > - if (prev_code == '\r' && code == '\n') > + /* skip the \n in the sequence \r\n and ignore last empty line */ > + if ((prev_code == '\r' && code == '\n') || > + (code == '\n' && i == len - 1) || > + (code == '\r' && i == len - 2)) I believe this will keep the last line on Mac-style text files. Gyan
Am 10.06.2019 um 19:14 schrieb Gyan: > > > On 10-06-2019 09:24 PM, Jonathan Baecker wrote: >> I created this issue on the bugtracker: >> https://trac.ffmpeg.org/ticket/7948 >> >> Here is now a patch for it. drawtext should ignore the very last >> newline character in text files, because many editor add >> automatically a newline at the end. > > Some users may want to deliberately expand the box, so this should not > be forced. Then you have the box double so high then it should and most of the free space under the text, but if you want this - a blank space would be enough. Anyway what would be your suggestion? It don't have to be like this, I only though it is more intuitive. > >> What do you think about this solution? > >> - /* skip the \n in the sequence \r\n */ >> - if (prev_code == '\r' && code == '\n') >> + /* skip the \n in the sequence \r\n and ignore last empty >> line */ >> + if ((prev_code == '\r' && code == '\n') || >> + (code == '\n' && i == len - 1) || >> + (code == '\r' && i == len - 2)) > > I believe this will keep the last line on Mac-style text files. Ok thanks for the hint, tomorrow I can test it on macOS and change it. > > Gyan > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 01cd7fa122..e8c33596e9 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1380,8 +1380,10 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, for (i = 0, p = text; *p; i++) { GET_UTF8(code, *p++, continue;); - /* skip the \n in the sequence \r\n */ - if (prev_code == '\r' && code == '\n') + /* skip the \n in the sequence \r\n and ignore last empty line */ + if ((prev_code == '\r' && code == '\n') || + (code == '\n' && i == len - 1) || + (code == '\r' && i == len - 2)) continue; prev_code = code;
I created this issue on the bugtracker: https://trac.ffmpeg.org/ticket/7948 Here is now a patch for it. drawtext should ignore the very last newline character in text files, because many editor add automatically a newline at the end. But when the filter draws a box behind the text, the box become to big. What do you think about this solution? From 9a4fa45a74c95d1a56a29dafe6c5c727d83c143c Mon Sep 17 00:00:00 2001 From: jonathan <jonbae77@gmail.com> Date: Mon, 10 Jun 2019 17:44:03 +0200 Subject: [PATCH] ignore last newline --- libavfilter/vf_drawtext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)