Closed coolguruji closed 6 years ago
Hello,
As explained by the FAQ, you need to create the config/config.yml
file and add this in it:
convert: true
avconv: path/to/avconv
i did and it works now. May i ask you one thing, I hope you'll answer me. how you are converting to mp3 files? I know you'll say ffmpeg but as i can see your script is not saving file on the server. I believe its fetching stream and converting it and giving instant download and dont save it on server. Am i right ?
Yes, we are using pipes to convert a video stream and stream directly to the browser without saving it on the server. Basically, we run something like this:
ffmpeg -i 'https://example.com/video' -f mp3 -vn pipe:1
Sound Good! This is how you can convert longer videos. I mean duration does not matters? But i believe you are running it inside a shell command as far as i know? Then how can you print / echo the stream data?
ffmpeg -i 'https://example.com/video' -f mp3 -vn pipe:1
I can set PHP headers like 👍
header('Content-Description: File Transfer');
header("Content-Type: audio/mpeg");
header('Content-Type: application/force-download');
header("Accept-Ranges: bytes");
header('Content-Transfer-Encoding: binary');
header('Content-disposition: attachment; filename="'.$title.'.mp3"');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
header("Cache-Control: private", false);
header('Pragma: no-cache');
readfile($mp3path); // pipe data
exit;
How to put that converted stream data inside php? Can you describe?
Yes, this is an efficient way to convert big videos because PHP only handles a small bit of the converted file at a time.
You should have a look at VideoDownload.php
to see how we do it.
We are running the command with popen so it returns a stream: https://github.com/Rudloff/alltube/blob/6e0464ebbeee989016e7711b3ec7d27a5f1b5404/classes/VideoDownload.php#L331
Then we can give this stream to Slim which sends it to the browser: https://github.com/Rudloff/alltube/blob/6e0464ebbeee989016e7711b3ec7d27a5f1b5404/controllers/FrontController.php#L227
(Under the hood, Slim reads the stream chunk by chunk with fread.)
Hey
You are my hero!
You saved my day. Finally i got what i was looking for from the last 4 days. I was looking for a way to get instant mp3 files without downloading it on my server. And, Your solution is perfect.
Thank you once again.
New issue
Your environment
Please answer these questions when reporting a new issue:
What is your operating system (Windows, Linux, OSX, etc.)? LINUX [Centos] What is your web server (Apache, IIS, etc.)? Apache What version of Alltube are you using? Maybe latest because i installed it today from github How did you install Alltube (with Git or with a release package)? Git What version of PHP are you using? 7.0 What version of Python are you using? Python 2.6.6 What version of youtube-dl are you using? 2018.02.04 Do you get any PHP-related errors in your webserver's logs? No What is the content of your
config/config.yml
file? File is not there, I can see config.example.html, config_test.yml, config_test_windows.yml Please provide the URL of a video that causes the issue. I can download videos by using this scriptDescribe your issue
Well, This is first time i tried to install something via composer / yarn and after solving few issues i can see it working and i downloaded a video by using this script. But, I cant see Audio only (MP3) button below the form, WHY?
I installed it to only for that purpose and now i am unhappy. Can you help?