Joined: 02 Apr 2008
|Posted: Mon Aug 11, 2008 11:14 pm Post subject: A simple hack: playing audios as videos
|I have a lot of MP3s that are seminar and workshop recordings, which are a pain to play in Windows Media Player or using the Tivo's music functions. You don't get instant replay, and you can't save your place so that you can do something else and then come back where you left off.
So yesterday I came up with a little hack for pyTivo to let it treat audio files as if they were video files. Basically, you add '.mp3' (and whatever else) to your 'video.ext' file, and then make a few minor changes to transcode.py.
Specifically, you have to change the video_info() function to have a codec of 'none' when the file doesn't have a video codec, to default width and height to 720x480, and fps to '29.97'. Then, after all the regex checks are done, you check whether "acodec is None and codec=='none'", and if so, bail out with a bunch of None's (after caching that, of course).
That change makes it so that audio files will be treated as video files, and any files that are neither video nor audio will be ignored, as before.
The second change you need to make is in the transcode function, changing the existing command line creation to:
cmd = [ffmpeg_path(), '-i', inFile]
type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar = \
cmd += ['-loop_input', '-i', r'SomeImgage.gif', '-t', '%.3f'%(millisecs/1000.0)]
cmd += cmd_string.split()
Replacing "SomeImage.gif" with the full path to some image file. Basically, this takes the image file and loops it for the full length of the audio, making that the video channel of what's sent to the Tivo. It's not ideal, in that I think the aspect ratio is off in some way. I haven't played with that much. If you just use an all-black image, though, I don't imagine it will make a difference.
Anyway, it seems to work for me. (The -t part to specify the duration is essential, as without it, ffmpeg keeps generating video forever and the transfer never finishes.)