summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Hurlbut <ghurlbut@mythtv.org>2011-07-08 04:19:33 (GMT)
committer Gavin Hurlbut <ghurlbut@mythtv.org>2011-07-08 04:19:47 (GMT)
commitf40668e2f2014f2101a420cfaead59525d90983b (patch)
tree2d7e2e7a3ed2e934947e7416da5dd563e3b1ccd0
parent374175d471c8d57eac274f8d4fd0b572489292bc (diff)
parent1e33dcf22fe8c44958303e3bc77c644f25fbd58d (diff)
Merge branch 'glidos-master'
Fixes #9902. This adds a --fifo-info command-line argument to mythtranscode, and also allows for remote transcoding when running in fifo mode. Additionally, the shutdown of mythtranscode has been tidied up by using a CleanupGuard that matches that of mythcommflag and other binaries.
-rwxr-xr-x[-rw-r--r--]mythtv/programs/mythtranscode/commandlineparser.cpp2
-rwxr-xr-x[-rw-r--r--]mythtv/programs/mythtranscode/main.cpp59
-rwxr-xr-x[-rw-r--r--]mythtv/programs/mythtranscode/transcode.cpp59
-rwxr-xr-x[-rw-r--r--]mythtv/programs/mythtranscode/transcode.h4
4 files changed, 117 insertions, 7 deletions
diff --git a/mythtv/programs/mythtranscode/commandlineparser.cpp b/mythtv/programs/mythtranscode/commandlineparser.cpp
index 7411fdd..49c4fef 100644..100755
--- a/mythtv/programs/mythtranscode/commandlineparser.cpp
+++ b/mythtv/programs/mythtranscode/commandlineparser.cpp
@@ -36,6 +36,8 @@ void MythTranscodeCommandLineParser::LoadArguments(void)
"Specifies the outputfile should be entirely keyframes.", "");
add(QStringList( QStringList() << "-f" << "--fifodir" ), "fifodir", "",
"Directory in which to write fifos to.", "");
+ add("--fifoinfo", "fifoinfo", false,
+ "Run in fifodir mode, but stop after displaying the fifo data format.", "");
add("--fifosync", "fifosync", false, "Enforce fifo sync.", "");
add("--passthrough", "passthru", false, "Pass through raw, unprocessed audio.", "");
add(QStringList( QStringList() << "-b" << "--buildindex" ), "reindex", false,
diff --git a/mythtv/programs/mythtranscode/main.cpp b/mythtv/programs/mythtranscode/main.cpp
index 44bc5c9..374d116 100644..100755
--- a/mythtv/programs/mythtranscode/main.cpp
+++ b/mythtv/programs/mythtranscode/main.cpp
@@ -121,6 +121,34 @@ static int QueueTranscodeJob(ProgramInfo *pginfo, QString profile,
return GENERIC_EXIT_DB_ERROR;
}
+namespace
+{
+ void cleanup()
+ {
+ delete gContext;
+ gContext = NULL;
+
+ }
+
+ class CleanupGuard
+ {
+ public:
+ typedef void (*CleanupFunc)();
+
+ public:
+ CleanupGuard(CleanupFunc cleanFunction) :
+ m_cleanFunction(cleanFunction) {}
+
+ ~CleanupGuard()
+ {
+ m_cleanFunction();
+ }
+
+ private:
+ CleanupFunc m_cleanFunction;
+ };
+}
+
int main(int argc, char *argv[])
{
uint chanid;
@@ -134,6 +162,7 @@ int main(int argc, char *argv[])
bool useCutlist = false, keyframesonly = false;
bool build_index = false, fifosync = false;
bool mpeg2 = false;
+ bool fifo_info = false;
QMap<QString, QString> settingsOverride;
frm_dir_map_t deleteMap;
frm_pos_map_t posMap;
@@ -274,6 +303,8 @@ int main(int argc, char *argv[])
build_index = true;
if (cmdline.toBool("fifodir"))
fifodir = cmdline.toString("fifodir");
+ if (cmdline.toBool("fifoinfo"))
+ fifo_info = true;
if (cmdline.toBool("fifosync"))
fifosync = true;
if (cmdline.toBool("recopt"))
@@ -299,6 +330,7 @@ int main(int argc, char *argv[])
if (cmdline.toBool("passthru"))
passthru = true;
+ CleanupGuard callCleanup(cleanup);
// Load the context
gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
@@ -357,6 +389,18 @@ int main(int argc, char *argv[])
cerr << "Must specify --fifodir to use --fifosync\n";
return GENERIC_EXIT_INVALID_CMDLINE;
}
+ if (fifo_info && !fifodir.isEmpty())
+ {
+ cerr << "Cannot specify both --fifodir and --fifoinfo\n";
+ return GENERIC_EXIT_INVALID_CMDLINE;
+ }
+
+ if (fifo_info)
+ {
+ // Setup a dummy fifodir path, so that the "fifodir" code path
+ // is taken. The path wont actually be used.
+ fifodir = "DummyFifoPath";
+ }
if (!MSqlQuery::testDBConnection())
{
@@ -412,7 +456,8 @@ int main(int argc, char *argv[])
return QueueTranscodeJob(pginfo, profilename, hostname, useCutlist);
}
- if (infile.left(7) == "myth://" && (outfile.isNull() || outfile != "-"))
+ if (infile.left(7) == "myth://" && (outfile.isNull() || outfile != "-") &&
+ fifodir.isEmpty())
{
VERBOSE(VB_IMPORTANT, QString("Attempted to transcode %1. "
"Mythtranscode is currently unable to transcode remote "
@@ -421,7 +466,7 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_REMOTE_FILE;
}
- if (outfile.isNull() && !build_index)
+ if (outfile.isNull() && !build_index && fifodir.isEmpty())
outfile = infile + ".tmp";
if (jobID >= 0)
@@ -443,12 +488,18 @@ int main(int argc, char *argv[])
result = transcode->TranscodeFile(infile, outfile,
profilename, useCutlist,
(fifosync || keyframesonly), jobID,
- fifodir, deleteMap, AudioTrackNo,
- passthru);
+ fifodir, fifo_info, deleteMap,
+ AudioTrackNo, passthru);
if ((result == REENCODE_OK) && (jobID >= 0))
JobQueue::ChangeJobArgs(jobID, "RENAME_TO_NUV");
}
+ if (fifo_info)
+ {
+ delete transcode;
+ return GENERIC_EXIT_OK;
+ }
+
int exitcode = GENERIC_EXIT_OK;
if ((result == REENCODE_MPEG2TRANS) || mpeg2 || build_index)
{
diff --git a/mythtv/programs/mythtranscode/transcode.cpp b/mythtv/programs/mythtranscode/transcode.cpp
index 17522dd..52d99b3 100644..100755
--- a/mythtv/programs/mythtranscode/transcode.cpp
+++ b/mythtv/programs/mythtranscode/transcode.cpp
@@ -1,5 +1,6 @@
#include <fcntl.h>
#include <math.h>
+#include <iostream>
#include <QStringList>
#include <QMap>
@@ -226,8 +227,9 @@ class AudioReencodeBuffer : public AudioOutput
int audiobuffer_len, audiobuffer_frames;
int channels, bits, bytes_per_frame, eff_audiorate;
long long last_audiotime;
+ bool m_passthru;
private:
- bool m_passthru, m_initpassthru;
+ bool m_initpassthru;
};
Transcode::Transcode(ProgramInfo *pginfo) :
@@ -378,6 +380,7 @@ int Transcode::TranscodeFile(
const QString &profileName,
bool honorCutList, bool framecontrol,
int jobID, QString fifodir,
+ bool fifo_info,
frm_dir_map_t &deleteMap,
int AudioTrackNo,
bool passthru)
@@ -760,6 +763,60 @@ int Transcode::TranscodeFile(
if (!fifodir.isEmpty())
{
+ AudioPlayer *aplayer = player->GetAudio();
+ const char *audio_codec_name;
+
+ switch(aplayer->GetCodec())
+ {
+ case CODEC_ID_AC3:
+ audio_codec_name = "ac3";
+ break;
+ case CODEC_ID_EAC3:
+ audio_codec_name = "eac3";
+ break;
+ case CODEC_ID_DTS:
+ audio_codec_name = "dts";
+ break;
+ case CODEC_ID_TRUEHD:
+ audio_codec_name = "truehd";
+ break;
+ case CODEC_ID_MP3:
+ audio_codec_name = "mp3";
+ break;
+ case CODEC_ID_MP2:
+ audio_codec_name = "mp2";
+ break;
+ default:
+ audio_codec_name = "unknown";
+ }
+
+ if (!arb->m_passthru)
+ audio_codec_name = "raw";
+
+ // Display details of the format of the fifo data.
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoVideoWidth %1").arg(video_width));
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoVideoHeight %1").arg(video_height));
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoVideoAspectRatio %1").arg(player->GetVideoAspect()));
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoVideoFrameRate %1").arg(video_frame_rate));
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoAudioFormat %1").arg(audio_codec_name));
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoAudioChannels %1").arg(arb->channels));
+ LOG(VB_GENERAL, LOG_INFO,
+ QString("FifoAudioSampleRate %1").arg(arb->eff_audiorate));
+
+ if(fifo_info)
+ {
+ // Request was for just the format of fifo data, not for
+ // the actual transcode, so stop here.
+ unlink(outputname.toLocal8Bit().constData());
+ return REENCODE_OK;
+ }
+
QString audfifo = fifodir + QString("/audout");
QString vidfifo = fifodir + QString("/vidout");
int audio_size = arb->eff_audiorate * arb->bytes_per_frame;
diff --git a/mythtv/programs/mythtranscode/transcode.h b/mythtv/programs/mythtranscode/transcode.h
index 83aa1d6..19e8649 100644..100755
--- a/mythtv/programs/mythtranscode/transcode.h
+++ b/mythtv/programs/mythtranscode/transcode.h
@@ -15,18 +15,18 @@ class Transcode : public QObject
{
public:
Transcode(ProgramInfo *pginfo);
+ ~Transcode();
int TranscodeFile(
const QString &inputname,
const QString &outputname,
const QString &profileName,
bool honorCutList, bool framecontrol, int jobID,
- QString fifodir, frm_dir_map_t &deleteMap,
+ QString fifodir, bool fifo_info, frm_dir_map_t &deleteMap,
int AudioTrackNo, bool passthru = false);
void ShowProgress(bool val) { showprogress = val; }
void SetRecorderOptions(QString options) { recorderOptions = options; }
private:
- ~Transcode();
bool GetProfile(QString profileName, QString encodingType, int height,
int frameRate);
void ReencoderAddKFA(long curframe, long lastkey, long num_keyframes);