Git Product home page Git Product logo

mythtv-stream-mpeg-dash's Introduction

mythtv-stream-mpeg-dash

Will allow you to transcode and stream any mythtv recording to be watched via the browser

Features:

  • Transcodes from MPEG2 or whatever format your recordings are in, as long as they are recognized by ffmpeg
  • Watch recording while transcode is still taking place (just don't seek too far ahead)
  • Use commercial skip info from mythtv database to skip commercials
  • Can transcode videos to multiple bitrates/resolutions for adaptive playback over less reliable networks (e.g. cell phone browser).

TODO:

  • Allow watching recordings that are currently being recorded (live recordings)

This depends on:

  • mythtv (for commerical skip info and looking up the name of each recording based on filename)
    • I use version v0.27
  • ffmpeg (for transcoding)
    • I use static version ffmpeg-3.2-64bit-static to best support seeking for commerical skipping
  • GNU screen
    • This is to allow monitoring of transcode and packager and to support background processes launched by the web-facing PHP script
    • apt-get install screen
  • Shaka packager
    • This consumes the transcoded video as it is being processed by ffmpeg and generates small segmented mp4 files that will be played by the browser player
    • I built it myself but there are linux builds available to download. The git version I used is similar to their release version 1.6.0.
  • Shaka player
    • This is the Javascript-based browser player that plays MPEG DASH content
    • I use version 2.0.1.

Setup:

  • Build shaka packager (or download binary) and put into a central directory that will be used for binaries (I used /home/mythtv). The name of the binary is "packager" and if you build shaka_packager, it will by located in src/out/Release or src/out/Debug, depending on whether you do a Release or Debug build.
  • Copy the static ffmpeg binary to the binaries directory also.
  • Put index.php and shaka-player.compiled.js in a directory under the web server root, preferably create one at /var/www/html/dash
  • Create another directory under the previously created one to store videos, preferably /var/www/html/dash/videos Change ownership or permissions so that the web server can write to this directory.
  • Change lines at the top of the index.php file to point to:
    • $video_path -- This is where the original mythtv recordings are. This assumes that the extension of the files are .mpg (may be different for different versions of mythtv)
    • $dash_path -- This is the dash video path (just created in the fourth step)
    • $program_path -- This is where ffmpeg and packager binaries are located (from the first two steps above)
  • Create a file called "mythdb.txt" and also add it to the directory with the binaries. This file should contain the plaintext mythtv database password. index.php assumes that the database server is running on localhost and the database username is mythtv and the database name is mythconverg. If any of these assumptions are not correct, modify the corresponding lines in index.php.
  • Optional final step: modify 2 lines of mythweb code to change ASX Stream button on the "Recorded Programs" page to DASH Stream button
    • Here is the diff:
*** /var/www/html/mythweb/modules/tv/tmpl/default/recorded.php.original
--- /var/www/html/mythweb/modules/tv/tmpl/default/recorded.php
***************
*** 158,165 ****
              echo ' -noimg">';
  ?>
          <a class="x-download"
!             href="<?php echo video_url($show, true) ?>" title="<?php echo t('ASX Stream'); ?>"
!             ><img height="24" width="24" src="<?php echo skin_url ?>/img/play_sm.png" alt="<?php echo t('ASX Stream'); ?>"></a>
          <a class="x-download"
              href="<?php echo $show->url ?>" title="<?php echo t('Direct Download'); ?>"
              ><img height="24" width="24" src="<?php echo skin_url ?>/img/video_sm.png" alt="<?php echo t('Direct Download'); ?>"></a>
--- 158,165 ----
              echo ' -noimg">';
  ?>
          <a class="x-download"
!             target="_blank" href="/dash/index.php?filename=<?php echo $show->chanid."_".gmdate('YmdHis', $show->recstartts) ?>" title="<?php echo 'DASH Stream'; ?>"
!             ><img height="24" width="24" src="<?php echo skin_url ?>/img/play_sm.png" alt="<?php echo 'DASH Stream'; ?>"></a>
          <a class="x-download"
              href="<?php echo $show->url ?>" title="<?php echo t('Direct Download'); ?>"
              ><img height="24" width="24" src="<?php echo skin_url ?>/img/video_sm.png" alt="<?php echo t('Direct Download'); ?>"></a>

That's it! If you have any trouble getting this working, file an issue in the issue tracker and I will try to get back to you. Keep in mind that this will quickly bring down a server if many people try to transcode and watch different videos all at once. If many people want to watch similar recordings, it should be fine since everybody can simultaneously watch a recording initiated by one person.

To watch TV recording, either click the top icon for your recording in the "Recorded Programs" listing (if you modified mythweb in the final step above) or find the .mpg filename in your recording directory, remove the .mpg from the filename and browse to http://yourserver/dash/index.php?filename=NNNN_NNNNNNNNNNNNNN Fill out the form to specify the quality you want and click "Watch Video".

Additional tips: If you want to add a new quality setting for a particular video, click "Cleanup Video Files" and then select another quality setting. It then will generate DASH manifest and DASH files for both the original quality setting AND the second quality setting. To interrupt the transcode and delete all generated files click "Delete Video Files". To remove only the DASH files (used for watching the recording), click "Cleanup Video Files". This will allow you to quickly regenerate the DASH video files later, without waiting for a transcode but it will consume more disk space than clicking "Delete Video Files". Please note that NONE of these buttons will delete the original source video file.

mythtv-stream-mpeg-dash's People

Contributors

thecount2a avatar

Watchers

 avatar

Forkers

alders

mythtv-stream-mpeg-dash's Issues

Build Shaka Packager

What was the specific command for building?

ninja -C out/Release

What from the results do you copy to the ffmpeg directory? Is it all the files in out/Release?

error loading dropdown

Getting this in apache error log

[Thu Feb 16 19:31:23.489761 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: filename in /var/www/html/dash/index.php on line 59
[Thu Feb 16 19:31:23.489993 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined offset: 0 in /var/www/html/dash/index.php on line 70
[Thu Feb 16 19:31:23.494272 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Warning:  mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/html/dash/index.php on line 90
[Thu Feb 16 19:31:23.494310 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined offset: 0 in /var/www/html/dash/index.php on line 107
[Thu Feb 16 19:31:23.494327 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: filename in /var/www/html/dash/index.php on line 118
[Thu Feb 16 19:31:23.494345 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: filename in /var/www/html/dash/index.php on line 118
[Thu Feb 16 19:31:23.494354 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: filename in /var/www/html/dash/index.php on line 120
[Thu Feb 16 19:31:23.494360 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: action in /var/www/html/dash/index.php on line 121
[Thu Feb 16 19:31:23.494367 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: action in /var/www/html/dash/index.php on line 148
[Thu Feb 16 19:31:23.494374 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: action in /var/www/html/dash/index.php on line 174
[Thu Feb 16 19:31:23.494388 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: filename in /var/www/html/dash/index.php on line 552
[Thu Feb 16 19:31:23.494402 2017] [:error] [pid 26936] [client 192.168.100.1:55203] PHP Notice:  Undefined index: filename in /var/www/html/dash/index.php on line 650

Looks like it is trying access the filename request parameter. Tried supplying it with no, but then it throws another exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.