Skip to content

Commit

Permalink
Merge pull request #2 from iamstarcode/feat-add-headers-to-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Apr 20, 2024
2 parents a90cf44 + 21a9cf4 commit 800bbc8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/m3u8-convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ export async function m3u8Convert(options: M3u8DLOptions, data: TsItemInfo[]) {
if (process.platform === 'win32') filesAllArr = filesAllArr.map(d => d.replaceAll('\\', '/'));
await promises.writeFile(inputFilePath, 'ffconcat version 1.0\nfile ' + filesAllArr.join('\nfile '));

const cmd = `ffmpeg -y -f concat -safe 0 -i ${inputFilePath} -acodec copy -vcodec copy -bsf:a aac_adtstoasc "${filepath}"`;
let headersString = '';
if (options.headers) {
for (const [key, value] of Object.entries(options.headers)) {
headersString += `-headers "${key}: ${value}" `;
}
}

const cmd = `ffmpeg -y -f concat -safe 0 -i ${inputFilePath} -acodec copy -vcodec copy -bsf:a aac_adtstoasc ${headersString} "${filepath}"`;
logger.debug('[convert to mp4]cmd:', cyan(cmd));
const r = execSync(cmd);
ffmpegSupport = !r.error;
Expand Down

0 comments on commit 800bbc8

Please sign in to comment.