asticode/go-astiav

Chromakey + overlay

hasnhasan opened this issue ยท 8 comments

How can I set the following code with this library?

ffmpeg -i source.mp4 -filter_complex "[0:v]chromakey=0x276100:1:0.1[out]" -map "[out]" -c:v prores -pix_fmt yuva444p10le transparent.mkv -y

ffmpeg -i transparent.mkv  -i mask.mp4 -filter_complex "[0:v][1:v]overlay[out]" -map "[out]" final.mkv -y
ffmpeg -i transparent.mkv  -i mask-2.mp4 -filter_complex "[0:v][1:v]overlay[out]" -map "[out]" final-2.mkv -y

In order not to run chroma key continuously, apply chroma key once. I need to apply later.

Check out the filtering example and specifically the filterFrame function : you can use it once to generate your chroma keyed content, and send frames in 2 different filters for you 2 different overlays.

Unfortunately, I couldn't implement it. Do you have a chance to provide a small example?

What I wanted to do was to add multiple masked videos to a live stream with just one Green Screen and display them with different live broadcasts. I am using a GPU (OVH T2-45) for this purpose. However, the method I used only supports up to 10 streams. The idea I mentioned in the previous message came to mind. Apply it after a single chroma key process.

// Create buffersrc
	chromakeysrc := astiav.FindFilterByName("chromakey")
	if chromakeysrc == nil {
		err = errors.New("main: chromakey is nil")
		return
	}

	// Create filter contexts
	if s.buffersrcContext, err = s.filterGraph.NewFilterContext(chromakeysrc, "chromakey", astiav.FilterArgs{
		"color":      "0x276100",
		"similarity": "0.060",
		"blend":      "0",
	}); err != nil {
		err = fmt.Errorf("main: creating chromakey context failed: %w", err)
		return
	}

	// Update outputs
	outputs.SetName("chromakey")
	outputs.SetFilterContext(s.buffersrcContext)
	outputs.SetPadIdx(0)
	outputs.SetNext(nil)

I won't have time to provide a specific example to your use case, however the filtering example should provide all you need: you'll need to insert your filter string here and you'll get the result of the chroma key filter here.

Thank you very much for your answer. Unfortunately, I failed in practice. Do you provide paid support in this regard?

Thank you very much for your answer. Unfortunately, I failed in practice. Do you provide paid support in this regard?

I do, but my schedule is full for the coming months.

Super. Can I have your e-mail address for planning?

I'll contact you when my schedule clears ๐Ÿ‘