Project

General

Profile

Convert recordings from MythTV

Added by Geoff Selzer about 10 years ago

I currently have a MythTV-based system setup as my HTPC with MANY recordings. I am considering a move to TVheadend given all the great reviews and frustration with some aspects of Myth. Is there a tool or script to convert the Myth recordings and database to TVheadend?


Replies (6)

RE: Convert recordings from MythTV - Added by Hein Rigolo about 10 years ago

tvheadend has a different model then MythTV and also a different way of storing its recordings.

First the model part:
tvheadend at the moment allows you to record a tv program or allows you to stream a live tv program to a compatible frontend application (like Showtime or XBMC). You can not play back your recordings via tvheadend.

The recordings are stored as files using the MKV container. This means that any meta-data of that recording (date/time, channel, program name, guide information etc) can be stored in the file it self. These files are therefor independent and can me moved/copied without any problems.

There is no real database within tvheadend with the details of the recordings like there is in mythtv. There is log of what shows have been recorded, and you can see those via the web gui, but if you move them they are not removed from that log.

Because there is no database there is nothing to convert on that side. And because the recordings are not played with tvheadend you do not need to convert them to a "tvheadend format". If you favorite media player can play the mythtv files directly there is also no need to convert them. (I would suggest renaming the files to meaningful names first, but there are mythtv tools to do that)

Also tvheadend does not "expire" recordings. It is up you to maintain enough available space in the recoding directory. If you run out of space, thveadend stops recording.

I hope this answers your questions ... feel free to ask other questions as a result.

Hein

RE: Convert recordings from MythTV - Added by Geoff Selzer about 10 years ago

That helps a ton. So I assume that if I decide to stick with TVheadend I can convert my Myth recordings to mkv and everything will "match." I'm looking forward to checking it out.

Thanks

RE: Convert recordings from MythTV - Added by Anonymous almost 10 years ago

Does anyone have a sample script or ffmpeg command to do this? I understand the MythTV database structure, and it's fairly easy to extract all this information, including the recording file. I basically have two types of files, analog (PVR150/250) and digital (MPEG2-TS). It would be really good to keep all the TS data (including subtitles, additional audio channels, etc.). This is exactly what TVHeadend does, so it should be fairly simple.

RE: Convert recordings from MythTV - Added by Anonymous almost 10 years ago

Ok, I haven't fully tested the resulting command, but the following MySQL query should generate the appropriate ffmpeg commands, that will include all the MythTV metadata. You might want to do some manual checks on the commands before running them, but it should give you a good headstart.

SELECT
CONCAT (recorded.hostname, ":", recorded.title, " (", recorded.progstart, ")") recording,
CONCAT (
"ffmpeg -i ",
storagegroup.dirname, "/", recorded.basename,
" -vcodec copy -sameq -acodec copy -f matroska",
" -metadata title=\"", recorded.title, "\"",
" -metadata DATE_BROADCASTED=\"", recorded.progstart, "\"",
" -metadata ORIGINAL_MEDIA_TYPE=\"TV\"",
CASE
WHEN recorded.category IS NOT NULL
THEN CONCAT(" -metadata CONTENT_TYPE=\"", recorded.category, "\"")
END,
" -metadata TVCHANNEL=\"", channel.name, "\"",
CASE
WHEN recorded.subtitle <> "" AND recorded.description <> ""
THEN CONCAT(" -metadata SUMMARY=\"", recorded.subtitle, ". ", recorded.description, "\"")
WHEN recorded.subtitle <> ""
THEN CONCAT(" -metadata SUMMARY=\"", recorded.subtitle, "\"")
WHEN recorded.description <> ""
THEN CONCAT(" -metadata SUMMARY=\"", recorded.description, "\"")
ELSE ""
END,
" \"", storagegroup.dirname, "/",
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(recorded.title, " ", "_"), "\\", "_"), "/", "_"), "*", "_"), "<", "_"), ">", "_"), "|", "_"), "\"", "_"),
"(", REPLACE(recorded.progstart, " ", "_"), ")", ".mkv\"") converttomkv
FROM recorded, channel, storagegroup
WHERE recorded.chanid = channel.chanid
AND recorded.hostname = storagegroup.hostname
AND recorded.storagegroup = storagegroup.groupname

RE: Convert recordings from MythTV - Added by Anonymous almost 10 years ago

Well, I've tried it, but it doesn't work. Neither ffmpeg nor mkvtoolnix will convert an mpeg .ts into an MKV.

RE: Convert recordings from MythTV - Added by Eric Valette almost 10 years ago

Mark Wormgoor wrote:

Well, I've tried it, but it doesn't work. Neither ffmpeg nor mkvtoolnix will convert an mpeg .ts into an MKV.

Well as I did it for a while, I suspect you're not issuing the right commands. For mkvmerge you need version 5.0.1 at least but result is not perfect regarding timestamps.

For ffmpeg, there is a bug in 0.8.5 that prevent to correctly do it but git or earlier version do work. If the reception quality is bad and ou have bogus packet
you may get a message about non rate monotonic dts, this can be fixed by a simple on liner patch.

    (1-6/6)