Talk:Streaming to iPod touch or iPhone

From MythTV Official Wiki
Revision as of 00:39, 18 November 2008 by Jflatt (talk | contribs)

Jump to: navigation, search

If you're having a problem post here and I'll try and help.

When experimenting to write this page I basically followed the following steps before getting everything right:

  1. Perform the transcoding and see if it plays well in mplayer
  2. Put the file into the root of the web-server, update mime-type and see if it plays on iPod
  3. Put the file back into the myth directory, link from data/recordings/ under mythweb, and see if it can find it
  4. Update php files to detect/link to correct files.


The resolutions are 432x240 for widescreen, or 480x360 for standard def. Since the resolution of the iphone is 480x320, I find 480x270 and 428x320 a better fit.


To put an icon in mythweb by the asx stream and download icons, you can make these changes to the recorded.php. You should see <a> for ASX and Direct Download around line 320, just add an additional <a>. You'll also need to provide your own image.

       <a class="x-download"
           href="<?php echo $show->url ?>" title="<?php echo t('Direct Download'); ?>"
           ><img src="<?php echo skin_url ?>img/video_sm.png" alt="<?php echo t('Direct Download'); ?>"></a>
       <a class="x-download"
           href="<?php
               $file='/mnt/store/TV/' . basename($show->filename) . '.mp4';
               if (file_exists($file))
                   echo '/mythweb/data/recordings/' . basename($show->filename) . '.mp4" alt="iPhone Stream" title="iPhone Stream"';
               else
                   echo '/mythweb/data/ipodencoder.php?file=recordings/' . basename($show->filename) . '&convert=true" alt="iPhone Encode" title="iPhone Encode"';
           ?>
           ><img src="<?php echo skin_url ?>img/quicktime.png"></a>
       </td>


If you get an error like this: "/mnt/store/TV/1081_20081110203000.mpg: no such file or directory" coming out of ffmpeg, it may be due to the quotation marks in the script. Removing the quotes around ${director}/${file} worked for me


Mgrusin, try '-acodec aac' Some older versions of ffmpeg have different switches.--Bob.os 01:35, 30 November 2007 (UTC)


When I manually execute the ffmpeg line in mythipod.sh, it fails with:

 mgrusin@Bender:/usr/local/bin$ ffmpeg -i /video/1048_20071124190000.mpg -acodec libfaac -ab ${abitrate} -s ${width}x${height} 
 -vcodec mpeg4 -b ${vbitrate} -flags +aic+mv4+trell -mbd 2 -cmp
 
 FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
 configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg 
 --enable-libgsm --enable-dc1394 --disable-debug --enable-libmp3lame --enable-libfaadbin --enable-libfaad --enable-libfaac --enable-xvid 
 --enable-x264 --enable-amr_nb --enable-amr_wb --enable-shared --prefix=/usr
 libavutil version: 1d.49.3.0
 libavcodec version: 1d.51.38.0
 libavformat version: 1d.51.10.0
 built on Nov 17 2007 21:23:57, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
 Input #0, mpeg, from '/video/1048_20071124190000.mpg':
 Duration: 01:59:38.0, start: 0.289367, bitrate: 5205 kb/s
 Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 480x480, 6000 kb/s, 29.97 fps(r)
 Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, 384 kb/s
 Unknown codec 'libfaac'

"ffmpeg -version" reports "--enable libfaac", and libfaac0 appears to be installed (this is on mythbuntu). What else should I check or try? Thanks for any help! Mgrusin 04:12, 27 November 2007 (UTC)


I'm wondering, will this work with storage groups?--Bob.os 22:03, 18 November 2007 (UTC)

Yes, but you would probably do better to put the files in a specific location. So you could set the output of the transcoding stop to a known location, then modify the PHP page (and expire script) to look in those directories specifically

In myth2ipod.sh add a directory that your webuser can see with something like

   ipoddirectory=/srv/www/htdocs/ipodvideos/

and then at the end where the ffmpeg command is, change this:

 "${directory}/${file}.mp4" 

to this:

 "${ipoddirectory}/${file}.mp4" 

The expire script would be a tiny bit more complicated as you'd have to, for each file in your ipoddirectory check if there was a corresponding file in any of the directories.

You would also change your php file from this:

   if(file_exists($show->filename . '.mp4')){
       echo '<a href="/mythweb/data/recordings/' . $file . '.mp4" target="_blank">Watch</a> ';
       echo "</b>";

to something like this:

   if(file_exists('/srv/www/htdocs/ipodvideos/'. $file . '.mp4')){
       echo '<a href="/srv/www/htdocs/ipodvideos/'. $file . '.mp4" target="_blank">Watch</a> ';
       echo "</b>";

Problem with security enabled

I get the streaming to work correctly as long as I have no security enabled to MythWeb, but as soon as I enable the security in the .htaccess file I just get "Error playing movie" from the quicktime player. The rest of the MythWeb interface works with security enabled, so it is just the movie streaming that doesn't work.

The .htaccess file is configured with AuthType=Digest

Erland 08:56, 30 December 2007 (UTC)

--

I'm having the same problem with "Error playing movie". Can you detail (or point to) how to disable security so I can test? I'm running KnoppMyth R5F1 is that helps. Thx, Too Many Secrets. <edit> found ToggleWebSecurity.sh which will disable security, enabling streaming.<edit>

--

Is there any fix for the security issue? I'd like to stream via EDGE, but don't want to open my box to the world.

--Too Many Secrets 15:57, 21 February 2008 (UTC)

Can you just move Mythweb into a subdirectory with a complex/random name so it can't be found by bots/accident? Might cause problems with upgrading, though. --Gw 23:31, 21 February 2008 (UTC)

I created an unsecured iphone data folder within my mythweb folder and altered the encoding script path and path in recorded.php to point to this folder. That way mythweb (and the only spiderable link) still requires authentication. Only the video files themselves do not. --Scotru 18:28, 23 March 2008 (UTC)

iPhone pages

I followed the instructions and got it working -- it's fantastic. However, I see room for improvement by adding a couple of pages to MythWeb.

First a simplified iPhone-specific page (iphone.php), like you see on other sites that would list just the videos where your transcoded mp4s are available for immediate viewing (would check for the presence of the mp4, the same way as the "Encode"/"Watch" switch works).

Secondly, to make it easy to sync myth videos to iTunes when I can't stream, a dynamically-built Podcast would be really great so I could just sync the videos I want to reside on the iPhone through iTunes. The Podcast/XML feed (podcast.php) would consist of the same mp4s. This would make it *much* easier to sync videos when connected to my LAN when I know I won't have fast connectivity later.

I started to create these two pages but can't quite figure out how mythweb works (siimply adding a page didn't work as expected), and won't have much spare time for another few weeks. If anyone could simply identify which files need to be touched to add an iphone.php page and podcast.php page, that would be a big help. If anyone wants to take it farther, better still. :) Scott459 19:26, 19 August 2008 (UTC)

MythWeb iPhone specific pages

This is quite literally an awesome idea, however I'm not PHP whiz either.

Scott459, I think the first thing you need is to use the include files (found in mythweb/include) as the base. Unfortunately my PHP-Fu is very weak. If you do get started on this then let me know and I'll do whatever I can to help. (I know some very basic PHP, all I know I basically learned for this) I'm interested too, so maybe it would be a bit of motivation. --Ugly 05:51, 4 November 2008 (UTC)