-
Notifications
You must be signed in to change notification settings - Fork 2
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avfilter: Added text2bitmap subtitle filter #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was from a quick look, I didn't look at the code closely yet.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments
3556936
to
4475081
Compare
Ok, I made the modifications suggested. I forced pushed to the same commit, I'm not sure this is how it works, I just am used to adding to the same commit because that's how ffmpeg wants it. |
a66debd
to
251582a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. Getting better and better :-)
One missing bit is a signed-off line at the bottom of the commit message.
You don't need to really sign the commits, just add this line,
I have pushed a new version which:
Once you have rebased and updated, I will apply your code locally and do some testing. |
This rebase is driving me insane. There are about 100 merge conflicts and I have no idea how to solve them. I am just solving at random. |
I know what you mean, I've been there. Shall I do it for you? |
But you have a single commit only - that's not even close to the core of rebasing hell... :-) |
Sure, if you can. It seems like I should keep the commits from your update, but that seems to be deleting a lot of documentation. I don't understand it. |
Just
You'll get a simple conflict resolution scenario then |
Cherry-pick? Is that a technical term? What does it mean? |
I know, but github only does merge, so I merge, and then I just do the rebasing on my computer. Unless there's a way to just do rebase fom Github, but I'm unaware of it. |
Yes, it's a GIT term, but in fact you just need to rebase instead of merge when pulling. So, forget my previous instructions. Instead, reset you branch to your original commit. Then pull with rebase. Which GIT client do you use? |
I just use git for linux |
I've sent you a rebased version of your path. Now, you need to reset your working branch to my most recent commit: 251582a Then you can apply your patch that I just setn on top of that via
|
I did the cherry-pick thing, do you think that's ok? It was very easy.. |
When you had exactly two conflicts (in allfilters and makefile) to solve, then you did it right and you can now force-push your branch from local to your GitHub repo |
Okay, yes I just had 2 conflicts. Thanks anyway. How come rebase is so complicated compared to cherry-pick? Isn't it basically the same thing? At least in my case. |
For testing, you can still try to apply the patch I sent you with |
I'll try that. |
rebase is not complicated, it's just The difference is that with git rebase, it tries to apply your commits on top of the updated base branch, while with merge, it tries to integrate the updated branch with commits that come AFTER your changes. |
ac3cf5e
to
cfff09a
Compare
Ok it's on the repo. |
No, the 1drv.ms link I sent via e-mail |
Watch! |
Yeah, looks dope. |
Done with a single ffmpeg command. |
Wow, that's pretty good. Glad I could be of help. By the way, big thanks for helping me through this, you've been very kind. |
I hate like many of the ffmpeg devs behave. It's all based on negativism. The best you can get is silence, which means nobody objects, and below that level, there's a huge bandwidth from justified objections to biased objections - rarely objections are coming with alternate suggestions - to "talking-to-death" behavior and finally even down to personal insults. It's nothing for the faint-of-heart, but I'm standing strong as well - for and behind the "Subtitle Filtering" addition, which is surely a major one (and it's not coming from one of their core developers, which is an irritating factor for them). This has already gone through about 30 iterations by now, and most objections have been ruled out already. |
So, for that final issue, I don't have immediate good news. But first of all - let's put all concerns in terms of making sense or being reasonable aside and see what we get in all possible cases. [E01_a.MKV] With stripstyles=0This is probably what you mean to have seen before: [E01_b.MKV] With stripstyles=1 but not dropping text subject to animation(I have temporarily added an option of this) [E01_c.MKV] Normal Operation with stripstyles=1=> No lyrics visible |
The B-file is larger than the A-file because the bitmaps created are larger. Bottom Line 1Neither A nor B is an acceptable result file. 2k subtitle bitmaps for 60k video frames is insane. VLC may play it, but normal DVD or DVB devices won't do it. Bottom Line 2If you still want to produce this kind of output, you are better off by totally disabling stripstyles. A combination of stripstyles but keeping the text doesn't make it any better - actually even worse: larger bitmaps + worse appearance Possible Solutionwould be to de-couple input and output of the filter and have a fixed-framerate output query on the filter (like textsub2video does). But for showing animations, you would still need a certain frame rate (maybe 5 fps) and when an animation is ongoing, you will have a different bitmap(-set) every 200ms. And bitmap subs are just not made for this. So, IMO, it's not worth the effort. And when you want to have it for fun working in VLC, you can still disable stripstyles. |
3b9550c
to
5007eba
Compare
I noticed a tiny parsing bug which I have fixed and pushed, so you would need to rebase once again and push the complete commit. |
Signed-off-by: softworkz <softworkz@hotmail.com>
and provide a compatibility shim for the legacy api Signed-off-by: softworkz <softworkz@hotmail.com>
…itle encoding This commit actually enables subtitle filtering in ffmpeg by sending and receiving subtitle frames to and from a filtergraph. The heartbeat functionality from the previous sub2video implementation is removed and now provided by the 'subfeed' filter. The other part of sub2video functionality is retained by auto-insertion of the new graphicsub2video filter. Justification for changed test refs: - sub2video The previous results were incorrect. The command line for this test specifies -r 5 (5 frames per second), which is now fulfilled by the additional frames in the reference output. Example: The first subtitle time is 499000, the second is 15355000, which means 0.5s and 15.35s with a difference of 14.85s. 15s * 5fps = 75 frames and that's now the exact number of video frames between these two subtitle events. - sub2video_basic The previous results had some incorrect output because multiple frames had the same dts The non-empty content frames are visually identical, the different CRC is due to the different blending algorithm that is being used. - sub2video_time_limited Subtitle frames are emitted to the filter graphs at a 5 fps rate by default. The time limit for this test is 15s * 5fps = 75 frames which matches the count in the new ref. - sub-dvb Running ffprobe -show_frames on the source file shows that there are 7 subtitle frames with 0 rects in the source at the start and 2 at the end. This translates to the 14 and 4 additional entries in the new test results. - filter-overlay-dvdsub-2397 Overlay results have slightly different CRCs due to different blending implementation - sub-scc The first entry is no longer in the output because it is before the actual start time and the strim filter removes such entries now (like for video and audio) Signed-off-by: softworkz <softworkz@hotmail.com>
The previous code expected a segment of type CLUT definition to exist in order to accept a set of segments to be complete. This was an incorrect assumption as the presence of a CLUT segment is not mandatory. (version 1.6.1 of the spec is probably a bit more clear about this than earlier versions: https://www.etsi.org/deliver/etsi_en/ 300700_300799/300743/01.06.01_20/en_300743v010601a.pdf) The flawed condition prevented proper fallback to using the default resolution for the decoding context. Signed-off-by: softworkz <softworkz@hotmail.com>
5007eba
to
5978631
Compare
Added a text2graphicsub subtitle filter which converts text-based subtitle tracks to bitmap-based subtitle tracks. The filter uses libass to render the subtitles. It takes as parameters an output height and width, as well as a number of colors in the output palette as well as sources of fonts. All its arguments are optional. Signed-off-by: tcoza <traian.coza@gmail.com>
3043511
to
5186ac0
Compare
I don't care that much about the opening subtitles anyway, so it's fine. I just thought it was weird how it used to work, but not anymore. Sure, let's submit. |
dd38501
to
a90a6e1
Compare
Done! I'm closing as I've cherry-picked your commit directly from your branch. |
davs2_decoder_close doesn't free those on the fly frames which don't get output yet. It's a design bug, but easy to workaround. Before the patch: Direct leak of 1198606 byte(s) in 2 object(s) allocated from: #0 0x563af5e1e5f0 in malloc (ffmpeg+0x6675f0) #1 0x563af9765ef3 in davs2_malloc davs2/source/common/common.h:1240 FFmpeg#2 0x563af9765ef3 in davs2_alloc_picture davs2/source/common/header.cc:815 Indirect leak of 3595818 byte(s) in 6 object(s) allocated from: #0 0x563af5e1e5f0 in malloc (ffmpeg+0x6675f0) #1 0x563af9765ef3 in davs2_malloc davs2/source/common/common.h:1240 FFmpeg#2 0x563af9765ef3 in davs2_alloc_picture davs2/source/common/header.cc:815 Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Exmaple command: ffmpeg -h filters=overlay Output: Filter overlay Overlay a video source on top of the input. slice threading supported Inputs: #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] #1: overlay (video), Formats: Dynamic, Default: [yuva420p] Outputs: #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] overlay AVOptions: [...] Signed-off-by: softworkz <softworkz@hotmail.com>
Exmaple command: ffmpeg -h filters=overlay Output: Filter overlay Overlay a video source on top of the input. slice threading supported Inputs: #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] #1: overlay (video), Formats: Dynamic, Default: [yuva420p] Outputs: #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] overlay AVOptions: [...] Signed-off-by: softworkz <softworkz@hotmail.com>
Exmaple command: ffmpeg -h filters=overlay Output: Filter overlay Overlay a video source on top of the input. slice threading supported Inputs: #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] #1: overlay (video), Formats: Dynamic, Default: [yuva420p] Outputs: #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] overlay AVOptions: [...] Signed-off-by: softworkz <softworkz@hotmail.com>
Exmaple command: ffmpeg -h filters=overlay Output: Filter overlay Overlay a video source on top of the input. slice threading supported Inputs: #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] #1: overlay (video), Formats: Dynamic, Default: [yuva420p] Outputs: #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] overlay AVOptions: [...] Signed-off-by: softworkz <softworkz@hotmail.com>
Exmaple command: ffmpeg -h filters=overlay Output: Filter overlay Overlay a video source on top of the input. slice threading supported Inputs: #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] #1: overlay (video), Formats: Dynamic, Default: [yuva420p] Outputs: #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21] overlay AVOptions: [...] Signed-off-by: softworkz <softworkz@hotmail.com>
Added a text2bitmap subtitle filter which converts text-based subtitle tracks
to bitmap-based subtitle tracks. The filter uses libass to render the subtitles.
It takes as parameters an output height and width, as well as a number of colors
in the output palette as well as sources of fonts. All its arguments are optional.