Fix multiple transcoding when track not exists

This commit is contained in:
Alexey Khit
2022-11-15 16:16:22 +03:00
parent c3da7584b0
commit e29f2594fa

View File

@@ -146,7 +146,7 @@ func Init() {
s += " -vn" s += " -vn"
case 1: case 1:
if len(query["audio"]) > 1 { if len(query["audio"]) > 1 {
s += " -map 0:v:0" s += " -map 0:v:0?"
} }
for _, video := range query["video"] { for _, video := range query["video"] {
if video == "copy" { if video == "copy" {
@@ -158,9 +158,9 @@ func Init() {
default: default:
for i, video := range query["video"] { for i, video := range query["video"] {
if video == "copy" { if video == "copy" {
s += " -map 0:v:0 -c:v:" + strconv.Itoa(i) + " copy" s += " -map 0:v:0? -c:v:" + strconv.Itoa(i) + " copy"
} else { } else {
s += " -map 0:v:0 " + strings.ReplaceAll(tpl[video], ":v ", ":v:"+strconv.Itoa(i)+" ") s += " -map 0:v:0? " + strings.ReplaceAll(tpl[video], ":v ", ":v:"+strconv.Itoa(i)+" ")
} }
} }
} }
@@ -170,7 +170,7 @@ func Init() {
s += " -an" s += " -an"
case 1: case 1:
if len(query["video"]) > 1 { if len(query["video"]) > 1 {
s += " -map 0:a:0" s += " -map 0:a:0?"
} }
for _, audio := range query["audio"] { for _, audio := range query["audio"] {
if audio == "copy" { if audio == "copy" {
@@ -182,9 +182,9 @@ func Init() {
default: default:
for i, audio := range query["audio"] { for i, audio := range query["audio"] {
if audio == "copy" { if audio == "copy" {
s += " -map 0:a:0 -c:a:" + strconv.Itoa(i) + " copy" s += " -map 0:a:0? -c:a:" + strconv.Itoa(i) + " copy"
} else { } else {
s += " -map 0:a:0 " + strings.ReplaceAll(tpl[audio], ":a ", ":a:"+strconv.Itoa(i)+" ") s += " -map 0:a:0? " + strings.ReplaceAll(tpl[audio], ":a ", ":a:"+strconv.Itoa(i)+" ")
} }
} }
} }