[Mythnettv] mp3 podcast patch

Noah Knowles noah711 at gmail.com
Sun Aug 30 12:35:22 PDT 2009


Hi, I've been using the patch below for a few weeks to allow 
subscription to mp3 podcasts. It's ugly but it works for me. It uses 
mencoder to convert the audio file to a video file playable in MythTV. 
It uses black frames and a low vbitrate so that the encoding results in 
only about a doubling of the file size (ie a 25MB mp3 ends up as a 50MB 
mpg file).
I'm sending it in case others might find it useful. No doubt it could be 
cleaned up and made much more elegant, but that's beyond my skills ATM 
(it's the first thing I've done in Python).

Thanks Michael for mythnettv-- our household uses it a lot!
Best,
Noah

ps-- I didn't know if I could send attachments, so patch is inline 
below. Hopefully wrapping isn't a problem.


-------------------- BEGIN PATCH
*** video.py.orig    2009-08-19 22:35:54.000000000 -0700
--- video.py    2009-08-30 11:28:18.000000000 -0700
***************
*** 59,64 ****
--- 59,68 ----
        except:
          pass
 
+     if not self.values.has_key('ID_VIDEO_FORMAT'):
+       if self.values.has_key('ID_AUDIO_CODEC'):
+         self.values['ID_VIDEO_FORMAT'] = self.values['ID_AUDIO_CODEC']
+
      if len(self.values) == 0:
        raise ParseException('Could not parse video characteristics')
 
***************
*** 80,86 ****
 
      # Does need transcoding
      # Note that some avc1 videos work, and some don't -- so all get 
transcoded
!     return_true = ['avc1', 'theo', 'WMV2', 'WMV3', 'FLV1']
 
      if self.values['ID_VIDEO_FORMAT'] in return_false:
        out.write('Files in format %s don\'t need transcoding\n'
--- 84,90 ----
 
      # Does need transcoding
      # Note that some avc1 videos work, and some don't -- so all get 
transcoded
!     return_true = ['avc1', 'theo', 'WMV2', 'WMV3', 'FLV1', 'mp3']
 
      if self.values['ID_VIDEO_FORMAT'] in return_false:
        out.write('Files in format %s don\'t need transcoding\n'
***************
*** 134,147 ****
      filename.
      """
 
      # If the file is small, go for a format which will hopefully look 
nicer
      out.write('Transcoding\n')
-     format = '-ovc lavc -oac lavc -lavcopts abitrate=128 -ffourcc DX50'
-     newfilename = self.NewFilename(datadir, 'avi', out=out)
-     start_size = os.stat(self.filename)[ST_SIZE]
 
!     command = 'mencoder "%s" %s -o "%s/%s"' %(self.filename, format,
                                                datadir, newfilename)
      (status, output) = commands.getstatusoutput(command)
 
      if status != 0:
--- 138,163 ----
      filename.
      """
 
+     audio_formats = ['mp3']
+
      # If the file is small, go for a format which will hopefully look 
nicer
      out.write('Transcoding\n')
 
!     if self.values['ID_VIDEO_FORMAT'] in audio_formats:
!       # command tweaked for myth from thread 
http://lists.mplayerhq.hu/pipermail/mplayer-users/2009-January/075795.html
!       format = '-of lavf -lavfopts format=mpegts -ovc frameno -oac 
copy -rawvideo format=RGBA:w=720:h=480:fps=30000/1001 -ovc lavc 
-lavcopts vcodec=mpeg1video:vbitrate=200 -demuxer rawvideo'
!       newfilename = self.NewFilename(datadir, 'mpg', out=out)
!       endpos = self.values['ID_LENGTH']
!       command = 'mencoder /dev/zero -audiofile "%s" %s -endpos %s -o 
"%s/%s"' %(self.filename, format, endpos,
!                                               datadir, newfilename)
!     else:
!       format = '-ovc lavc -oac lavc -lavcopts abitrate=128 -ffourcc DX50'
!       newfilename = self.NewFilename(datadir, 'avi', out=out)
!       command = 'mencoder "%s" %s -o "%s/%s"' %(self.filename, format,
                                                datadir, newfilename)
+
+     start_size = os.stat(self.filename)[ST_SIZE]
+
      (status, output) = commands.getstatusoutput(command)
 
      if status != 0:
--------------------END PATCH



More information about the Mythnettv mailing list