Skip to content

Commit

Permalink
Merge remote branch 'glidos/master' into glidos-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Jul 7, 2011
2 parents 595f890 + 38fa9ed commit c13db9d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
2 changes: 2 additions & 0 deletions mythtv/programs/mythtranscode/commandlineparser.cpp 100644 → 100755
Expand Up @@ -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,
Expand Down
21 changes: 18 additions & 3 deletions mythtv/programs/mythtranscode/main.cpp 100644 → 100755
Expand Up @@ -134,6 +134,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;
Expand Down Expand Up @@ -274,6 +275,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"))
Expand Down Expand Up @@ -357,6 +360,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())
{
Expand Down Expand Up @@ -412,7 +427,7 @@ 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 "
Expand All @@ -421,7 +436,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)
Expand All @@ -443,7 +458,7 @@ int main(int argc, char *argv[])
result = transcode->TranscodeFile(infile, outfile,
profilename, useCutlist,
(fifosync || keyframesonly), jobID,
fifodir, deleteMap, AudioTrackNo,
fifodir, fifo_info, deleteMap, AudioTrackNo,
passthru);
if ((result == REENCODE_OK) && (jobID >= 0))
JobQueue::ChangeJobArgs(jobID, "RENAME_TO_NUV");
Expand Down
56 changes: 55 additions & 1 deletion mythtv/programs/mythtranscode/transcode.cpp 100644 → 100755
@@ -1,5 +1,6 @@
#include <fcntl.h>
#include <math.h>
#include <iostream>

#include <QStringList>
#include <QMap>
Expand Down Expand Up @@ -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) :
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -760,6 +763,57 @@ 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.
// Circumvent logging system so that output is independent
// of logging level.
cout << "FifoVideoWidth " << video_width << endl;
cout << "FifoVideoHeight " << video_height << endl;
cout << "FifoVideoAspectRatio "<< player->GetVideoAspect() << endl;
cout << "FifoVideoFrameRate " << video_frame_rate << endl;
cout << "FifoAudioFormat " << audio_codec_name << endl;
cout << "FifoAudioChannels " << arb->channels << endl;
cout << "FifoAudioHz " << arb->eff_audiorate << endl;

if(fifo_info)
{
// Request was for just the format of fifo data, not for
// the actual transcode, so stop here.
unlink(outputname.toLocal8Bit().constData());
if (player_ctx)
delete player_ctx;
return REENCODE_OK;
}

QString audfifo = fifodir + QString("/audout");
QString vidfifo = fifodir + QString("/vidout");
int audio_size = arb->eff_audiorate * arb->bytes_per_frame;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythtranscode/transcode.h 100644 → 100755
Expand Up @@ -20,7 +20,7 @@ class Transcode : public QObject
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; }
Expand Down

0 comments on commit c13db9d

Please sign in to comment.