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

Update args builder to respect WithAudio #3

Merged
merged 7 commits into from
Jan 12, 2024

Conversation

rafiramadhana
Copy link
Contributor

Resolves #1

Update args to respect WithAudio.
@mauricioabreu
Copy link
Collaborator

mauricioabreu commented Jan 10, 2024

@rafiramadhana did you run the tests?
I've just set up a test workflow. Would you mind to run the tests locally and rebase your branch with the main branch?

@rafiramadhana
Copy link
Contributor Author

@rafiramadhana did you run the tests?

I only run the package's unit test

@rafiramadhana
Copy link
Contributor Author

I've just set up a test workflow. Would you mind to run the tests locally and rebase your branch with the main branch?

ok, I will take a look

@rafiramadhana
Copy link
Contributor Author

@mauricioabreu

the test runs fine on my local

➜  mosaic-video git:(1-with-audio-field) ✗ go test -v ./...
?   	github.com/mauricioabreu/mosaic-video	[no test files]
?   	github.com/mauricioabreu/mosaic-video/cmd	[no test files]
?   	github.com/mauricioabreu/mosaic-video/internal/config	[no test files]
?   	github.com/mauricioabreu/mosaic-video/internal/locking	[no test files]
?   	github.com/mauricioabreu/mosaic-video/internal/logging	[no test files]
?   	github.com/mauricioabreu/mosaic-video/internal/mocks	[no test files]
?   	github.com/mauricioabreu/mosaic-video/internal/mosaic/command	[no test files]
?   	github.com/mauricioabreu/mosaic-video/internal/uploader	[no test files]
=== RUN   TestBuildFFMPEGCommand
=== RUN   TestBuildFFMPEGCommand/Multiple_URLs_with_audio
=== RUN   TestBuildFFMPEGCommand/Multiple_URLs_without_audio
--- PASS: TestBuildFFMPEGCommand (0.00s)
    --- PASS: TestBuildFFMPEGCommand/Multiple_URLs_with_audio (0.00s)
    --- PASS: TestBuildFFMPEGCommand/Multiple_URLs_without_audio (0.00s)
=== RUN   TestGenerateMosaic
--- PASS: TestGenerateMosaic (0.00s)
PASS
ok  	github.com/mauricioabreu/mosaic-video/internal/mosaic	0.004s
=== RUN   TestGenerateMosaicWhenLockingFails
--- PASS: TestGenerateMosaicWhenLockingFails (0.00s)
=== RUN   TestGenerateMosaicWhenExecutingCommandFails
--- PASS: TestGenerateMosaicWhenExecutingCommandFails (0.00s)
PASS
ok  	github.com/mauricioabreu/mosaic-video/internal/worker	(cached)

@mauricioabreu
Copy link
Collaborator

I see the problem @rafiramadhana

We are using ElementsMatch from assert. It is not a good option here because the order of the parameters matter when we talk about FFMPEG. I think we need to change the way we assert the command is right (parameters, order, etc)

@rafiramadhana
Copy link
Contributor Author

i see, wdyt about this?

i think if we are not planning to add more args (frequently in the near future), this is good enough

args := []string{
	"-loglevel", "error",
	"-i", cfg.StaticsPath + "/background.jpg",
	"-i", m.Medias[0].URL,
	"-i", m.Medias[1].URL,
	"-filter_complex", filterComplex,
	"-map", "[mosaico]",
}

if m.WithAudio {
	args = append(args, "-map", "1:a")
}

args = append(args, []string{
	"-c:v", "libx264",
	"-x264opts", "keyint=30:min-keyint=30:scenecut=-1",
	"-preset", "ultrafast",
	"-threads", "0",
	"-r", "24",
	"-c:a", "copy",
	"-f", "hls",
	"-hls_playlist_type", "event",
	"-hls_time", "5",
	"-strftime", "1",
	"-hls_segment_filename", segmentPattern,
	"-method", "PUT",
	"-http_persistent", "1",
	"-sc_threshold", "0",
	fmt.Sprintf("http://localhost:8080/%s", playlistPath),
}...)

return args

for the unit test, I will update them to also assert the args ordering

@mauricioabreu
Copy link
Collaborator

@rafiramadhana yes, this is good enough.

@rafiramadhana
Copy link
Contributor Author

@rafiramadhana yes, this is good enough.

ready for review

@mauricioabreu
Copy link
Collaborator

@rafiramadhana thank you!

@mauricioabreu
Copy link
Collaborator

@rafiramadhana tests are failing. Could you check why?

@rafiramadhana
Copy link
Contributor Author

@rafiramadhana tests are failing. Could you check why?

updated, ready to review

@mauricioabreu
Copy link
Collaborator

@rafiramadhana tests are still failing as you can see in the logs. Could you check why?

@rafiramadhana
Copy link
Contributor Author

@rafiramadhana tests are still failing as you can see in the logs. Could you check why?

ah sry, i've pushed the fix. thanks!

@mauricioabreu
Copy link
Collaborator

Thank you @rafiramadhana
merged

@mauricioabreu mauricioabreu merged commit 09463dd into learn-video:main Jan 12, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

Extract audio only when mosaic is set to have audio support
2 participants