fix: copy audio stream

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-05-28 12:37:06 +07:00
parent 769d00023c
commit 69cdad3154
3 changed files with 11 additions and 6 deletions
+4 -4
View File
@@ -76,8 +76,8 @@ func BuildAudioCommand(opts *Options) []string {
// BuildRawVideoCommand returns an extremely lightweight ffmpeg command for converting raw video without extra cost.
func BuildRawVideoCommand(opts *Options) []string {
return append(buildCommonComamnd(opts),
"-c:v",
"copy",
"-c:a", "copy", // Copy audio stream
"-c:v", "copy", // Copy video stream
"-hls_time", "5",
"-hls_flags", "split_by_time",
"-hls_list_size", "0",
@@ -101,8 +101,8 @@ func BuildScalingVideoCommand(opts *Options) []string {
for _, level := range opts.ScalingLevels {
result = append(result,
"-vf", "scale=-2:"+level[:len(level)-1],
"-c:v",
"libx264",
"-c:a", "copy", // Copy audio stream
"-c:v", "libx264",
"-preset", "veryfast",
"-crf", "23",
"-g", "60",
+2 -2
View File
@@ -31,7 +31,7 @@ func Test_BuildVideoCommand_Scaling(t *testing.T) {
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_flags split_by_time -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_flags split_by_time -hls_list_size 0 -hls_segment_filename test/1/1_%03d_480p.ts test/1/1_480p_master.m3u8`
const expected = `-threads 4 -i pipe:0 -vf scale=-2:720 -c:a copy -c:v libx264 -preset veryfast -crf 23 -g 60 -hls_time 5 -hls_flags split_by_time -hls_list_size 0 -hls_segment_filename test/1/1_%03d_720p.ts test/1/1_720p_master.m3u8 -vf scale=-2:480 -c:a copy -c:v libx264 -preset veryfast -crf 23 -g 60 -hls_time 5 -hls_flags split_by_time -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, " "))
}
@@ -45,7 +45,7 @@ func Test_BuildVideoCommand_Raw(t *testing.T) {
Level: resconv.Level("651:490"),
})
const expected = `"-threads 4 -i pipe:0 -c:v copy -hls_time 5 -hls_flags split_by_time -hls_list_size 0 -hls_segment_filename test/1/1_%03d_480p.ts test/1/1_480p_master.m3u8`
const expected = `"-threads 4 -i pipe:0 -c:a copy -c:v copy -hls_time 5 -hls_flags split_by_time -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, " "))
}
+5
View File
@@ -91,6 +91,11 @@ func Test_Resconv_ShouldReturnCorrectPrefixes(t *testing.T) {
res: "2560:1440",
expected: []string{"1080p", "720p"},
},
{
name: "pixels between 1k and 2k",
res: "2880:1800",
expected: []string{"1080p", "720p"},
},
{
name: "pixels equal to 2k",
res: "3840:2160",