Talk:Streaming to iPod touch or iPhone

From MythTV Official Wiki
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. Even better than this would be to read the ID_VIDEO_WIDTH and ID_VIDEO_HEIGHT coming out of `mplayer -identify` and using those values.

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"
               $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"';
                   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>

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, 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 add a directory that your webuser can see with something like


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


to this:


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 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.

I'm failing to generate anything understandable by my iTouch or Quicktime

I'm using ffmpeg version SVN-r16851 under SuSE 11.1. I had an error from ffmpeg about the "trell" option, so I replaced "-flags trell" with "-trellis 1". Then I had an error about libfaac not supporting the output format, which I got rid of by adding explicitly "-ar 44100". With those changes, the script generates a file, but both Quicktime and my itouch refuse to play it. Any ideas?

Updated - "trell" and "title" are deprecated in new builds of ffmpeg

On new builds of ffmpeg, certain options have been changed. See the main page for an updated ffmpeg line. Comment out the old line and uncomment the new one to use.

Barry253 19:07, 18 May 2009 (UTC)

Much better quality from h264

I was initially disappointed at the quality I was getting from this conversion when compared to that from HandBrake. After some experimenting, I found this alternative using h264. Files are bigger, but the quality is superb, seemingly better than anything I could get from experiments with the mpeg4 codec:

 ffmpeg -i "${directory}/${file}"  -f mp4 $ACODEC -ar 48000 -ab ${abitrate} -ac 2 -s ${width}x${height} -aspect 16:9 -vcodec libx264 -crf 20 -level 30 -coder 0 -refs 2 -flags +loop -flags2 +mixed_refs-fastpskip -me_method umh -me_range 16 -subq 6 -bf 0 -keyint_min 25 -partitions +partp8x8+parti4x4 -g 250 -trellis 2 -title "${file}" "${odirectory}/${file}.mp4"

Also, I changed the command to create ${file}.mp4.tmp and then mv that file to ${file}.mp4. That way I can have different icons for the stages of conversion: none, in progress, done.

--Glidos 15:24, 31 May 2009 (UTC)

Problem with playing video in iphone

I have tried many different ffmpeg commands, but none of my converted videos will play on my iphone, it just says: "This movie could not be played".

I get same result with

 ffmpeg -i "${directory}/${file}"  -f mp4 $ACODEC -ar 48000 -ab ${abitrate} -ac 2 -s ${width}x${height} -aspect 16:9 -vcodec libx264 -crf 20 -level 30 -coder 0 -refs 2 -flags +loop -flags2 +mixed_refs-fastpskip -me_method umh -me_range 16 -subq 6 -bf 0 -keyint_min 25 -partitions +partp8x8+parti4x4 -g 250 -trellis 2 -metadata title="${file}" "${directory}/${file}.mp4"


 ffmpeg -i "${directory}/${file}" $ACODEC -ab ${abitrate} -ac 2 -ar 44100 -s ${width}x${height} -vcodec mpeg4 -b ${vbitrate} -flags +aic+mv4 -trellis 1 -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 512k -bufsize 2M -metadata title="${file}" "${directory}/${file}.mp4"

Video can be played with mplayer and vlc, what could be the reason for this?

Here is screenshot from vlc:


Worth noting that this doesnt stream MythTV in the true sense, it will download the entire show before it plays, however, using the mod_h264_streaming plugin for apache makes it a snap to stream any mp4 in the true sense of the word


I did manage to solve my problem, it was misconfigured httpd.conf. I also made dynamic podcastfeed, that can be used from iTunes, if anyone is intrested about it, please let me know. -Hiisty (hiisty@ircnet, hiisty@freenode)


It seems that my ipod touch wants to open the m4v as a text file when I go directly to the file (shows all the h.264 encoding) The iphone 3gs seems to play the files right and open quicktime.

The file itself plays fine on the ipod touch. It's just when I go to view ANY mp4/m4v on the web, I get text. Any suggestions?

Error after editing recorded.php

I followed the instructions you posted, which were excellent by the way, by I am getting an error related to the suggested edits to recorded.php.

It reads:

!!NoTrans: file_exists(): Unable to find the wrapper "myth" - did you forget to enable it when you configured PHP?!!

I am admittedly a novice where it comes to php and perl. Do you have any suggestions?