Skip to content

Automatically Convert Videos to MP4 and MP3

Daniel Neto edited this page Jan 8, 2025 · 4 revisions

This guide explains how to enable and use features like converting videos to MP4 and MP3. These options make it easy to download, watch offline, or listen to audio content.


🎥 HLS to MP4 Conversion

📌 Why Convert to MP4?

  • HLS videos are optimized for streaming but difficult to download or watch offline.
  • Converting them to MP4 makes downloading and offline viewing simple.

How to Enable

  1. Open the VideoHLS Plugin settings.
  2. Look for the option autoConvertToMp4.
  3. Check the box to activate this feature.

📖 Learn more about the VideoHLS Plugin.

⚙️ How to Convert Manually

If you prefer to convert videos yourself:

  1. Open your terminal and go to this folder:
    cd /var/www/html/AVideo/plugin/VideoHLS/tools
  2. Run this command:
    php convertToMP4.php
    • This will only convert if the MP4 file doesn’t already exist.
  3. To force a conversion, even if the MP4 file exists:
    php convertToMP4.php 1

🎵 Video to MP3 Conversion

📌 Why Convert to MP3?

  • MP3 files allow users to listen to the audio from videos, perfect for podcasts.
  • Especially useful for mobile users who want to listen with the screen locked.

How to Enable

  1. Go to the CustomizeAdvanced Plugin settings.
  2. Locate the autoConvertVideosToMP3 option.
  3. Check the box to enable it.

📖 Learn more about enabling MP3 downloads.

⚙️ How to Convert All Videos Manually

  1. Open your terminal and navigate to:
    cd /var/www/html/AVideo/install
  2. Run the command:
    php getMp3FromAll.php
    • Converts videos to MP3 only if the MP3 doesn’t already exist.

⚙️ How to Convert a Specific Video

To convert a specific video to MP3:

  1. Run this command:
    php getMp3FromVideo.php
  2. Follow the prompts:
    • Enter the video ID to specify the video.
    • If the MP3 already exists, the script will ask if you want to delete it and retry.
  3. Example interaction:
    cd /var/www/html/AVideo/install
    php getMp3FromVideo.php
    Enter the video ID: 123
    MP3 file already exists at: /path/to/mp3/file.mp3
    Do you want to remove and try again? (y/n): y
    Conversion successful!
    Execution Steps:
    - Step 1
    - Step 2
    MP3 Duration: 3:15

🔍 Check for MP3 Errors

If an MP3 file’s length doesn’t match the video’s:

  1. Run this command to identify and fix errors:
    php verifyAllMP3Lengths.php
    • Note: This process may take longer.

🌟 Benefits of These Features

🎥 HLS to MP4 Conversion:

  • Easier Downloads: Enables users to download HLS videos as MP4.
  • Offline Viewing: Watch videos anywhere, even without internet access.

📖 Learn more about offline viewing.

🎵 Video to MP3 Conversion:

  • Listen Anywhere: Perfect for podcasts, audiobooks, or lectures.
  • Screen Locked Listening: Save battery on mobile devices.
  • Car-Friendly: Connect to your car’s audio system for hands-free listening.

📖 Learn more about the mobile app.


🔄 How It Works Automatically

  1. HLS to MP4 Conversion:

    • The system checks for new HLS videos every minute and converts them.
    • If the conversion fails, it retries every minute.
  2. Video to MP3 Conversion:

    • The system checks for new videos every hour and converts them.
    • If the conversion fails, it retries every hour.

📂 Additional Resources

Clone this wiki locally