Skip to content

Commit

Permalink
fix: Fix m4a
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjjrt committed Oct 6, 2024
1 parent 6e82aa8 commit f9190a8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export class Track implements TrackInterface {
}

public async createAudioResource() {
if (!fs.existsSync(`${MUSIC_DIR}/${this.metadata.ytId}.webm`)) {
if (!fs.existsSync(`${MUSIC_DIR}/${this.metadata.ytId}.m4a`)) {
const ytDlpWrap = new YTDlpWrap();
await ytDlpWrap
.execPromise([
`https://www.youtube.com/watch?v=${this.metadata.ytId}`,
"-o",
`${MUSIC_DIR}/%(id)s.%(ext)s`,
"--format",
"bestaudio",
"ba[ext=m4a]",
"--quiet",
"--file-access-retries",
"1",
Expand All @@ -98,10 +98,10 @@ export class Track implements TrackInterface {
throw new Error(e.message.split("Stderr:\n")[1]);
});
}
const duration = await getVideoDurationInSeconds(createReadStream(`${MUSIC_DIR}/${this.metadata.ytId}.webm`));
const duration = await getVideoDurationInSeconds(createReadStream(`${MUSIC_DIR}/${this.metadata.ytId}.m4a`));
this.startTime = new Date().getTime();
this.endTime = new Date().getTime() + duration * 1000;
return createAudioResource(createReadStream(`${MUSIC_DIR}/${this.metadata.ytId}.webm`), {
return createAudioResource(createReadStream(`${MUSIC_DIR}/${this.metadata.ytId}.m4a`), {
metadata: this,
inputType: StreamType.WebmOpus,
});
Expand Down

0 comments on commit f9190a8

Please # to comment.