Web Analytics Made Easy -
StatCounter YouTube-to-MP3 conversion - PHP class and script - CodingForum

Announcement

Collapse
No announcement yet.

YouTube-to-MP3 conversion - PHP class and script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gioware
    replied
    Is anyone else getting hit by DMCA like crazy? For last month I receive about 4-5 takedown notices daily from Google, with 3-4 links in each

    Leave a comment:


  • chump2877
    replied
    New Version!

    Hello everyone,

    I have just finished updating the YouTube-to-Mp3 (and more!) Converter software. New in this version:
    1. Updated and improved the SoundCloud, Twitter, Facebook, VK, AOL, RedTube, and YouTube extractors
      • SoundCloud extraction was repaired, and the infamous SoundCloud "client id" value now automatically updates when the current id is revoked
      • Facebook thumbnail images now display correctly, and extraction from one Facebook URL format was repaired
      • Twitter, AOL, and RedTube extraction was repaired
    2. Fixed "wildcard" pattern (used to validate URLs from some supported sites) to accommodate PHP 7.3+
    3. Various (minor) bug fixes and refactoring of code.

    The following files were updated/added:
    1. /docs/CHANGELOG.txt updated! *
    2. /extractors/AOL.php updated! *
    3. /extractors/Extractor.php updated! *
    4. /extractors/Facebook.php updated! *
    5. /extractors/RedTube.php updated! *
    6. /extractors/SoundCloud.php updated! *
    7. /extractors/Twitter.php updated! *
    8. /extractors/VK.php updated! *
    9. /extractors/YouTube.php updated! *
    10. /inc/index_header.php updated! *
    11. Config.class.php updated! *
    12. VideoConverter.class.php updated! *

    * Use a file comparison utility like WinMerge to see line-by-line illustration of code changes (between previous and current versions).
    ** Delete all existing files in this directory and replace with the new files.

    If you purchased the software via Tradebit.com, Tinypass.com, or Sendowl.com, then you will be e-mailed a link to download the new version for free!.

    If you create a new language file for the software, please donate the file to the code base so that others can benefit from your translations! Simply send me a copy of your updated index.xml file as well as your new *.xml translation file, and I will add it to the software in a future release!

    Custom templates and "extras" are available!! Please contact me for more information!


    Please report any issues with either the paid-for version or the free version in this forum thread. Your feedback is encouraged. Donations are welcome!

    Thank you!

    Leave a comment:


  • chump2877
    replied
    Originally posted by Kontra View Post
    Hello,
    there will be a new version soon, with the demo version you can download Twitter video without any problems.
    When I test this on my website, I always get an error message.
    Error downloading remote file!

    greeting
    Hello,

    Yes, the demo is being updated in advance of a new software version that will be officially released soon.

    In the meantime, if you need the updated Twitter "extractor" file, please open a new ticket (by sending an email to support {[at]} mp3youtu {[dot]} be), and I am happy to provide the new code via your open ticket.

    Thank you!

    Leave a comment:


  • Kontra
    replied
    Hello,
    there will be a new version soon, with the demo version you can download Twitter video without any problems.
    When I test this on my website, I always get an error message.
    Error downloading remote file!

    greeting

    Leave a comment:


  • chump2877
    replied
    Originally posted by Kontra View Post
    Hello, can it be that YouTube has changed something again.
    I keep getting the error message: Error downloading remote file!
    Hi there,

    My apologies for the delayed response.

    When you see an error like this on your site, you should immediately check the demo site to see if the issue can be reproduced there.

    At this time, I am not seeing any issue with YouTube downloads on the demo site.

    What version of the software are you using?

    (FYI - You can also create a support request ticket for this issue by sending an email to support {[at]} mp3youtu {[dot]} be .)

    Let me know how it goes.

    Thank you!

    Leave a comment:


  • Kontra
    replied
    Hello, can it be that YouTube has changed something again.
    I keep getting the error message: Error downloading remote file!

    Leave a comment:


  • chump2877
    replied
    Originally posted by Gioware View Post
    Ultimate goal would be page load speed. I tried to optimize and move things here and there but can't do much about thumbs.
    In my opinion, this is an unnecessary (SEO) optimization.

    If you check the list of requests in the Google Chrome Dev Tools "Network" tab, then you'll see that these thumbnail images take between ~60-140 milliseconds each to initially load. That's approximately 1/10 of a second each, multiplied by the initial number of videos per page. (E.g., if you have the default 5 videos, then the total load time is about 1/2 of a second, more or less.)

    After the first page load, the images are cached in your browser, and the load time for each image drops to about 1-4 milliseconds each.

    Moreover, keep in mind that images are page elements that generally take the longest to load.

    So, again, in my opinion, this is easily the least of your concerns in terms of page load speed.

    Leave a comment:


  • Gioware
    replied
    It is certainly "possible", but why do you want to cache thumbnail images? To reduce the number of requests to YouTube? To save bandwidth? Some other reason? I think I could advise you better if understood your ultimate goal.

    Ultimate goal would be page load speed. I tried to optimize and move things here and there but can't do much about thumbs.


    The YouTube Media Converter automatically generates sitemaps here that contain links to "Top Videos" for each country included in Config.php.
    Ooooooooh thanks. This is great news. I have no idea how I missed that.

    Leave a comment:


  • chump2877
    replied
    Originally posted by Gioware View Post
    is it possible (in theory) to somehow cache youtube thumbnails, instead of loading them directly from youtube?
    It is certainly "possible", but why do you want to cache thumbnail images? To reduce the number of requests to YouTube? To save bandwidth? Some other reason? I think I could advise you better if understood your ultimate goal.

    Originally posted by Gioware View Post
    is it possible to create sitemap.xml from top youtube videos?
    The YouTube Media Converter automatically generates sitemaps here that contain links to "Top Videos" for each country included in Config.php.

    Leave a comment:


  • Gioware
    replied
    Thanks chump2877 , everything works perfect now! awesome script and support!

    P.S. while we are on subject of suggestions, is it possible (in theory) to somehow cache youtube thumbnails, instead of loading them directly from youtube?
    aand, is it possible to create sitemap.xml from top youtube videos?

    Leave a comment:


  • chump2877
    replied
    Originally posted by Gioware View Post
    maybe it would be better from UX point of view, to load both mp4 and video streams on the same page, once "Download Video" is clicked.
    We'll consider your suggestion The current allocation of video formats/qualities to the Videos and Video Streams sections is based on the YouTube source as well as the programming logic required to deliver videos to each section. From a developer (and code-management) standpoint, the current approach is more efficient. But I could see how the UX and UI might be improved by combining both sections into a single section. That said, if we were to do that, then there would be duplicate download file formats/qualities. So, the argument could be made that we could or should eliminate the Videos section entirely. In fact, you can currently enable/disable either section via the following Config constants:

    PHP Code:
    // Enable "non-DASH", composite video + audio downloads
    // No FFmpeg is required.
    // (This is typically lower quality video, but YouTube Direct download is available.)
    const _ENABLE_NONDASH_VIDEO true;

    // Enable the download of merged "video streams"
    // Video-only and audio-only tracks are combined via FFmpeg stream copy.
    // (Supports all video qualities, but no YouTube Direct download is available.)
    const _ENABLE_MERGED_VIDEO_STREAMS true
    To clarify, _ENABLE_NONDASH_VIDEO corresponds to the Videos section, and _ENABLE_MERGED_VIDEO_STREAMS corresponds to the Video Streams section.

    Originally posted by Gioware View Post
    It usually displays which top movies are being shown (for example Top Music Videos - US) but now country is removed (so it displays like "Top Music Videos - " ) any suggestions how to fix that? (If you manually select Top Music Videos country from drop down menu, it shows country names as intended)
    In result() function, in PagesController.php, try replacing

    PHP Code:
    $countryInfo['Continent'
    ...with:

    PHP Code:
    Config::_DEFAULT_COUNTRY_GROUP 

    Leave a comment:


  • Gioware
    replied
    1. I see, yes downloading videos and converting them seems not only time intensive, but as a waste of resources too, I bet it will require quite powerful server and bandwidth. Way I have seen this implemented is trough progress bar UI. Where user waits for progress bar to finish in order to download converted video.

    That being said

    It seems youtube is moving towards mkv/webm and maybe it would be better from UX point of view, to load both mp4 and video streams on the same page, once "Download Video" is clicked. Anyways, this more mp3 focused service rather than video, but still.


    2. Both modifications worked as intended, just small nuance:

    It usually displays which top movies are being shown (for example Top Music Videos - US) but now country is removed (so it displays like "Top Music Videos - " ) any suggestions how to fix that? (If you manually select Top Music Videos country from drop down menu, it shows country names as intended)

    Leave a comment:


  • chump2877
    replied
    Originally posted by Gioware View Post
    2. Yes, top videos, it seems to be the case - Yes, So, if I am getting it correctly, there is no way to download higher resolution mp4 by clicking "Download Video" button, and even if user knows what "Video streams" are, he/she is still left with mkv or webm options only? I am asking because I have seen other services where they offer hd mp4 on popular videos, I think it is done by server side conversion? (server first downloads mkv/webm and converts to mp4)
    These services must be downloading and saving the video to the server first. We don't do that.

    In short: Saving Video Streams videos to MKV instead of MP4 is the only way we were able to preserve fast and immediate downloads of HD video "streams" to your users' browsers. (Fast downloads is one of the things that really elevates and differentiates the YouTube Media Converter software from our other products!)

    To clarify this assertion, please read on:
    1. In the context of our software, your server requests media saved on YouTube, and YouTube's response is streamed to your server (which acts as a proxy between YouTube and your users). We then capture that stream and redirect it to your users' browsers -- in the form of a browser download. The net result produces fast and immediate downloads of HD video "streams" to your users' browsers.
    2. The HD video from YouTube is currently only available as separate DASH, "non-seekable", video-only/audio-only "streams".
      • "Seekable" content, by definition, enables users to navigate forwards and backwards in a video during playback.
      • DASH "streams" are "non-seekable" content. In general, streams are meant to be played live, so "seeking" is inherently unsupported (because you cannot navigate backwards and forwards during a live stream).
    3. MP4 "containers" (files with a .mp4 extension) do not support "non-seekable" streams that are not otherwise saved to your server first.
    4. Thus, because we are not saving video content to your server (in order to facilitate fast and immediate downloads), YouTube's DASH formats cannot be practically copied (as is, via FFmpeg, with no further encoding) to MP4 "containers" in the context of our software. (That is why we save to MKV "containers" instead, because they do support "non-seekable" content in this context.)
    5. In fact, the only way to use an MP4 container here is to save the stream to a file on your server, thereby enabling the stream to become "seekable".
    6. But, if we copy and save a stream format to MP4 on your server first, then end users must wait for that process to finish before they can start downloading the MP4 from your server.
    7. E.g., for even moderately-sized HD videos, this initial transfer of the video stream to a tangible file on your server can take several minutes. During that time, the end user can only wait for the download to the server to complete.
    8. Thus, the only method that would enable us to support the download of MP4 here would also prevent the fast and immediate downloads of HD video "streams" to your users' browsers
    (I know that explanation may seem complicated, but this stuff isn't simple. We just make it look simple! )

    In truth, MKV works on all (tested) devices that support MP4 playback.

    That said, I do understand the reluctance to embrace MKV instead of MP4, for these videos. Foremost, MKV is lesser known than MP4, so you may wonder how this will impact your users' behavior. For this reason, we have added the following constant to "lib/Config.php", to help assuage that concern:

    PHP Code:
     // The file type label that appears on download buttons in video charts, search results, and the Iframe/Button API as well as the file type ("ftype") property value in JSON API responses.
    const _MERGED_VIDEO_STREAM_LABEL "mkv"
    This constant's value will effectively "re-brand" your MKV files as "MP4" (or anything else you want). Users will still ultimately download MKV, but once they realize that MKV works just as well as MP4, they will become more comfortable with using MKV.

    In general, we do understand that this is not a perfect or ideal solution for some people. But nothing about YouTube's decision to remove non-DASH, composite HD video (in the Videos section, for popular videos) is "perfect". We are constantly prone to the whims of YouTube, and we can only make the best of a less-than-ideal situation.

    Originally posted by Gioware View Post
    3. Can I somehow disable this automatic setting, so site is always shown in the language set in config, as well as it always displays top videos from country set in config
    In "app/Controllers/PagesController.php", in the index() and results() functions, you can try replacing

    PHP Code:
    $countryInfo['cCode'
    ...with:

    PHP Code:
    Config::_DEFAULT_COUNTRY 
    I've not tested this, but theoretically it should force the default country (defined in Config) for Music Charts.

    Also, in "app/Core/Language.php", in the GetLanguage() function, you could set

    PHP Code:
    $langCode Config::_DEFAULT_LANGUAGE
    Again, not tested, but this should theoretically set the language to the default language (defined in Config) if the language has not otherwise been set by user yet.

    Leave a comment:


  • Gioware
    replied
    1. Thanks chump2877 I will be implementing CAPTCHA and let you know how it goes. Yes, I mean units, on some accounts it went up to 1 000 000 while I don't see such traffic. It might be that some error output maybe revealed API key, or maybe It is being parsed trough form, I don't know, but will try captcha now anyways.

    2. Yes, top videos, it seems to be the case - Yes, So, if I am getting it correctly, there is no way to download higher resolution mp4 by clicking "Download Video" button, and even if user knows what "Video streams" are, he/she is still left with mkv or webm options only? I am asking because I have seen other services where they offer hd mp4 on popular videos, I think it is done by server side conversion? (server first downloads mkv/webm and converts to mp4)

    3. Can I somehow disable this automatic setting, so site is always shown in the language set in config, as well as it always displays top videos from country set in config

    Leave a comment:


  • chump2877
    replied
    Originally posted by Gioware View Post
    Also, couple of questions:

    1. What to do if all your videos download links generate only 360p versions?


    2. Setting default top videos to certain country, does not change actual top videos to that country. Is this still being determined by browser agent?
    1) Are you referring to video download buttons in the Videos section of a given video listed in the YouTube Media Converter search results?

    If so, these days, most "popular" videos only have 360p composite (non-DASH) video + audio versions available on YouTube. So, if you want more video formats and qualities, then you will need to click on the Video Streams section instead. Video Streams videos are created by merging video- and audio-only (DASH) formats/tracks available on YouTube. (In general, this is the same thing that YouTube is doing when you play a higher resolution video on their site. They are merging the separate tracks at playtime.)

    2) The software automatically checks the browser language/location, and sets language/location to these values if the corresponding language and country charts are available. So, if you try to set the default country in Config.php, then this value will be overridden by the end user's browser language/country (because, more often than not, this is the preferred language/country of the end user). In any case, the end user can always manually update the language and/or charts country if they do not want the automatic settings.

    Leave a comment:

Working...
X