Jump to content

video sharing script


inferno-prime

Recommended Posts

Hello

First off I want to say thank to those who helped me with my last visit here they were a tremendous help.

 

I am using this script for encoding my video. this script encodes both webm and mp4 at the same time which is something I don't want. I was hoping to make that option select-able but I fear that would be to much to ask now. I'll admit I don't know much about php but I really do appreciate the help.

I have the encode file here I tried commenting some lines out but had no success. I will also mention that I tried their forums but they are no help since they expect everyone who comes there to magically know php. I asked for help several times and most of the time got no reply.

<?php

// Startup application
include_once(dirname(__FILE__) . '/bootstrap.php');

// Validate CLI parameters passed to script
$arguments = getopt('', array('video:', 'import::'));
if (!$arguments || !preg_match('/^[0-9]+$/', $arguments['video'])) exit();

// Validate provided import job
if (!empty($arguments['import'])) {
    if (file_exists(UPLOAD_PATH . '/temp/import-' . $arguments['import'])) {
        $importJobId = $arguments['import'];
    } else {
        exit('An invalid import job was passed to the video encoder.');
    }
} else {
    $importJobId = null;
}

// Establish page variables, objects, arrays, etc
$video_id = $arguments['video'];
$ffmpegPath = Settings::get('ffmpeg');
$qtFaststartPath = Settings::get('qtfaststart');
$videoMapper = new VideoMapper();
$videoService = new \VideoService();

// Update any failed videos that are still marked processing
$videoService->updateFailedVideos();

// Set MySQL wait_timeout to 10 hours to prevent 'MySQL server has gone away' errors
$db->query("SET @@session.wait_timeout=36000");

// Debug Log
if ($config->debugConversion) {
    App::log(CONVERSION_LOG, "\n\n// Converter Called...");
    App::log(CONVERSION_LOG, "Values passed to encoder:\n" . print_r ($arguments, TRUE));
}

try {

    /////////////////////////////////////////////////////////////
    //                        STEP 1                           //
    //       Check Permissions on Transcoding Binaries         //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nChecking FFMPEG permissions...") : null;
    if (strpos($ffmpegPath, DOC_ROOT) !== false && Filesystem::getPermissions($ffmpegPath) != '0777') {
        try {
            Filesystem::setPermissions($ffmpegPath, 0777);
        } catch (Exception $e) {
            throw new Exception("Unable to update permissions for FFMPEG. Please make sure it ($ffmpegPath) has 777 executeable permissions.\n\nAdditional information: " . $e->getMessage());
        }
    }

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nChecking qt-faststart permissions...") : null;
    if (strpos($qtFaststartPath, DOC_ROOT) !== false && Filesystem::getPermissions($qtFaststartPath) != '0777') {
        try {
            Filesystem::setPermissions($qtFaststartPath, 0777);
        } catch (Exception $e) {
            throw new Exception("Unable to update permissions for qt-faststart. Please make sure it ($qtFaststartPath) has 777 executeable permissions.\n\nAdditional information: " . $e->getMessage());
        }
    }









    /////////////////////////////////////////////////////////////
    //                        STEP 2                           //
    //               Validate Requested Video                  //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Validating requested video...') : null;

    // Validate requested video
    $video = $videoMapper->getVideoByCustom(array('video_id' => $video_id, 'status' => VideoMapper::PENDING_CONVERSION));
    if (!$video) throw new Exception("An invalid video was passed to the video encoder.");

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Establishing variables...') : null;

    // Retrieve video information
    $video->status = VideoMapper::PROCESSING;
    $video->jobId = posix_getpid();
    $videoMapper->save($video);
    $debugLog = LOG . '/' . $video->filename . '.log';
    $rawVideo = UPLOAD_PATH . '/temp/' . $video->filename . '.' . $video->originalExtension;
    $h264TempFilePath = UPLOAD_PATH . '/h264/' . $video->filename . '_temp.mp4';
    $h264FilePath = UPLOAD_PATH . '/h264/' . $video->filename . '.mp4';
    $theoraFilePath = UPLOAD_PATH . '/theora/' . $video->filename . '.ogg';
    $webmFilePath = UPLOAD_PATH . '/webm/' . $video->filename . '.webm';
    $mobileTempFilePath = UPLOAD_PATH . '/mobile/' . $video->filename . '_temp.mp4';
    $mobileFilePath = UPLOAD_PATH . '/mobile/' . $video->filename . '.mp4';
    $thumb = UPLOAD_PATH . '/thumbs/' . $video->filename . '.jpg';

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying raw video exists...') : null;

    // Verify Raw Video Exists
    if (!file_exists ($rawVideo)) throw new Exception("The raw video file does not exists. The id of the video is: $video->videoId");

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying raw video was valid size...') : null;

    // Verify Raw Video has valid file size
    // (Greater than min. 5KB, anything smaller is probably corrupted
    if (!filesize ($rawVideo) > 1024*5) throw new Exception("The raw video file is not a valid filesize. The id of the video is: $video->videoId");









    /////////////////////////////////////////////////////////////
    //                        STEP 3                           //
    //              Encode raw video to H.264                  //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nPreparing for: H.264 Encoding...") : null;

    // Encode raw video to H.264
    $h264Command = "$ffmpegPath -i $rawVideo " . Settings::get('h264_encoding_options') . " $h264TempFilePath >> $debugLog 2>&1";

    // Debug Log
    $logMessage = "\n\n\n\n==================================================================\n";
    $logMessage .= "H.264 ENCODING\n";
    $logMessage .= "==================================================================\n\n";
    $logMessage .= "H.264 Encoding Command: $h264Command\n\n";
    $logMessage .= "H.264 Encoding Output:\n\n";
    $config->debugConversion ? App::log(CONVERSION_LOG, 'H.264 Encoding Command: ' . $h264Command) : null;
    App::log($debugLog, $logMessage);

    // Execute H.264 encoding command
    exec($h264Command);

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying H.264 video was created...') : null;

    // Verify temp H.264 video was created successfully
    if (!file_exists($h264TempFilePath) || filesize($h264TempFilePath) < 1024*5) {
        throw new Exception("The temp H.264 file was not created. The id of the video is: $video->videoId");
    }









    /////////////////////////////////////////////////////////////
    //                        STEP 4                           //
    //            Shift Moov atom on H.264 video               //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nShifting moov atom on H.264 video...") : null;

    // Prepare shift moov atom command
    $h264ShiftMoovAtomCommand = "$qtFaststartPath $h264TempFilePath $h264FilePath >> $debugLog 2>&1";

    // Debug Log
    $logMessage = "\n\n\n\n==================================================================\n";
    $logMessage .= "H.264 SHIFT MOOV ATOM\n";
    $logMessage .= "==================================================================\n\n";
    $logMessage .= "H.264 Shift Moov Atom Command: $h264ShiftMoovAtomCommand\n\n";
    $logMessage .= "H.264 Shift Moov Atom Output:\n\n";
    $config->debugConversion ? App::log(CONVERSION_LOG, 'H.264 Shift Moov Atom Command: ' . $h264ShiftMoovAtomCommand) : null;
    App::log($debugLog, $logMessage);

    // Execute shift moov atom command
    exec($h264ShiftMoovAtomCommand);

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying final H.264 file was created...') : null;

    // Verify H.264 video was created successfully
    if (!file_exists($h264FilePath) || filesize($h264FilePath) < 1024*5) {
        throw new Exception("The final H.264 file was not created. The id of the video is: $video->videoId");
    }









    /////////////////////////////////////////////////////////////
    //                        STEP 5                           //
    //               Encode raw video to WebM                  //
    /////////////////////////////////////////////////////////////

    $webmEncodingEnabled = (Settings::get('webm_encoding_enabled') == '1') ? true : false;
    $webmEncodingOptions = Settings::get('webm_encoding_options');
    if ($webmEncodingEnabled) {
        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, "\nPreparing for: WebM Encoding...") : null;

        // Encode raw video to WebM
        $webmCommand = "$ffmpegPath -i $rawVideo " . $webmEncodingOptions . " $webmFilePath >> $debugLog 2>&1";

        // Debug Log
        $logMessage = "\n\n\n\n==================================================================\n";
        $logMessage .= "WebM ENCODING\n";
        $logMessage .= "==================================================================\n\n";
        $logMessage .= "WebM Encoding Command: $webmCommand\n\n";
        $logMessage .= "WebM Encoding Output:\n\n";
        $config->debugConversion ? App::log(CONVERSION_LOG, 'WebM Encoding Command: ' . $webmCommand) : null;
        App::log($debugLog, $logMessage);

        // Execute WebM encoding command
        exec($webmCommand);

        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying WebM video was created...') : null;

        // Verify temp WebM video was created successfully
        if (!file_exists($webmFilePath) || filesize($webmFilePath) < 1024*5) {
            throw new Exception("The WebM file was not created. The id of the video is: $video->videoId");
        }
    }









    /////////////////////////////////////////////////////////////
    //                        STEP 6                           //
    //              Encode raw video to Theora                 //
    /////////////////////////////////////////////////////////////

    $theoraEncodingEnabled = (Settings::get('theora_encoding_enabled') == '1') ? true : false;
    $theoraEncodingOptions = Settings::get('theora_encoding_options');
    if ($theoraEncodingEnabled) {
        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, "\nPreparing for: Theora Encoding...") : null;

        // Encode raw video to Theora
        $theoraCommand = "$ffmpegPath -i $rawVideo " . $theoraEncodingOptions . " $theoraFilePath >> $debugLog 2>&1";

        // Debug Log
        $logMessage = "\n\n\n\n==================================================================\n";
        $logMessage .= "Theora ENCODING\n";
        $logMessage .= "==================================================================\n\n";
        $logMessage .= "Theora Encoding Command: $theoraCommand\n\n";
        $logMessage .= "Theora Encoding Output:\n\n";
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Theora Encoding Command: ' . $theoraCommand) : null;
        App::log($debugLog, $logMessage);

        // Execute Theora encoding command
        exec($theoraCommand);

        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying Theora video was created...') : null;

        // Verify temp Theora video was created successfully
        if (!file_exists($theoraFilePath) || filesize($theoraFilePath) < 1024*5) {
            throw new Exception("The Theora file was not created. The id of the video is: $video->videoId");
        }
    }









    /////////////////////////////////////////////////////////////
    //                        STEP 7                           //
    //              Encode raw video to Mobile                 //
    /////////////////////////////////////////////////////////////

    $mobileEncodingEnabled = (Settings::get('mobile_encoding_enabled') == '1') ? true : false;
    $mobileEncodingOptions = Settings::get('mobile_encoding_options');
    if ($mobileEncodingEnabled) {
        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, "\nPreparing for: Mobile Encoding...") : null;

        // Encode raw video to Mobile
        $mobileCommand = "$ffmpegPath -i $rawVideo " . $mobileEncodingOptions . " $mobileTempFilePath >> $debugLog 2>&1";

        // Debug Log
        $logMessage = "\n\n\n\n==================================================================\n";
        $logMessage .= "Mobile ENCODING\n";
        $logMessage .= "==================================================================\n\n";
        $logMessage .= "Mobile Encoding Command: $mobileCommand\n\n";
        $logMessage .= "Mobile Encoding Output:\n\n";
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Mobile Encoding Command: ' . $mobileCommand) : null;
        App::log($debugLog, $logMessage);

        // Execute Mobile encoding command
        exec($mobileCommand);

        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying Mobile video was created...') : null;

        // Verify temp Mobile video was created successfully
        if (!file_exists($mobileTempFilePath) || filesize($mobileTempFilePath) < 1024*5) {
            throw new Exception("The Mobile file was not created. The id of the video is: $video->videoId");
        }









        /////////////////////////////////////////////////////////////
        //                        STEP 8                           //
        //            Shift Moov atom on Mobile video              //
        /////////////////////////////////////////////////////////////

        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, "\nShifting moov atom on Mobile video...") : null;

        // Execute Faststart Command
        $faststartCommand = "$qtFaststartPath $mobileTempFilePath $mobileFilePath >> $debugLog 2>&1";

        // Debug Log
        $logMessage = "\n\n\n\n==================================================================\n";
        $logMessage .= "FASTSTART\n";
        $logMessage .= "==================================================================\n\n";
        $logMessage .= "Faststart Command: $faststartCommand";
        $logMessage .= "Faststart Output:\n\n";
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Faststart Command: ' . $faststartCommand) : null;
        App::log($debugLog, $logMessage);

        // Execute Faststart command
        exec($faststartCommand);

        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying final Mobile file was created...') : null;

        // Verify Mobile video was created successfully
        if (!file_exists($mobileFilePath) || filesize($mobileFilePath) < 1024*5) throw new Exception("The final Mobile file was not created. The id of the video is: $video->videoId");
    }









    /////////////////////////////////////////////////////////////
    //                        STEP 9                           //
    //                  Get Video Duration                     //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nRetrieving video duration...") : null;

    // Retrieve duration of raw video file.
    $durationCommand = "$ffmpegPath -i $rawVideo 2>&1 | grep Duration:";
    exec($durationCommand, $durationResults);

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "Duration command results:\n" . print_r ($durationResults, TRUE)) : null;

    $durationResultsCleaned = preg_replace('/^\s*Duration:\s*/', '', $durationResults[0]);
    preg_match ('/^[0-9]{2}:[0-9]{2}:[0-9]{2}/', $durationResultsCleaned, $duration);
    $sec = Functions::durationToSeconds($duration[0]);

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "Duration in Seconds: $sec") : null;

    // Calculate thumbnail position
    $thumbPosition = round ($sec / 2);

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "Thumb Position: $thumbPosition") : null;









    /////////////////////////////////////////////////////////////
    //                        STEP 10                          //
    //                Create Thumbnail Image                   //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nPreparing to create video thumbnail...") : null;

    // Create video thumbnail image
    $thumbCommand = "$ffmpegPath -i $rawVideo -ss $thumbPosition " . Settings::get('thumb_encoding_options') . " $thumb >> $debugLog 2>&1";

    // Debug Log
    $logMessage = "\n\n\n\n==================================================================\n";
    $logMessage .= "THUMB CREATION\n";
    $logMessage .= "==================================================================\n\n";
    $logMessage .= "Thumb Creation Command: $thumbCommand";
    $logMessage .= "Thumb Creation Output:\n\n";
    $config->debugConversion ? App::log(CONVERSION_LOG, "Thumbnail Creation Command: " . $thumbCommand) : null;
    App::log($debugLog, $logMessage);

    exec($thumbCommand);    // Execute Thumb Creation Command

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, 'Verifying valid thumbnail was created...') : null;

    // Verify valid thumbnail was created
    if (!file_exists($thumb) || filesize($thumb) == 0) throw new Exception("The video thumbnail is invalid. The id of the video is: $video->videoId");









    /////////////////////////////////////////////////////////////
    //                        STEP 11                          //
    //               Update Video Information                  //
    /////////////////////////////////////////////////////////////

    // Debug Log
    $config->debugConversion ? App::log(CONVERSION_LOG, "\nUpdating video information...") : null;

    // Update database with new video status information
    $video->duration = Functions::formatDuration($duration[0]);
    $video->status = \VideoMapper::PENDING_APPROVAL;
    $video->jobId = null;
    $videoMapper->save($video);

    // Activate video
    $videoService->approve($video, 'activate');









    /////////////////////////////////////////////////////////////
    //                        STEP 12                          //
    //                 Notify Import Script                    //
    /////////////////////////////////////////////////////////////

    if ($importJobId) {

        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, "\nNotifying import script of completed video...") : null;
        \ImportManager::executeImport($importJobId);
    }









    /////////////////////////////////////////////////////////////
    //                         STEP 13                         //
    //                        Clean up                         //
    /////////////////////////////////////////////////////////////

    try {
        // Debug Log
        $config->debugConversion ? App::log(CONVERSION_LOG, 'Deleting raw video...') : null;

        // Delete pre-faststart files
        Filesystem::delete($h264TempFilePath);
        if ($mobileEncodingEnabled) Filesystem::delete($mobileTempFilePath);

        // Delete original video
        if (Settings::get('keep_original_video') != '1') {
            Filesystem::delete($rawVideo);
        }

        // Delete encoding log files
        if ($config->debugConversion) {
            App::log(CONVERSION_LOG, "Video ID: $video->videoId, has completed processing!\n");
        } else {
            Filesystem::delete($debugLog);
        }
    } catch (Exception $e) {
        App::alert('Error During Video Encoding', $e->getMessage());
        App::log(CONVERSION_LOG, $e->getMessage());
    }

} catch (Exception $e) {

    // Update video status
    if ($video) {
        $video->status = \VideoMapper::FAILED;
        $video->jobId = null;
        $videoMapper->save($video);
    }

    // Notify import script of error
    if ($importJobId) {
        \ImportManager::executeImport($importJobId);
    }

    App::alert('Error During Video Encoding', $e->getMessage());
    App::log(CONVERSION_LOG, $e->getMessage());
    exit();
}

 

Link to comment
Share on other sites

Does quite a bit more than just WebM and MP4.

The script is broken down into a number of different scripts. Some of them are dedicated to converting to a particular format. If you don't want that format (at least not yet) then comment out the whole step.

Link to comment
Share on other sites

  • 3 weeks later...

Found the problem I had to remove this line : <source src="<?= $config->h264Url ?>/<?= $video->filename ?>.mp4" type="video/mp4" /> under the begin video section.
 

<?php
$this->addMeta('videoId', $video->videoId);
$this->addMeta('theme', $this->options->themeUrl);
$this->addMeta('loggedIn', (bool) $loggedInUser);

$this->addMeta('reply_to', Language::getText('reply_to'));
$this->addMeta('report_abuse', Language::getText('report_abuse'));

if ($loggedInUser && !$video->commentsClosed) {
    $this->addMeta('reply', Language::getText('reply'));
}
$this->addCss($this->options->themeUrl . '/css/vendor/video-js.css');
$this->addJs($this->options->themeUrl . '/js/vendor/video.min.js');
//$this->addJs($this->options->themeUrl . '/js/general.js');

$this->addJs($this->options->themeUrl . '/js/vendor/moment.min.js');
$this->addJs($this->options->themeUrl . '/js/vendor/jsrender.min.js');
$this->addJs($this->options->themeUrl . '/js/comments.js');
?>


<div class="container-fluid">


    <div class="row pt-5">
        <div class="col-md-8">
            <div class="header-secondary">
                <h1 class="video-title"><?php echo htmlspecialchars($video->title); ?></h1>
                <?php (isset($message)) ? showAlertMessage($message, $message_type) : ''; ?>
            </div>
            <?php if ($video->gated && !$loggedInUser) : ?>
                <div id="player-gated">
                    <img width="100%" height="auto" src="<?= getVideoThumbUrl($video) ?>" alt="<?= htmlspecialchars($video->title); ?>" />
                    <div>
                        <p><?= Language::getText('gated_video') ?></p>
                        <a href="<?= HOST ?>/login/?redirect=<?= urlencode($this->getService('Video')->getUrl($video)) ?>" class="button_small"><?= Language::getText('login') ?></a>
                        <?php if ($config->enableRegistrations) : ?>
                            <a href="<?= HOST ?>/register/" class="button_small"><?= Language::getText('register') ?></a>
                        <?php endif; ?>
                    </div>
                </div>

            <?php else : ?>
                <!-- BEGIN VIDEO -->
                <div id="player" class="mb-1">
                    <video class="video-js vjs-big-play-centered" controls preload="auto" data-setup='{ "autoplay": false, "fluid": true, "aspectRatio": "16:9"}' poster="<?= getVideoThumbUrl($video) ?>">
                        <source src="<?= $config->h264Url ?>/<?= $video->filename ?>.mp4" type="video/mp4" />
                        <?php if ($webmEncodingEnabled) : ?>
                            <source src="<?= $config->webmUrl ?>/<?= $video->filename ?>.webm" type="video/webm" />
                        <?php endif; ?>
                        <?php if ($theoraEncodingEnabled) : ?>
                            <source src="<?= $config->theoraUrl ?>/<?= $video->filename ?>.ogg" type="video/ogg" />
                        <?php endif; ?>
                    </video>
                </div>
                <!-- END VIDEO -->
            <?php endif; ?>

            <!-- BEGIN ACTIONS -->
            <div class="row actions">
                <div class="col-md-6">
                    <p class="large">Viewed <?= $video->views ?> times.</p>
                </div>
                <div class="col-md-6">
                    <div class="btn-toolbar float-right" role="toolbar" aria-label="Video actions.">
                        <div class="btn-group mr-2" role="group" aria-label="Like/Rating buttons.">
                            <?php if (isRated($video, $loggedInUser)) : ?>
                                <a id="liked" class="like rating btn btn-sm btn-outline-primary disabled" href="#" data-rating="0" data-video_id=<?= $video->videoId; ?> role="button"><i class="fas fa-heart like-icon" alt="Click to like this video."></i> <span class="likes badge badge-light"><?= $rating->likes ?></span> <span class="sr-only"> likes for this video.</span> </a>
                            <?php else : ?>
                                <a id="like" class="like rating btn btn-sm btn-outline-primary" href="" data-rating="1" data-video_id=<?= $video->videoId; ?> role="button"><i class="far fa-heart like-icon" alt="Click to like this video."></i> <span class="likes badge badge-light"><?= $rating->likes ?></span> <span class="sr-only"> likes for this video.</span> </a>
                            <?php endif; ?>
                        </div>
                    <?php if ($loggedInUser) : ?>
                        <div class="btn-group button-actions" role="group" aria-label="Playlist Actions.">
                            <?php include $this->getFallbackPath("blocks/playlist-buttons.phtml"); ?>
                        </div>
                    <?php endif; ?>
                    </div>

                </div>
            </div>
            <!-- END ACTIONS -->

            <!-- BEGIN TABS -->
            <div class="row actions">
                <div class="col">
                    <nav>
                        <div class="nav nav-tabs" id="nav-tab" role="tablist">
                            <a class="nav-item nav-link active" id="nav-about-tab" data-toggle="tab" href="#nav-about" role="tab" aria-controls="nav-about" aria-selected="true"><?= Language::getText('about') ?></a>
                            <a class="nav-item nav-link" id="nav-share-tab" data-toggle="tab" href="#nav-share" role="tab" aria-controls="nav-share" aria-selected="false">Embed/Share</a>
                            <a class="nav-item nav-link" id="nav-flag-tab" data-toggle="tab" href="#nav-flag" role="tab" aria-controls="nav-flag" aria-selected="false">Report</a>
                        </div>
                    </nav>
                </div>
            </div>
            <!-- END TABS -->

            <!-- BEGIN TAB CONTENT -->
            <div class="row">
                <div class="col">
                    <div class="tab-content" id="nav-tabContent">
                        <div class="tab-pane fade show active" id="nav-about" role="tabpanel" aria-labelledby="nav-about-tab">
                            <?php include 'blocks/watch/about.php'; ?>
                        </div>
                        <div class="tab-pane fade show" id="nav-share" role="tabpanel" aria-labelledby="nav-share-tab">
                            <?php include 'blocks/watch/share.php'; ?>
                        </div>

                        <div class="tab-pane fade show" id="nav-flag" role="tabpanel" aria-labelledby="nav-flag-tab">
                            <?php include 'blocks/watch/report.php'; ?>
                        </div>
                    </div>
                </div>
            </div>
            <!-- END TAB CONTENT -->

            <!-- BEGIN COMMENTS SECTION -->
            <?php if ($video->commentsClosed) : ?>
                <div id="comments-closed" class="row">
                    <div class="col alert alert-info">
                        <p class="commentMessage"><?= Language::getText('comments_closed') ?></p>
                    </div>
                </div>
            <?php else : ?>

                <div id="comments" class="row comments-form-block comments-actionable">
                    <div class="col commentForm">

                        <div class="comment-form-head">
                            <h3 class="d-inline-block"><?= Language::getText('comments_header') ?> </h3>
                            <span id="comment-count" class="badge badge-info align-top "><?= $commentCount ?></span> <span class="sr-only"><?= Language::getText('comments_total') ?></span>
                        </div>

                        <?php include 'blocks/watch/comments_form.php'; ?>
                        <div class="comment-alerts"></div>
                    </div>
                </div>
                <div class="row comment-stream mt-4">
                    <div id="comments-list-block" class="col comments-actionable report-abuse-container">
                        <?php include 'blocks/watch/comments_list.php'; ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <?php if ($commentCount > 5) : ?>
                            <div class="loadMoreComments">
                                <button href="" class="btn btn-outline-primary btn-lg btn-block" data-loading_text="<?= Language::getText('loading') ?>"><i class="fas fa-caret-down pr-3"></i> <?= Language::getText('load_more') ?> <i class="fas fa-caret-down pl-3"></i></button>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endif; ?>
            <?php readfile('templates/comment_card.html', true); ?>
        </div>
        <!-- END COMMENTS SECTION -->
        <aside class="col-md-4 pt-3">
            <!-- BEGIN RELATED VIDEOS -->
            <?php if ($playlist) : ?>
                <?php include 'blocks/watch/playlist.php'; ?>
            <?php endif; ?>
            <!-- BEGIN RELATED VIDEOS -->
            <?php include 'blocks/watch/related.php'; ?>
            <!-- END RELATED VIDEOS -->


        </aside>
    </div>


</div>

Now the webm will play.

Now my next problem is that this script has a mobile side as well but it forces you to encode a seperate video for that side. I simply want to use the same video from the desktop side. So I will see if I can either replace that same url for the mobile size or if I change the mobile videos folder to match the desktop one.

Link to comment
Share on other sites

This is the page for the mobile theme.

<script>
cumulusClips.lang.errorComment = <?=json_encode(Language::getText('error_comment'))?>;
cumulusClips.lang.reply = <?=json_encode(Language::getText('reply'))?>;
cumulusClips.lang.replyTo = <?=json_encode(Language::getText('reply_to'))?>;
cumulusClips.videoId = <?=$video->videoId?>;
cumulusClips.commentCount = <?=$commentCount?>;
</script>

<div class="video-player-container block">

    <div class="video-player">
        <?php if ($video->gated && !$loggedInUser): ?>
            <img width="100%" height="200" src="<?=$config->thumbUrl?>/<?=$video->filename?>.jpg" alt="" />
            <div class="gate">
                <p><?=Language::getText('gated_video')?></p>
                <a class="login-link" href=""><?=Language::getText('login')?></a>
                <?php if ($config->enableRegistrations): ?>
                    <a href="<?=HOST?>/register/"><?=Language::getText('register')?></a>
                <?php endif; ?>
            </div>
        <?php else: ?>
            <video width="100%" height="100%" controls poster="<?=$config->thumbUrl?>/<?=$video->filename?>.jpg">
                <source src="<?= $config->webmUrl ?>/<?= $video->filename ?>.webm" type="video/webm" />
            </video>
        <?php endif; ?>
    </div>

    <h1><?=$video->title?></h1>

    <div class="play-tabs" data-role="navbar">
        <ul>
            <li><a href="" data-block="about-container" class="ui-btn-active" data-ajax="false"><?=Language::getText('about')?></a></li>
            <li><a href="" data-block="suggestions-container" data-ajax="false"><?=Language::getText('suggestions')?></a></li>
            <li><a href="" data-block="comments-container"  data-ajax="false"><?=Language::getText('comments')?></a></li>
        </ul>
    </div>
</div>



<div class="tab-blocks">

    <!-- About -->
    <div class="about-container">
        <h1><?=Language::getText('about')?></h1>
        <div class="block">
            <p><strong><?=Language::getText('duration')?>:</strong> <?=$video->duration?></p>
            <p><strong><?=Language::getText('views')?>:</strong> <?=$video->views?></p>
            <p><strong><?=Language::getText('by')?>:</strong> <?=$video->username?></p>
            <p><strong><?=Language::getText('description')?>:</strong> <?=$video->description?></p>
        </div>
    </div>

    <!-- Suggestions -->
    <div class="suggestions-container">
        <h1><?=Language::getText('suggestions_header')?></h1>
        <div class="block block-listview">
            <ul data-role="listview">
            <?php if (count($relatedVideos) > 0): ?>
                <?php $this->repeatingBlock('video.phtml', $relatedVideos); ?>
            <?php else: ?>
                <li><p><?=Language::getText('no_suggestions')?></p></li>
            <?php endif; ?>
            </ul>
        </div>
    </div>

    <!-- Comments -->
    <div class="comments-container">

        <div class="header">
            <h1><?=Language::getText('comments_header')?></h1>
            &bull; <span><?=$commentCount?></span>
            
            <?php if ($loggedInUser): ?>
                <a href="#post-comment-<?=$video->videoId?>" data-transition="pop" data-rel="popup" data-position-to="window"><?=Language::getText('comments_button')?></a>
            <?php else: ?>
                <?php if ($config->enableRegistrations): ?>
                    <p><?=Language::getText('comments_login_register', array('login_link' => '', 'register_link' => HOST . '/register/'))?></p>
                <?php else: ?>
                    <p><?=Language::getText('comments_login', array('login_link' => ''))?></p>
                <?php endif; ?>
            <?php endif; ?>
        </div>

        <div class="block block-listview">
            <ul data-role="listview" class="comment-list">
            <?php if ($commentCount > 0): ?>

                <?php foreach ($commentCardList as $commentCard): ?>

                    <li data-comment="<?=$commentCard->comment->commentId?>" class="comment">
                        <div class="avatar">
                            <img width="40" height="40" src="<?=($commentCard->avatar) ? $commentCard->avatar : $this->options->themeUrl . '/images/avatar.gif'?>" />
                        </div>
                        
                        <div class="content">
                            <p>
                                <?=$commentCard->author->username?> <?=date('m/d/Y', strtotime($commentCard->comment->dateCreated))?>
                                <?php if ($loggedInUser): ?>
                                    <a href="#post-comment-<?=$video->videoId?>" class="comment-reply" data-parent-comment="<?=$commentCard->comment->commentId?>" data-transition="pop" data-rel="popup" data-position-to="window"><?=Language::getText('reply')?></a>
                                <?php endif; ?>
                            </p>
                            <?php if ($commentCard->comment->parentId != 0): ?>
                                <p class="reply"><?=Language::getText('reply_to')?> <?=$commentCard->parentAuthor->username?></p>
                            <?php endif; ?>
                            <p class="comment-text"><?=nl2br($commentCard->comment->comments)?></p>
                        </div>
                    </li>

                <?php endforeach; ?>
                    
                <?php if (count($commentCardList) < $commentCount): ?>
                    <li data-icon="false" data-limit="5" class="load-more"><a href=""><?=Language::getText('load_more')?></a></li>
                <?php endif; ?>
                    
            <?php else: ?>
                <li class="no-comments"><p><?=Language::getText('no_comments')?></p></li>
            <?php endif; ?>
            </ul>
        </div>
    </div>
</div>


<div id="post-comment-<?=$video->videoId?>" class="post-comment" data-role="popup" data-tolerance="15" data-overlay-theme="b">
    <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
    <div>
        <div class="message block"></div>
        <h3><?=Language::getText('comments_post_header')?></h3>
        <form action="<?=HOST?>/actions/comment/add/" method="post" data-ajax="false">
            <textarea name="comments" style="height:auto;" placeholder="<?=Language::getText('comments')?>" rows="4"></textarea>
            <input type="hidden" name="video-id" value="<?=$video->videoId?>" />
            <input type="hidden" name="parent-comment-id" value="" />
            <button type="submit" class="ui-btn ui-corner-all"><?=Language::getText('comments_button')?></button>
        </form>
    </div>
</div>
       

Line 23 was originally this :<source src="<?=$config->mobileUrl?>/<?=$video->filename?>.mp4" type="video/mp4" />. Tried changing some lines for the mobile folder in bootstrap and encode.php but no go.

Is it true that today's smartphone browsers cannot play the webm format ? Basically that's what I am trying to achieve here.

Link to comment
Share on other sites

4 minutes ago, inferno-prime said:

Line 23 was originally this :<source src="<?=$config->mobileUrl?>/<?=$video->filename?>.mp4" type="video/mp4" />. Tried changing some lines for the mobile folder in bootstrap and encode.php but no go.

You changed it from using MP4 to using WEBM. I thought you said you were removing support for both of those?

 

4 minutes ago, inferno-prime said:

Is it true that today's smartphone browsers cannot play the webm format ? Basically that's what I am trying to achieve here.

According to caniuse.com, WEBM is generally supported with VP8 as the most portable codec.

Link to comment
Share on other sites

You "only" want to use it for desktop and mobile? Okay... so what do you not want to use it for?

If you want WEBM at all then can I assume you did not remove support for it from the conversion script?

And what does "no go" mean when you say it's not working? How is it not working? What do you want it to do and what is it actually doing?

Link to comment
Share on other sites

Quote

You "only" want to use it for desktop and mobile? Okay... so what do you not want to use it for?

I want people to be able to view video from both their desktop and mobile devices.

Quote

If you want WEBM at all then can I assume you did not remove support for it from the conversion script?

No, I did not. I already tested it too and it works fine for desktop viewing.

17 hours ago, requinix said:

And what does "no go" mean when you say it's not working? How is it not working? What do you want it to do and what is it actually doing?

Have you heard "it is a go no-go situation" before ?  It is not working on mobile for some reason when I view it I see the thumbnail but no video plays and I want it to play. I will say it again because I can't stress it enough how much I appreciate your help or anyone's help on the matter.I have started trying to learn php to hopefully help some if any on this or future problems.

If you have anymore questions please let me know.

Link to comment
Share on other sites

47 minutes ago, inferno-prime said:

Have you heard "it is a go no-go situation" before ?

Have you ever tried to take your car to a mechanic and when they asked what was wrong you said the car was "no-go"? Try that sometime and let me know what they say.

 

47 minutes ago, inferno-prime said:

when I view it I see the thumbnail but no video plays

That is useful information.

Stick the path to the video in an <a> link and click it (on mobile). What happens?

Link to comment
Share on other sites

35 minutes ago, inferno-prime said:

But for some reason on my iphone 5s it won't play.

Time for you to do a little detective work: does the browser/iOS on your iPhone 5S support playing WEBM videos? If so, is it restricted to the VP8 codec? Is that what your WEBM videos are using?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.