Skip to content

Commit

Permalink
add: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Prajjawalk committed Apr 4, 2024
1 parent 01e8c5d commit d1dab74
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/nextjs/app/slow-fetch/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ export async function POST(req: NextRequest) {
// fetch the playback info on the server
const playbackInfo = await livepeer.playback.get(playbackId);
const videoUrl = playbackInfo.playbackInfo?.meta.source[0]?.url;
console.log(videoUrl);
// const videoUrl = downloadUrl;

// console.log("playback info ", playbackInfo.playbackInfo?.meta.source[0]);

// Download MP4 video file
const mp4FilePath = `tmp/video-${playbackId}.mp4`;
const mp4FilePath = `video-${playbackId}.mp4`;
const mp4FileStream = fs.createWriteStream(mp4FilePath);
const response = await axios.get(String(videoUrl), { responseType: "stream" });

Expand All @@ -117,7 +118,7 @@ export async function POST(req: NextRequest) {
console.log("mp4 file downloaded...");

// Convert MP4 to GIF using FFmpeg
const gifFilePath = `tmp/output-${playbackId}.gif`;
const gifFilePath = `output-${playbackId}.gif`;
await new Promise<void>((resolve, reject) => {
exec(
`npx ffmpeg -i ${mp4FilePath} -vf "fps=10,scale=320:-1:flags=lanczos" -c:v gif -loop 0 ${gifFilePath}`,
Expand Down

0 comments on commit d1dab74

Please sign in to comment.