File tree 1 file changed +14
-8
lines changed
1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -169,16 +169,22 @@ export function updateCommand(e) {
169
169
inputs . push ( audio_stream ) ;
170
170
}
171
171
inputs . push ( ...subtitles ) ;
172
- if ( extension === 'mp4' ) {
173
- cmd . value = `${ options . ffmpeg_command } ${ inputs . map ( ( url ) => `-i "${ url } "` ) . join ( ' ' ) } ${ mapOutputToNumber ( inputs ) } ${ inputs . length > 2 ? '-c:s mov_text' : '' } -c:v copy -c:a copy -bsf:a aac_adtstoasc "${ output_path } "` ;
174
- } else {
175
- cmd . value = `${ options . ffmpeg_command } ${ inputs . map ( ( url ) => `-i "${ url } "` ) . join ( ' ' ) } ${ mapOutputToNumber ( inputs ) } -c:v copy -c:a copy "${ output_path } "` ;
172
+
173
+ const command = [
174
+ options . ffmpeg_command ,
175
+ ...inputs . map ( ( url ) => `-i "${ url } "` ) ,
176
+ ] ;
177
+ if ( subtitles . length > 1 ) {
178
+ // Adding -map arguments to ffmpeg makes it select all the streams from that input. https://trac.ffmpeg.org/wiki/Map
179
+ command . push ( ...inputs . map ( ( v , i ) => `-map ${ i } ` ) ) ;
176
180
}
177
- function mapOutputToNumber ( array ) {
178
- return array . length > 2
179
- ? array . map ( ( _value , index ) => `-map ${ index } ` ) . join ( ' ' )
180
- : '' ;
181
+ command . push ( '-c:v copy -c:a copy' ) ;
182
+ if ( extension === 'mp4' ) {
183
+ command . push ( '-c:s mov_text -bsf:a aac_adtstoasc' ) ;
181
184
}
185
+ command . push ( `"${ output_path } "` ) ;
186
+
187
+ cmd . value = command . join ( ' ' ) ;
182
188
}
183
189
cmd . setAttribute ( 'data-url' , url ) ;
184
190
cmd . dispatchEvent ( new Event ( 'input' ) ) ;
You can’t perform that action at this time.
0 commit comments