I want to convert a video link to an m3u8 file - php

I want to convert a video link to an m3u8 file That means I can give a video for the input of the link and I can watch the same video with the extension m3u8 for the output.
Please help me with this.

You should use ffpmeg and ffprobe for video converting / procesing.
try this library PHP-FFmpeg-video-streaming

Related

Laravel FFMpeg upload video and concat with request

i have problem when i upload video from (form HTML)
i use Laravel FFMpeg package
this code from my controller
$file = $request->file('video'); // take video request
FFMpeg::fromDisk('public')
->open(['vid\vid_one.mp4' , $file]) // concat video here and i think there is a problem
->export()
->concatWithoutTranscoding()
->save('contacct.mp4');
You have to store that video on that point where you are using ffmpeg open function with this function:
$request->file('video')->storeAs('folderName', $request->video->getClientOriginalName(), 'diskName');

How to get video download link from Google Drive in PHP?

I'm trying to get the download source from a Google Drive file I own. I currently have this code:
$videoSRC = "https://www.googleapis.com/drive/v3/files/". $_GET['id']. "?alt=media&key=API_KEY_HERE";
echo '<video autoplay="" preload="auto" src="'. $videoSRC. '"></video>';
The problem is, when you look at the video source, it says the video source is "https://www.googleapis.com/drive/v3/files/GOOGLE_FILE_ID?alt=media&key=API_KEY_HERE". While it does display the video, I've seen that website have their video source as "https://redirector.googlevideo.com/videoplayback". How are they able to achieve this?
I suggest using the webContentLink of the file which is generated by using the Files.get.
Files.get uses the following URI request:
https://www.googleapis.com/drive/v3/files/fileId
Tried this on one of my file and got this webContentLink:
https://docs.google.com/uc?id=0Bzgk4zccNwI7MmJOYWs3SG1VUUE&export=download
You can pass this link in your GET request in PHP and see if it downloads the file.

PDF to Image Conversion - PHP

Note: PDF files would be uploaded by user.
I am making a document sharing website(pdf). I don't want users to be able to copy/select the pdf file text. I am looking for a nice PDF/Image Document viewer. Currently using the following method:
I am using imagemagick to convert PDF file to Jpeg. But the process is too slow even after disabling OpenMP. I was looking forward to convert full PDF to different image files but decided to just convert the first image to a thumbnail because the process is so slow.
I am using it on my local machine and it takes more than 30 seconds to convert 40-50 pages in good quality. So if there are pdf files more than 100 pages, this process would ruin the user experience.
Is there any way to convert PDF to Image files?
Also is there a way to let this process (pdf to image) happen asynchronously? Like the user filling out file details while the pdf is being uploaded and converted, something like YT videos?
Enter the command in exec() function, this will help you out
<?php
$pdf_url = 'testfile.pdf'; // Url of the PDF
$image_name = 'output.jpg'; // Set the image name
exec('convert "'.$pdf_url.'" -colorspace RGB -resize 800 "'.$image_name.'"', $output, $return_var);
?>
Hope this helps you
¿You use a linux sever?
Just use convert command and put [0] sufix to pdf file for save a cover:
exec("convert '/home/sample.pdf[0]' '/home/test.png'");

Get URL image content using php

I have a url like this.
http://www.cardekho.com/
If i wish to get all the image content(jpg,png,gif - only images) from this url to my local machine(C:\images) - How to do this..
Please help me.
Thanks -
Haan
Use either cURL or PHP function file_get_content to get the source code and the source code for the css (if you want to get background-images aswell).
Then use preg_match_all and match all the image tags.
Loop all found image paths and use cURL or file_get_content to save the image to a local destination.

How to get thumbnail snapshot of video and pdf file in php

Can anyone help me out that how i can display video and pdf file as thumbnail??
Thanks..............
For the PDF you can use Imagick.
How it's done is here in great detail
For the video snapshot, you can use FFMPEG. Here's an example code.
// this will create many images
$thumb = exec("ffmpeg -i video.mpg image%d.jpg");
Use ImageMagick's PHP class. Supports both video and PDF.

Categories