Files
huly-platform/internal/pkg/transcoder/command_test.go
T
2025-03-16 01:00:35 +03:00

52 lines
1.9 KiB
Go

// Copyright © 2025 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
package transcoder_test
import (
"strings"
"testing"
"github.com/hcengineering/stream/internal/pkg/resconv"
"github.com/hcengineering/stream/internal/pkg/transcoder"
"github.com/stretchr/testify/require"
)
func Test_BuildVideoCommand_Scaling(t *testing.T) {
var scaleCommand = transcoder.BuildScalingVideoCommand(&transcoder.Options{
OuputDir: "test",
Input: "pipe:0",
UploadID: "1",
Threads: 4,
ScalingLevels: []string{"720p", "480p"},
})
const expected = `-threads 4 -i pipe:0 -vf scale=-2:720 -c:v libx264 -preset veryfast -crf 23 -g 60 -hls_time 5 -hls_list_size 0 -hls_segment_filename test/1/1_%03d_720p.ts test/1/1_720p_master.m3u8 -vf scale=-2:480 -c:v libx264 -preset veryfast -crf 23 -g 60 -hls_time 5 -hls_list_size 0 -hls_segment_filename test/1/1_%03d_480p.ts test/1/1_480p_master.m3u8`
require.Contains(t, expected, strings.Join(scaleCommand, " "))
}
func Test_BuildVideoCommand_Raw(t *testing.T) {
var rawCommand = transcoder.BuildRawVideoCommand(&transcoder.Options{
OuputDir: "test",
Input: "pipe:0",
UploadID: "1",
Threads: 4,
Level: resconv.Level("651:490"),
})
const expected = `"-threads 4 -i pipe:0 -c:v copy -hls_time 5 -hls_list_size 0 -hls_segment_filename test/1/1_%03d_480p.ts test/1/1_480p_master.m3u8`
require.Contains(t, expected, strings.Join(rawCommand, " "))
}