Skip to content
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

Audio is silent in the beginning and becomes louder at the end #283

Open
forhku opened this issue Oct 3, 2022 · 7 comments
Open

Audio is silent in the beginning and becomes louder at the end #283

forhku opened this issue Oct 3, 2022 · 7 comments

Comments

@forhku
Copy link

forhku commented Oct 3, 2022

Below is a screenshot of the waveform of the final video output (software used: wavepad). How do I fix this?
image

@drawcall
Copy link
Member

drawcall commented Oct 6, 2022

Can provide your code

@forhku
Copy link
Author

forhku commented Oct 6, 2022

Can provide your code


const creator = new FFCreator({
	cacheDir: "vid_cache",
	outputDir: chosen_folder,
	width: 720,
	height: 1280,
	parallel: 5
});

const scene = new FFScene();

const image = new FFImage({
	path: __dirname + "/" + images[0],
	scale: 0.40,
	x: 360,
	y: 640
});

const bgv = new FFVideo({
	path: "background.mp4",
	height: 1280,
	width: 720,
	x: 360,
	y: 640
})

bgv.setAudio(false)

var ff_scenes = []

scene.addChild(bgv)
scene.addChild(image)
scene.addAudio("bgm.mp3")
var audio = fs.readFileSync("vocals_1.mp3")
scene.addAudio("vocals_1.mp3")

var post_duration = (getMp3Duration(audio) / 1000) + 0.2
post_duration = parseFloat(post_duration.toFixed(2))
scene.setDuration(post_duration)
creator.addChild(scene);

var last_duration = post_duration
var total_durations = post_duration

images.forEach((image, index) => {
	if (index != 0) {
		console.log(image)
		var audio = fs.readFileSync(image +  "_audio.mp3")
		var temp_image = new FFImage({
			path: __dirname + "/" + image,
			scale: 0.40,
			x: 360,
			y: 640
		});

		var current_duration = 0

		var temp_scene = new FFScene();
		temp_scene.setDuration((getMP3Duration(audio) / 1000) + 1);
		current_duration = (getMP3Duration(audio) / 1000) + 1

		var temp_current_duration = current_duration


		console.log(total_durations)
		console.log(total_durations + current_duration)

		var temp_bgv = new FFVideo({
			path: "background.mp4",
			height: 1280,
			width: 720,
			x: 360,
			y: 640
		})
		temp_bgv.setAudio(false)

		temp_scene.addChild(temp_bgv)
		temp_scene.addChild(temp_image)

		total_durations = current_duration + total_durations

		temp_scene.addAudio(__dirname + "/" + image +  "_audio.mp3")

		ff_scenes.push(temp_scene)
	}
})


ff_scenes.forEach(ff_scene => {
	creator.addChild(ff_scene);
})

creator.start();

Here's everything that has to do with ffcreator. Changed sensitive information to generic filenames

@lczpln
Copy link

lczpln commented Jul 10, 2023

Were you able to fix it?

@Lnoorlander
Copy link

Has any of you been able to fix this? I have the same problem.

@lczpln
Copy link

lczpln commented Sep 16, 2023

@Lnoorlander #314

@Lnoorlander
Copy link

@lczpln Thanks a lot! Is there some secret documentation i missed?

@lczpln
Copy link

lczpln commented Sep 16, 2023

Idk, I’ve spent a half hour to find it lol, glad to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants