Upload Google Drive video in JW Player and get direct link for Google Drive video

+2


source to share


6 answers


If you just want to transfer videos from google drive, it can be done - you can see a working example here:

You can see exactly how it is encoded by right clicking and checking in your browser



<video controls="controls" style="margin-bottom:20px;width:590px">    
         <source src="https://drive.google.com/uc?export=download&amp;id=0B0JMGMGgxp9WMEdWb1hyQUhlOWs" type="video/mp4"> 
</video>

      

To create a signed url for google cloud storage programmatically, you need to follow their instructions from the link below - I have not copied or summarized them here, as if an AWS mechanism like this is something that can go through this approach can often change and it is better to always check the latest official documentation:

0


source


Easy

  • Upload your video

  • Make video available for sharing

  • Open the link and watch the video, where you will find the video tag, where you can take the link to the video file.



zYpMp.png

0


source


You can try this Perl script to get a direct download link. If you want to play it in JWPlayer, you will need to run the script from the server to get the link and then paste that link into HTML.

https://circulosmeos.wordpress.com/2014/04/12/google-drive-direct-download-of-big-files/

Files hosted on Google Drive may be publicly available. However, if they are too large, Google pages advise that "Google Drive does not scan this file for viruses" and ask the user to confirm it to continue downloading.

If for any reason you are trying to auto-upload a file or download it in a resource-limited environment, this will prevent the link from being directly used.

Here is the script

https://github.com/circulosmeos/gdown.pl

However, the script downloads the file to the filesystem, so you will have to modify it, so the last time you redirect the url, you save the final url instead of downloading it.

0


source


If you have WordPress Webiste you can use GD Player WordPress Plugin works with Google Drive Mp4 etc. It can also set subtitles in videos. I use this and it works really well for me. Hope this helps.

0


source


I tried to do this, I was able to get the url, but then there was a problem streaming it from the server back to the client, basically using the puppeteer to navigate to the url, click play, wait for the video to appear, get the "src" attribute, then (somehow via XMLHttpRequest) route it back to the server, then the server (nodeJS) will route it back to the client, then use that URL to embed the video (not complete yet) see my [very humble] question on this for more details):

var puppeteer = require("puppeteer-core");
var http=require("https");
var fs=require("fs");
var fetch=require("fetch-node");
(async() => {
    var browser = await puppeteer.launch({
        executablePath:"./cobchrome/chrome.exe"
    });
    console.log("Got browser", browser);
    var page = await browser.newPage();

    console.log(page,"got page");

    await page.goto("https://docs.google.com/file/d/0B9aMNh1shw_4VUVVWkF0TjRHWTA/preview?enablejsapi=1&playerapiid=player4");
    console.log("went to page..");


    var newClickID = ".ndfHFb-c4YZDc";
    var clicker = await page.waitForSelector(newClickID);

    await page.click(newClickID);

    var frame = await page.waitForSelector("iframe[id=drive-viewer-video-player-object-0]");




    var cf = await frame.contentFrame();

    await cf.waitFor(() => !!document.querySelector("video"))

    var video = await cf.$("video");

    var videoEl = await cf.evaluate(
        v =>{
            var result = {};
            for(var k in v) {
                result[k] = v[k];
            }
            return result;
        },
        video
    );
    var src = videoEl.src;


    await page.goto(src);
    console.log("went to video page ", src);
    var file = fs.createWriteStream("output/therebbe.mp4");
        var count = 0;

    page.on("console", c => {
        var txt = (c.text()),
            buff = Buffer.from(txt,"base64");
     //   var pic = fs.createWriteStream("output/frame"+count+".png");
       // pic.write(buff);
      //  pic.end();
        console.log("Consoling ",count++, buff);
    //    file.write(buff);
    });

    await page.evaluate(() => {
        function _arrayBufferToBase64( buffer ) {
            var binary = '';
            var bytes = new Uint8Array( buffer );
            var len = bytes.byteLength;
            for (var i = 0; i < len; i++) {
                binary += String.fromCharCode( bytes[ i ] );
            }
            return window.btoa( binary );
        }
        function str2ab(str) {
            var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
            var bufView = new Uint16Array(buf);
            for (var i=0, strLen=str.length; i < strLen; i++) {
                bufView[i] = str.charCodeAt(i);
            }
            return buf;
        }

        var x = new XMLHttpRequest();
        var url = location.href;
        x.onreadystatechange = function(){
            if(x.readyState == 200) {
                console.log("done");
            } else {
                console.log(
                    _arrayBufferToBase64(
                        str2ab(x.response)
                    )
                );
            }
        }
      //  x.responseType="arraybuffer";
        x.open("GET",url,true);
        x.send("");
    });








 // await browser.close();
})();

      

0


source


Just an idea: you don't need a JW player or PHP, I've been baked in browsers all the time (HTML5). Here's an example on how to do it (using Google Material Design UI). Just old HTML / CSS / JS.

https://github.com/rhroyston/mdl-audio

-1


source







All Articles