[Commited] [Core] SSA burn-in support

Developer discussion and patch submissions only!
Forum rules
This forum is for developer discussion and patch submission only.
Post Reply
davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

[Commited] [Core] SSA burn-in support

Post by davidfstr » Sat Aug 14, 2010 10:05 pm

Anime fans rejoice! This patch adds SSA subtitle burn-in support with libass. Therefore SSA subtitles should now be rendered in full quality, with the appropriate embedded fonts and positioning information.

Only caveat is that this patch does not support animated SSA effects (ex: karaoke, fade in/out) since the current transcoding pipeline is not really designed for it. (With animated effects, one subtitle packet could result in an effectively unbounded number of corresponding video frames, which is probably not a good idea to precalculate.) Will work on this in a subsequent patch.

As previously, if SSA passthru is selected, SSA subtitles will be converted to plain text subtitles, losing all styling and animation effects.

Patch:
http://handbrake.fr/pastebin/pastebin.php?show=1578

New contrib modules: (Now on rocky)
* libass-0.9.9.tar.bz2
** fontconfig-2.8.0.tar.gz
*** libxml2-2.7.7.tar.gz
** freetype-2.3.9.tar.gz

Description:

Code: Select all

SSA burn-in support with libass.
Contributed by davidfstr.

User avatar
Ritsuka
HandBrake Team
Posts: 875
Joined: Fri Jan 12, 2007 11:29 am

Re: [Patch] [Core] SSA burn-in support

Post by Ritsuka » Sun Aug 15, 2010 7:46 am

For some reason I always get this error:
configure: error: You must have freetype installed; see http://www.freetype.org/
make[1]: *** [contrib/fontconfig/.stamp.configure] Error 1
make[1]: *** Waiting for unfinished jobs....

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Sun Aug 15, 2010 9:34 pm

Ritsuka wrote:configure: error: You must have freetype installed; see http://www.freetype.org/
Did you reproduce this on a clean checkout? (Or 'make xclean'?)

If so, then there may be an undeclared dependency issue:

Try the following commands individually (in order). Does the error appear on any one of them (and if so, which)?
* make libxml2
* make fontconfig
* make freetype
* make libass

If no error, try these targets:
* make libxml2.install
* make fontconfig.install
* make freetype.install
* make libass.install

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: [Patch] [Core] SSA burn-in support

Post by dynaflash » Tue Aug 17, 2010 1:49 pm

davidfstr wrote:
Ritsuka wrote:configure: error: You must have freetype installed; see http://www.freetype.org/
Did you reproduce this on a clean checkout? (Or 'make xclean'?)

If so, then there may be an undeclared dependency issue:

Try the following commands individually (in order). Does the error appear on any one of them (and if so, which)?
* make libxml2
* make fontconfig
* make freetype
* make libass

If no error, try these targets:
* make libxml2.install
* make fontconfig.install
* make freetype.install
* make libass.install
Same Issue here. In following your test instructions:
* make libxml2 "BUILD SUCCEEDED"
* make fontconfig "BUILD FAILED"

Pastebin of complete make fontconfig results: http://handbrake.fr/pastebin/pastebin.php?show=1580

Here is where the issue lies I think:

Code: Select all

configure: WARNING: Cannot find usable expat library. Trying to use libxml2 as fallback.
checking for pkg-config... no
checking for LIBXML2... configure: error: in `/Users/Joe/Projects/Handbrake/current_ssa/build/contrib/fontconfig/fontconfig-2.8.0':
configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details.
make[1]: *** [contrib/fontconfig/.stamp.configure] Error 1
Command /bin/sh failed with exit code 2
Command /bin/sh failed with exit code 2
** BUILD FAILED **


The following build commands failed:
external:
	ExternalBuildToolExecution external
(1 failure)

make: *** [__goals__] Error 1

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Wed Aug 18, 2010 7:31 am

I think I see the problem. The configure rules for fontconfig depend on the use of pkg-config to determine how to link against libxml2. However pkg-config is not included in the HandBrake build system. It happens to be installed in my system's PATH, so I didn't notice.

I will manually set the LIBXML2_CFLAGS and LIBXML2_LIBS variables to the correct values to remove the dependency of libxml2. But tomorrow - is quite late today.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Thu Aug 19, 2010 1:15 am

Here's the fix. Patch no longer relies on the presence of pkg-config.

http://handbrake.fr/pastebin/pastebin.php?show=1581

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: [Patch] [Core] SSA burn-in support

Post by dynaflash » Thu Aug 19, 2010 2:16 pm

now make libass fails.

pastebin of complete libass build: http://handbrake.fr/pastebin/pastebin.php?show=1582

Looks like its in this snippet below:

Code: Select all

checking for FREETYPE... configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables FREETYPE_CFLAGS
and FREETYPE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details.
make[1]: *** [contrib/libass/.stamp.configure] Error 1
Command /bin/sh failed with exit code 2
Command /bin/sh failed with exit code 2
** BUILD FAILED **


The following build commands failed:
external:
	ExternalBuildToolExecution external
(1 failure)

make: *** [__goals__] Error 1

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Fri Aug 20, 2010 5:51 am

Heh. I updated the libass module options, but the default configure script has a bug: if pkg-config is not installed, the overriding FREETYPE_CFLAGS and FREETYPE_LIBS variables aren't even checked. The fontconfig configure script does not have this bug. :roll:

So I'm probably going to have to generate a patch for the configure script so that it picks up the variables correctly. Or forcefully regenerate it upon build, but that might be slow.

P.S. Inception (http://en.wikipedia.org/wiki/Inception_(film)) is an amazing film. I think I ran out of adrenaline.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Fri Aug 20, 2010 6:57 am

Should have all uses of pkg-config knocked out now. I removed it from my path entirely.

New patch: http://handbrake.fr/pastebin/pastebin.php?show=1584

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: [Patch] [Core] SSA burn-in support

Post by dynaflash » Fri Aug 20, 2010 1:29 pm

Builds fine here now. Thanks.

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: [Patch] [Core] SSA burn-in support

Post by dynaflash » Fri Aug 20, 2010 2:05 pm

However now it fails to build from within Xcode.app. Did you try to see if that worked on your setup ?

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Sat Aug 21, 2010 3:18 am

I added all of the dependencies to the Xcode project a long time ago, and it was working then.

Looks like Xcode runs a parallel build using '--jobs=2' by default, which might complicate analysis.

Probably will have to debug the Xcode build system to figure this out - which means I have to figure out how it works. Probably will be delayed another few days.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Sat Aug 21, 2010 6:27 pm

Err... I'm getting Xcode build errors on a clean working copy (svn 3489), without my patches.

Pastebin here: http://handbrake.fr/pastebin/pastebin.php?show=1589

Update: Some details:

The FFmpeg configure script is giving failures:

Code: Select all

liba52/Makefile.am:1: `CFLAGS' is a user variable, you should not override it;
liba52/Makefile.am:1: use `AM_CFLAGS' instead.
checking for ieee754_float64_t... src/Makefile.am:1: `CFLAGS' is a user variable, you should not override it;
src/Makefile.am:1: use `AM_CFLAGS' instead.
And the libsamplerate configure script is trying to use git:

Code: Select all

checking how to run the C++ preprocessor... ./version.sh: line 2: git: command not found
There may be more warnings/errors, but Xcode is suppressing them.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Mon Aug 23, 2010 1:34 am

I must be doing something wrong... I have attempted to build the following revisions in Xcode, without success.
* 2010-02-01
* 2010-06-01
* 2010-07-01
* 2010-07-20
* 2010-08-01
* 2010-08-22

Procedure I am following:
* R=<see above>; svn checkout svn://svn.handbrake.fr/HandBrake/trunk HB-$R -r {$R}
* open HB-$R/macosx/HandBrake.xcodeproj/
* Press Cmd-B to build.
* View build output in build window, summoned by Cmd-Shift-B.

Output from the 2010-02-01 build: http://handbrake.fr/pastebin/pastebin.php?show=1592

Based on output lines 2453-2472, it looks like contrib libraries aren't being built or aren't being built in the correct location.

dynaflash, under the assumption that you can successfully build the latest svn in Xcode, could you post a full Xcode build log so that I could compare it with mine?

User avatar
Rodeo
HandBrake Team
Posts: 11517
Joined: Tue Mar 03, 2009 8:55 pm

Re: [Patch] [Core] SSA burn-in support

Post by Rodeo » Mon Aug 23, 2010 1:36 am

davidfstr wrote:I must be doing something wrong...

[…]

Procedure I am following:
* R=<see above>; svn checkout svn://svn.handbrake.fr/HandBrake/trunk HB-$R -r {$R}
* open HB-$R/macosx/HandBrake.xcodeproj/
* Press Cmd-B to build.
* View build output in build window, summoned by Cmd-Shift-B.
AFAIK, you need to build once from the Terminal first.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Mon Aug 23, 2010 7:12 am

Looks like my clean-room build environment was missing yasm. I'll try rebuilding again tomorrow.

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: [Patch] [Core] SSA burn-in support

Post by dynaflash » Mon Aug 23, 2010 2:52 pm

Okay, Rodeo and I both built head successfully this morning.

Here is a full log with your patch 1584 failing to build within xcode.app (remember, a vanilla install) also, bear in mind that it built fine with terminal first.

http://handbrake.fr/pastebin/pastebin.php?show=1594

It is worth noting that Rodeo built fine in xcode but said he has some custom stuff installed here is the irc log excerpt from that:

Code: Select all

[08:31am] Rodeo: davidfstr: this quick discussion may help you
[08:31am] Rodeo: let me try that with the patch applied now
[08:34am] Rodeo: patched, terminal rebuild worked, now trying xcode
[08:35am] dynaflash: yep, terminal works fine
[08:36am] Rodeo: 4 errors, 125 warnings, continue: HB launches
[08:36am] Rodeo: that's with patch 1584
[08:36am] dynaflash: hmm
[08:36am] dynaflash: using standard config ?
[08:36am] Rodeo: yes
[08:36am] Rodeo: I do have a few extras installed, like pkg-config and such
[08:37am] dynaflash: well, that is not in a vanilla setup 
The part about pkg-config stood out.

User avatar
Rodeo
HandBrake Team
Posts: 11517
Joined: Tue Mar 03, 2009 8:55 pm

Re: [Patch] [Core] SSA burn-in support

Post by Rodeo » Mon Aug 23, 2010 6:15 pm

I, on the contrary, can build fine in Xcode with the latest patch (http://handbrake.fr/pastebin/pastebin.php?show=1584).

It seems my configuration was fairly different than what dynaflash and Ritsuka are using, so I did the following: remove all Macports-installed commands (left macPorts installed, but checked that the commands - including pkg-config - were no longer in my path); then removed the Mono Framework and all associated files, including those in /usr/bin (e.g. another pkg-config); finally, installed yasm 1.1.0 and git 1.7.2.2 from source, downloaded from their respective official websites:

http://www.tortall.net/projects/yasm/wiki/Download
http://git-scm.com/download

Here's what I do to build HB in Xcode:

1. clean checkout (svn3490)

2. apply patch

3. build from Terminal (./configure --launch --launch-jobs=8)

4. open macosx/HandBrake.xcodeproj/

5. click Build and Run

6. when the GDB window comes up, click Continue

At this point, HandBrake launches successfully.

Here's my Xcode build log: http://handbrake.fr/pastebin/pastebin.php?show=1595

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Tue Aug 24, 2010 7:24 am

Finally got a consistent procedure for building Xcode in my clean-room environment (which lacks pkg-config and most other tools).

* svn checkout svn://svn.handbrake.fr/HandBrake/trunk HB-edge
* cd HB-edge
* patch -p0 < ~/Desktop/ssapatch.diff
* cd macosx
* xcodebuild

And this works for me, generating the HandBrake binary as expected.

dynaflash, are you still having trouble with this?

User avatar
Rodeo
HandBrake Team
Posts: 11517
Joined: Tue Mar 03, 2009 8:55 pm

Re: [Patch] [Core] SSA burn-in support

Post by Rodeo » Tue Aug 24, 2010 9:06 am

davidfstr wrote:* xcodebuild
So you still can't build it from the GUI? AFAICT building from the command line also calls xcodebuild, so I'm not sure that conts as "building from within Xcode". Also, did you use a configure command at all?

Can you try the steps I outlined in my post without your patch first (i.e. steps 1 and 3-6)?

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: [Patch] [Core] SSA burn-in support

Post by dynaflash » Tue Aug 24, 2010 1:15 pm

As Rodeo said, command line works fine. It building from within the Xcode gui itself via /macosx/HandBrake.xcodeproj which is used a lot by macgui devs to make changes and doing a "Build and Run" via the Xcode.app gui.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Wed Aug 25, 2010 3:57 am

Finally have a repro. Explicitly building x86_64 causes a failure. (My clean-room build machine is i386.)

Rodeo: I can build successfully in the Xcode GUI (on my native i386 arch) using this procedure:
* svn checkout svn://svn.handbrake.fr/HandBrake/trunk -r 3490 HB-svn3490
* cd HB-svn3490
* patch -p0 < ~/Desktop/temp.diff
* open macosx/HandBrake.xcodeproj
* [Click "Build and Go"]

Am investigating the x86_64 error. Preliminary results suggest that libass isn't even getting built for some reason.

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [Patch] [Core] SSA burn-in support

Post by davidfstr » Wed Aug 25, 2010 4:43 am

Apparently fontconfig's configure script is not very friendly to cross-compiles. I have now fed it the correct arguments, but now there is another problem...

fontconfig is apparently building and then running some programs of its own during the build process. During a cross-compile, these intermediate programs are cross-compiled as well, which means they break when you try running them on the native architecture. This will probably take a while to sort out.

User avatar
JohnAStebbins
HandBrake Team
Posts: 4953
Joined: Sat Feb 09, 2008 7:21 pm

Re: [Patch] [Core] SSA burn-in support

Post by JohnAStebbins » Wed Aug 25, 2010 3:57 pm

Ouch! I do something similar when building the gtk UI. But I make sure to use the native compiler for the parts that must be native. Maybe you can write a small simple makefile that handbrake can call to pre-build the native parts for fontconfig.

Unfortunately, I don't know the right way to do this with autoconf. I cheated and used handbrakes build system for the native parts and autoconf for the rest of the gtk ui.

User avatar
JohnAStebbins
HandBrake Team
Posts: 4953
Joined: Sat Feb 09, 2008 7:21 pm

Re: [Patch] [Core] SSA burn-in support

Post by JohnAStebbins » Wed Aug 25, 2010 5:47 pm

This made me curious about how to do this sort of thing with autoconf, so I looked it up. Accepted practice is to define a variable CC_FOR_BUILD in configure.ac (or configure.in), and use that in Makefile.am. If other libs are needed you may have to add some additional variables for native cflags and libs. I had to do all of the above for the gtk ui. Checked those changes in if your interested in seeing an example.

Post Reply