Skip to content

Commit

Permalink
Change the default file extension for recordings from .mpg to .ts
Browse files Browse the repository at this point in the history
.ts is the correct extension for untranscoded recordings from digital
recorders which use the MPEG-TS container. We have been incorrectly
using the .mpg extension which is only valid for containers such as
MPEG-PS

Some video players use the extension, or for streams the mimetype
which is derived from the extension in order to correctly parse the
files.
  • Loading branch information
stuartm committed Feb 13, 2015
1 parent d8e11b2 commit 6576614
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 24 deletions.
32 changes: 20 additions & 12 deletions mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -2399,10 +2399,20 @@ bool ProgramInfo::SaveBasename(const QString &basename)
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("UPDATE recorded "
"SET basename = :BASENAME "
"WHERE chanid = :CHANID AND "
" starttime = :STARTTIME;");
query.bindValue(":CHANID", chanid);
query.bindValue(":STARTTIME", recstartts);
"WHERE recordedid = :RECORDEDID;");
query.bindValue(":RECORDEDID", recordedid);
query.bindValue(":BASENAME", basename);

if (!query.exec())
{
MythDB::DBError("SetRecordBasename", query);
return false;
}

query.prepare("UPDATE recordedfile "
"SET basename = :BASENAME "
"WHERE recordedid = :RECORDEDID;");
query.bindValue(":RECORDEDID", recordedid);
query.bindValue(":BASENAME", basename);

if (!query.exec())
Expand All @@ -2422,7 +2432,7 @@ bool ProgramInfo::SaveBasename(const QString &basename)
* If the base part of pathname is not empty this will return
* that value otherwise this queries the recorded table in the
* DB for the basename stored there for this ProgramInfo's
* chanid and recstartts.
* recordedid
*/
QString ProgramInfo::QueryBasename(void) const
{
Expand All @@ -2433,11 +2443,9 @@ QString ProgramInfo::QueryBasename(void) const
MSqlQuery query(MSqlQuery::InitCon());
query.prepare(
"SELECT basename "
"FROM recorded "
"WHERE chanid = :CHANID AND "
" starttime = :STARTTIME");
query.bindValue(":CHANID", chanid);
query.bindValue(":STARTTIME", recstartts);
"FROM recordedfile "
"WHERE recordedid = :RECORDEDID;");
query.bindValue(":RECORDEDID", recordedid);

if (!query.exec())
{
Expand All @@ -2450,8 +2458,8 @@ QString ProgramInfo::QueryBasename(void) const
else
{
LOG(VB_GENERAL, LOG_INFO,
QString("QueryBasename found no entry for %1 @ %2")
.arg(chanid).arg(recstartts.toString(Qt::ISODate)));
QString("QueryBasename found no entry for recording ID %1")
.arg(recordedid));
}

return QString();
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/jobqueue.cpp
Expand Up @@ -2028,6 +2028,7 @@ void JobQueue::DoTranscodeThread(int jobID)
ChangeJobStatus(jobID, JOB_FINISHED, tr("Finished."));
retry = false;

program_info->Reload(); // Refresh, the basename may have changed
filename = program_info->GetPlaybackURL(false, true);
QFileInfo st(filename);

Expand Down
8 changes: 6 additions & 2 deletions mythtv/libs/libmythtv/recorders/channelbase.cpp
Expand Up @@ -1174,7 +1174,7 @@ ChannelBase *ChannelBase::CreateChannel(
bool enter_power_save_mode,
QString &rbFileExt)
{
rbFileExt = "mpg";
rbFileExt = "ts";

ChannelBase *channel = NULL;
if (genOpt.cardtype == "DVB")
Expand Down Expand Up @@ -1203,8 +1203,9 @@ ChannelBase *ChannelBase::CreateChannel(
genOpt.videodev.toLower().startsWith("file:")))
{
channel = new DummyChannel(tvrec);
rbFileExt = "mpg";
}
else if (genOpt.cardtype == "FREEBOX")
else if (genOpt.cardtype == "FREEBOX") // IPTV
{
#ifdef USING_IPTV
channel = new IPTVChannel(tvrec, genOpt.videodev);
Expand All @@ -1229,10 +1230,13 @@ ChannelBase *ChannelBase::CreateChannel(
#endif
if ((genOpt.cardtype != "MPEG") && (genOpt.cardtype != "HDPVR"))
rbFileExt = "nuv";
else
rbFileExt = "mpg";
}
else if (genOpt.cardtype == "EXTERNAL")
{
channel = new ExternalChannel(tvrec, genOpt.videodev);
rbFileExt = "mpg";
}

if (!channel)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -118,7 +118,7 @@ TVRec::TVRec(int capturecardnum)
// tvchain
tvchain(NULL),
// RingBuffer info
ringBuffer(NULL), rbFileExt("mpg")
ringBuffer(NULL), rbFileExt("ts")
{
QMutexLocker locker(&cardsLock);
cards[cardid] = this;
Expand Down
6 changes: 2 additions & 4 deletions mythtv/libs/libmythupnp/httprequest.cpp
Expand Up @@ -121,7 +121,7 @@ static MIMETypes g_MIMETypes[] =
{ "mkv" , "video/x-matroska" }, // See http://matroska.org/technical/specs/notes.html#MIME (See NOTE 1)
{ "nuv" , "video/nupplevideo" },
{ "ogv" , "video/ogg" }, // Defined: http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
{ "ts" , "video/mp2t" }, // HTTP Live Streaming
{ "ts" , "video/mp2t" },
{ "vob" , "video/mpeg" },
{ "wmv" , "video/x-ms-wmv" }
};
Expand Down Expand Up @@ -1567,10 +1567,8 @@ bool HTTPRequest::ParseRange( QString sRange,
return false;
}

#if 0
LOG(VB_GENERAL, LOG_DEBUG, QString("%1 Range Requested %2 - %3")
LOG(VB_HTTP, LOG_DEBUG, QString("%1 Range Requested %2 - %3")
.arg(getSocketHandle()) .arg(*pllStart) .arg(*pllEnd));
#endif

return true;
}
Expand Down
16 changes: 11 additions & 5 deletions mythtv/programs/mythtranscode/main.cpp
Expand Up @@ -890,13 +890,19 @@ static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
newSize = st.size();

QString cnf = filename;
if ((jobArgs == "RENAME_TO_NUV") &&
(filename.contains(QRegExp("mpg$"))))
if (filename.endsWith(".mpg") && jobArgs == "RENAME_TO_NUV")
{
QString newbase = pginfo->QueryBasename();

cnf.replace(QRegExp("mpg$"), "nuv");
newbase.replace(QRegExp("mpg$"), "nuv");
cnf.replace(".mpg", ".nuv");
newbase.replace(".mpg", ".nuv");
pginfo->SaveBasename(newbase);
}
else if (filename.endsWith(".ts"))
{
QString newbase = pginfo->QueryBasename();
// MPEG-TS to MPEG-PS
cnf.replace(".ts", ".mpg");
newbase.replace(".ts", ".mpg");
pginfo->SaveBasename(newbase);
}

Expand Down

0 comments on commit 6576614

Please sign in to comment.