Upload HLS playlist manifest file and media segment files to GCP directly

0 votes

I am working on VOD feature and for the past few days I am unable to output generated HLS playlist and files to GCP. I am using fluent-ffmpeg for uploading hls playlist to GCP. Here is the test code environment for uploading HLS to GCP using Node.js

const path = require('path');
const { Storage } = require('@google-cloud/storage');
const { createHLSPlaylist } = require('./utils/ffmpeg');

//* Creates a client, keyFileName is link to service account authentication credentials
const storage = new Storage({
  keyFilename: path.join(
    __dirname,
    './config/FILE.json'
  ),
  projectId: process.env.GCP_PROJECT_ID,
});

//* To be used in upload GCP videos controller (copy this file contents within controller)
const url = 'URL';
const bucket = storage.bucket('BUCKETNAME');
const playlistName = 'file.m3u8';

const newFile = bucket.file(playlistName);

createHLSPlaylist(url, newFile.createWriteStream());

and here is the ffmpeg code that transcodes video in url to hls playlist

const ffmpeg = require('fluent-ffmpeg');
const ffmpegInstaller = require('@ffmpeg-installer/ffmpeg');

ffmpeg.setFfmpegPath(ffmpegInstaller.path);

const createHLSPlaylist = (url, stream) => {
  const command = ffmpeg(url, { timeout: 432000 })
    .addOption([
      '-profile:v baseline',
      '-level 3.0',
      '-start_number 0',
      '-hls_time 10',
      '-hls_list_size 0',
      '-f hls',
    ])
    .on('end', (stdout, stderr) => {
      console.log('Transcoding succeeded !');
      process.exit(1);
    })
    .on('start', (commandLine) => {
      console.log('start', commandLine);
    })
    .on('codecData', (data) => {
      console.log(`Input is ${data.audio} audio with ${data.video} video`);
    })
    .on('progress', (progress) => {
      console.log(`Processing. Timemark: -> ${progress.timemark}`);
    })
    .on('stderr', (stderrLine) => {
      // do nothing
    })
    .on('error', (err, stdout, stderr) => {
      console.log(`error1: ${err}`);
      console.log(`error2: ${stdout}`);
      console.log(`error3: ${stderr}`);
      console.log(`Cannot process video: ${err.message}`);
    })
    .on('data', (chunk) => {
      console.log(`ffmpeg just wrote ${chunk.length} bytes`);
    })
    .pipe(stream, { end: true }); //end = true, close output stream after writing
};

module.exports = {
  createHLSPlaylist,
};

I get the following messages via console.log

Processing. Timemark: -> 00:00:28.62

Processing. Timemark: -> 00:00:28.62

Processing. Timemark: -> 00:00:28.62

Processing. Timemark: -> 00:00:28.89

Transcoding succeeded !

But nothing in GCP bucket, any pointers will be appreciated

EDIT: I also converted URL to readStream and followed the following answer on github but this time no progress is showed.

Apr 7 in GCP by Rahul
• 3,380 points
273 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In GCP

–1 vote
1 answer

How to copy files between Cloud Shell and the local machine in GCP?

Hi@akhtar, You can copy files from the remote ...READ MORE

answered Nov 9, 2020 in GCP by MD
• 95,380 points
5,811 views
0 votes
1 answer

How to create a file on GCP storage?

In case you are using Cloud storage ...READ MORE

answered Nov 5, 2019 in GCP by Sirajul
• 59,190 points
1,685 views
0 votes
1 answer

How do I transfer files to a windows instance on GCP?

You could probably use Windows RDP client for ...READ MORE

answered Nov 8, 2019 in GCP by Sirajul
• 59,190 points
1,780 views
0 votes
1 answer
0 votes
2 answers

How to transfer files to GCP VM from local system?

gcloud compute scp localpath vm_instance_name:instance/path READ MORE

answered Oct 27, 2020 in GCP by anonymous
3,531 views
0 votes
1 answer
0 votes
1 answer

How to create a custom role from a YAML file in GCP?

Hi@akhtar, You can create an IAM role in ...READ MORE

answered Nov 10, 2020 in GCP by MD
• 95,380 points
484 views
0 votes
1 answer
0 votes
1 answer

ARP protocol in GCP for two VMs to communicate directly

ARP and RARP are supported. ARP lookups ...READ MORE

answered Mar 4 in GCP by Korak
• 5,820 points
156 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP