kisonecat / autocut

Automatically cut off the parts of the video where I'm not speaking
GNU General Public License v3.0
18 stars 2 forks source link

How to "put the video in the corner of slides" #1

Open bremner opened 4 years ago

bremner commented 4 years ago

The commit message is tantalizing, but I didn't make it work yet. Based on guesswork, I tried

<?xml version="1.0" encoding="UTF-8"?>
<movie>
  <video src="1-1.mkv" slide="page000.png" />
  <video src="1-2.mkv" slide="page001.png" />
  <video src="1-3.mkv" />
</movie>

This produces the attached input for melt. autocut.out.txt

This has the audiotrack over the relevant slides, but no picture from the video files. For reference my melt command looks like

    melt -profile hdv_1080_30p -consumer avformat:out.avi in.xml
kisonecat commented 4 years ago

Instead of slide try overlay, so try

<?xml version="1.0" encoding="UTF-8"?>
<movie>
  <video src="1-1.mkv" overlay="page000.png" />
  <video src="1-2.mkv" overlay="page001.png" />
  <video src="1-3.mkv" />
</movie>

This adds the rescaled video to the overlay image (so it expects a black background) but other sorts of compositions are possible with melt, though they aren't exposed in the autocutter's xml.

bremner commented 4 years ago

That seems to produce the same output xml from autocut as without the overlay attributes (and unsurprisingly, the same video from melt).

I attach the media files, in case there is something special about them that breaks things. It's true the page backgrounds are not black.

example.zip

kisonecat commented 4 years ago

Yes -- try making the lower left hand corner black, and then this should work. (With this background, it is adding the video on top of white, but anything plus #fff is #fff).

bremner commented 4 years ago

Jim Fowler notifications@github.com writes:

Yes -- try making the lower left hand corner black, and then this should work. (With this background, it is adding the video on top of white, but anything plus #fff is #fff).

It seems to be a combination of a few things.

1) It really is "slide" that triggers the generation of the overlay (see line 32 of melt.py). EDIT: looking at beaudiomer.py, it looks like it is actually "overlay" there. If I'm understanding the code correctly those two should match.

2) As you say, page*.png needs to be black in the appropriate places

3) Initially I was using 4:3 beamer slides, which led to 1440x1080 output from beaudiomer. So the positioning in melt.py was outside the viewport.

4) The default cropping of 420 on each side doesn't work too well for my video samples, which are 1280x720

5) I think I needed to install frei0r-plugins to get the cairoblend plugin to work.

I guess ideally the cropping and translation should adapt to the dimensions of the video and the slide.

I can see how to manage the translation part, but I'm not too sure about cropping. It seems a bit burdensome to fix the resolution of videos used. On the other hand, so far there is no configuration for autocut.

d

bremner commented 4 years ago

I started to generalize the cropping at https://github.com/bremner/autocut/tree/new-crop.

I'll make a PR when I get rid of the hardcoding of the overlay image size to 1920x1080

kisonecat commented 4 years ago

Thank you for the PR!

It would be really nice to get this to work more flexibly (since not everyone is going to use 16:9 slides or put the video in the same spot).

One sneakier trick would be to emit a PDF annotation for the video box, so we could position the video just using TeX. (I worry that unless the video box is a bit oversized, there might be an unsightly border. Already I notice that the beamer template I'm using sometimes gets rendered by mutool with some thin lines in certain places...)