mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-07 17:32:20 +02:00
2017-05-26 Fred Gleason <fredg@paravelsystems.com>
* Added rdconvert(1).
This commit is contained in:
parent
27075036d1
commit
2c1f1c6a59
1
.gitignore
vendored
1
.gitignore
vendored
@ -85,6 +85,7 @@ tests/timer_test
|
||||
tests/upload_test
|
||||
tests/wav_chunk_test
|
||||
utils/rdauth/rdauth
|
||||
utils/rdconvert/rdconvert
|
||||
utils/rdhpiinfo/rdhpiinfo
|
||||
utils/rddgimport/rddgimport
|
||||
utils/rddiscimport/rddiscimport
|
||||
|
@ -15812,3 +15812,5 @@
|
||||
configuration but was beyond the number of active GPIOS set.
|
||||
2017-05-25 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Incremented the package version to 2.15.3int08.
|
||||
2017-05-26 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added rdconvert(1).
|
||||
|
@ -473,6 +473,7 @@ AC_CONFIG_FILES([rivendell.spec \
|
||||
utils/rdcleandirs/Makefile \
|
||||
utils/rdclilogedit/Makefile \
|
||||
utils/rdcollect/Makefile \
|
||||
utils/rdconvert/Makefile \
|
||||
utils/rddbcheck/Makefile \
|
||||
utils/rddelete/Makefile \
|
||||
utils/rddgimport/Makefile \
|
||||
|
@ -34,6 +34,7 @@
|
||||
all-local: cae.html\
|
||||
cae.pdf\
|
||||
rdclilogedit.1\
|
||||
rdconvert.1\
|
||||
rddbcheck.8\
|
||||
rdmarkerset.8\
|
||||
rdrevert.8\
|
||||
@ -45,6 +46,7 @@ all-local: cae.html\
|
||||
web_api.pdf
|
||||
|
||||
man_MANS = rdclilogedit.1\
|
||||
rdconvert.1\
|
||||
rddbcheck.8\
|
||||
rdexport.1\
|
||||
rdimport.1\
|
||||
@ -56,6 +58,8 @@ EXTRA_DIST = cae.html\
|
||||
cae.xml\
|
||||
rdclilogedit.1\
|
||||
rdclilogedit.xml\
|
||||
rdconvert.1\
|
||||
rdconvert.xml\
|
||||
rddbcheck.8\
|
||||
rddbcheck.xml\
|
||||
rdmarkerset.8\
|
||||
|
261
docs/docbook/rdconvert.xml
Normal file
261
docs/docbook/rdconvert.xml
Normal file
@ -0,0 +1,261 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<refentry id="stdin" xmlns="http://docbook.org/ns/docbook" version="5.0">
|
||||
<!--
|
||||
Header
|
||||
-->
|
||||
<refmeta>
|
||||
<refentrytitle>rdconvert</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class='source'>May 2017</refmiscinfo>
|
||||
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>rdconvert</refname>
|
||||
<refpurpose>Convert an audio file to a different format</refpurpose>
|
||||
</refnamediv>
|
||||
<info>
|
||||
<author>
|
||||
<personname>
|
||||
<firstname>Fred</firstname>
|
||||
<surname>Gleason</surname>
|
||||
<email>fredg@paravelsystems.com</email>
|
||||
</personname>
|
||||
<contrib>Application Author</contrib>
|
||||
</author>
|
||||
</info>
|
||||
|
||||
<!--
|
||||
Body
|
||||
-->
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>rdconvert</command>
|
||||
<arg choice='opt'><replaceable>OPTIONS</replaceable></arg>
|
||||
<arg choice='req'><replaceable>src-file</replaceable></arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id='description'><title>Description</title>
|
||||
<para>
|
||||
<command>rdconvert</command><manvolnum>1</manvolnum> can be used to convert
|
||||
audio files between different formats.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='options'><title>Options</title>
|
||||
<variablelist remap='TP'>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--destination-bit-rate=</option><replaceable>bit-rate</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use a bit rate of <replaceable>bit-rate</replaceable> bits per
|
||||
second. This option is ignored for PCM and FLAC formats, and is
|
||||
mutually exclusive with the <option>--destination-quality</option>
|
||||
option. The default value is <userinput>0</userinput>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--destination-channels=</option><replaceable>chans</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use <replaceable>chans</replaceable> channels. Supported values
|
||||
are <userinput>1</userinput> and <userinput>2</userinput>. The
|
||||
default value is <userinput>2</userinput>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--destination-file=</option><replaceable>filename</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Write the converted data to <replaceable>filename</replaceable>.
|
||||
If not specified, the data will be written to the name of the
|
||||
input file with the default extension of the destination format
|
||||
appended.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--destination-format=</option><replaceable>format</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Write the converted data to the specified format.
|
||||
<replaceable>format</replaceable> can be one of the following:
|
||||
</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><userinput>0</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
PCM16 WAV
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><userinput>2</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
MPEG Layer 2 (Raw)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><userinput>3</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
MPEG Layer 3 (Raw)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><userinput>4</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Free Lossless Audio Codec (FLAC)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><userinput>5</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
OggVorbis
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><userinput>6</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
MPEG Layer 2 (BWF WAV Container)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><userinput>7</userinput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
PCM24 WAV
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--destination-quality=</option><replaceable>qual</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use a variable bitrate with a quality of
|
||||
<replaceable>chans</replaceable>. Supported values
|
||||
are <userinput>-1</userinput> through <userinput>10</userinput>.
|
||||
This parameter is used only with a format of <userinput>5</userinput>
|
||||
(OggVorbis). The default value is <userinput>0</userinput>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--destination-sample-rate=</option><replaceable>rate</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use a sample rate of <replaceable>rate</replaceable> samples per
|
||||
second. Not all sample rates are supported for all formats; see
|
||||
the relevant MPEG specifications for details. The default value is
|
||||
<userinput>48000</userinput>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--end-point=</option><replaceable>msec</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Stop converting the audio data at the point
|
||||
<replaceable>msec</replaceable> mS from the start of the source
|
||||
file. A value of <userinput>-1</userinput> means to continue
|
||||
conversion to the end of the source file, which is the default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--normalization-level=</option><replaceable>lvl</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Peak-normalize the audio to <replaceable>lvl</replaceable> dBFS.
|
||||
A value of <userinput>0</userinput> disables normalization, which
|
||||
is the default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--speed-ratio=</option><replaceable>ratio</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Alter the tempo of the audio by <replaceable>ratio</replaceable>.
|
||||
A value of <userinput>1.0</userinput> specifies no tempo alteration,
|
||||
which is the default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--start-point=</option><replaceable>msec</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Start converting the audio data at the point
|
||||
<replaceable>msec</replaceable> mS into the source file. The
|
||||
default value is <userinput>0</userinput>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='see_also'><title>See Also</title>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdexport</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>
|
||||
<literal>,</literal>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdimport</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>
|
||||
<literal>,</literal>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdmarkerset</refentrytitle><manvolnum>8</manvolnum>
|
||||
</citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
@ -397,6 +397,10 @@
|
||||
|
||||
<refsect1 id='see_also'><title>See Also</title>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdconvert</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>
|
||||
<literal>,</literal>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdimport</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>
|
||||
|
@ -815,6 +815,10 @@
|
||||
|
||||
<refsect1 id='see_also'><title>See Also</title>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdimport</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>
|
||||
<literal>,</literal>
|
||||
<citerefentry>
|
||||
<refentrytitle>rdexport</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>
|
||||
|
@ -276,6 +276,41 @@ QString RDSettings::pathName(const QString &stationname,QString pathname,
|
||||
}
|
||||
|
||||
|
||||
QString RDSettings::defaultExtension(RDSettings::Format fmt)
|
||||
{
|
||||
QString ret="dat";
|
||||
|
||||
switch(fmt) {
|
||||
case RDSettings::Pcm16:
|
||||
case RDSettings::Pcm24:
|
||||
case RDSettings::MpegL2Wav:
|
||||
ret="wav";
|
||||
break;
|
||||
|
||||
case RDSettings::MpegL1:
|
||||
ret="mp1";
|
||||
break;
|
||||
|
||||
case RDSettings::MpegL2:
|
||||
ret="mp2";
|
||||
break;
|
||||
|
||||
case RDSettings::MpegL3:
|
||||
ret="mp3";
|
||||
break;
|
||||
|
||||
case RDSettings::Flac:
|
||||
ret="flac";
|
||||
break;
|
||||
|
||||
case RDSettings::OggVorbis:
|
||||
ret="ogg";
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QString RDSettings::defaultExtension(const QString &stationname,
|
||||
RDSettings::Format fmt)
|
||||
{
|
||||
|
@ -53,6 +53,7 @@ class RDSettings
|
||||
QString resolvedCustomCommandLine(const QString &destfile);
|
||||
static QString pathName(const QString &stationname,QString pathname,
|
||||
RDSettings::Format fmt);
|
||||
static QString defaultExtension(RDSettings::Format fmt);
|
||||
static QString defaultExtension(const QString &stationname,
|
||||
RDSettings::Format fmt);
|
||||
static unsigned bytesPerSec(const QString &stationname,
|
||||
|
@ -237,6 +237,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
@LOCAL_PREFIX@/bin/rdpurgecasts
|
||||
@LOCAL_PREFIX@/bin/rdmaint
|
||||
@LOCAL_PREFIX@/bin/rdcollect
|
||||
@LOCAL_PREFIX@/bin/rdconvert
|
||||
@LOCAL_PREFIX@/bin/rdcheckcuts
|
||||
@LOCAL_PREFIX@/bin/rd_audio_sync
|
||||
@LOCAL_PREFIX@/bin/rd_config
|
||||
@ -289,9 +290,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/etc/pam.d/rivendell
|
||||
/etc/pam.d/rdalsaconfig-root
|
||||
/etc/security/console.apps/rdalsaconfig-root
|
||||
%{_mandir}/man1/rdclilogedit.1.gz
|
||||
%{_mandir}/man1/rdconvert.1.gz
|
||||
%{_mandir}/man1/rdexport.1.gz
|
||||
%{_mandir}/man1/rdimport.1.gz
|
||||
%{_mandir}/man1/rdclilogedit.1.gz
|
||||
%{_mandir}/man8/rddbcheck.8.gz
|
||||
%{_mandir}/man8/rdmarkerset.8.gz
|
||||
%{_mandir}/man8/rdrevert.8.gz
|
||||
|
@ -36,6 +36,7 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\
|
||||
rdcleandirs\
|
||||
rdclilogedit\
|
||||
rdcollect\
|
||||
rdconvert\
|
||||
rddelete\
|
||||
rddiscimport\
|
||||
rdexport\
|
||||
|
50
utils/rdconvert/Makefile.am
Normal file
50
utils/rdconvert/Makefile.am
Normal file
@ -0,0 +1,50 @@
|
||||
## automake.am
|
||||
##
|
||||
## Automake.am for rivendell/utils/rdconvert
|
||||
##
|
||||
## (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License version 2 as
|
||||
## published by the Free Software Foundation.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public
|
||||
## License along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
## Use automake to process this into a Makefile.in
|
||||
|
||||
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib
|
||||
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
|
||||
MOC = @QT_MOC@
|
||||
|
||||
# The dependency for qt's Meta Object Compiler (moc)
|
||||
moc_%.cpp: %.h
|
||||
$(MOC) $< -o $@
|
||||
|
||||
bin_PROGRAMS = rdconvert
|
||||
|
||||
dist_rdconvert_SOURCES = rdconvert.cpp rdconvert.h
|
||||
|
||||
rdconvert_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
|
||||
|
||||
CLEANFILES = *~\
|
||||
*.exe\
|
||||
*.idb\
|
||||
*ilk\
|
||||
*.obj\
|
||||
*.pdb\
|
||||
*.qm\
|
||||
moc_*
|
||||
|
||||
MAINTAINERCLEANFILES = *~\
|
||||
*.tar.gz\
|
||||
aclocal.m4\
|
||||
configure\
|
||||
Makefile.in\
|
||||
moc_*
|
209
utils/rdconvert/rdconvert.cpp
Normal file
209
utils/rdconvert/rdconvert.cpp
Normal file
@ -0,0 +1,209 @@
|
||||
// rdconvert.cpp
|
||||
//
|
||||
// Rivendell file format converter.
|
||||
//
|
||||
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <rddb.h>
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdaudioconvert.h>
|
||||
|
||||
#include "rdconvert.h"
|
||||
|
||||
MainObject::MainObject(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
unsigned schema=0;
|
||||
|
||||
destination_settings=new RDSettings();
|
||||
start_point=-1;
|
||||
end_point=-1;
|
||||
speed_ratio=1.0;
|
||||
bool ok=false;
|
||||
RDAudioConvert::ErrorCode conv_err;
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
RDCmdSwitch *cmd=
|
||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdconvert",
|
||||
RDCONVERT_USAGE);
|
||||
if(cmd->keys()<1) {
|
||||
fprintf(stderr,"rdconvert: missing argument\n");
|
||||
exit(256);
|
||||
}
|
||||
source_filename=cmd->key(cmd->keys()-1);
|
||||
for(unsigned i=0;i<cmd->keys()-1;i++) {
|
||||
/*
|
||||
if(cmd->key(i)=="--source-file") {
|
||||
source_filename=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
*/
|
||||
if(cmd->key(i)=="--destination-file") {
|
||||
destination_filename=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--start-point") {
|
||||
start_point=cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid start point\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--end-point") {
|
||||
end_point=cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid end point\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--destination-format") {
|
||||
RDSettings::Format format=(RDSettings::Format)cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid destination format\n");
|
||||
exit(256);
|
||||
}
|
||||
switch(format) {
|
||||
case RDSettings::Pcm16:
|
||||
case RDSettings::Pcm24:
|
||||
case RDSettings::MpegL2:
|
||||
case RDSettings::MpegL2Wav:
|
||||
case RDSettings::MpegL3:
|
||||
case RDSettings::Flac:
|
||||
case RDSettings::OggVorbis:
|
||||
destination_settings->setFormat(format);
|
||||
cmd->setProcessed(i,true);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"rdconvert: invalid destination format\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setFormat(format);
|
||||
}
|
||||
if(cmd->key(i)=="--destination-channels") {
|
||||
unsigned channels=cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid destination channels\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setChannels(channels);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--destination-sample-rate") {
|
||||
unsigned sample_rate=cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid destination sample rate\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setSampleRate(sample_rate);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--destination-bit-rate") {
|
||||
unsigned bit_rate=cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid destination bit rate\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setBitRate(bit_rate);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--quality") {
|
||||
unsigned quality=cmd->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdconvert: invalid destination quality\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setQuality(quality);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--normalization-level") {
|
||||
int normalization_level=cmd->value(i).toInt(&ok);
|
||||
if((!ok)||(normalization_level>0)) {
|
||||
fprintf(stderr,"rdconvert: invalid normalization level\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setNormalizationLevel(normalization_level);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--speed-ratio") {
|
||||
speed_ratio=cmd->value(i).toFloat(&ok);
|
||||
if((!ok)||(speed_ratio<=0)) {
|
||||
fprintf(stderr,"rdconvert: invalid speed-ratio\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
}
|
||||
if(source_filename.isEmpty()) {
|
||||
fprintf(stderr,"rdconvert: missing source-file\n");
|
||||
exit(256);
|
||||
}
|
||||
if(destination_filename.isEmpty()) {
|
||||
destination_filename=source_filename+"."+
|
||||
RDSettings::defaultExtension(destination_settings->format());
|
||||
}
|
||||
if((destination_settings->bitRate()!=0)&&
|
||||
(destination_settings->quality()!=0)) {
|
||||
fprintf(stderr,"rdconvert: --destination-bit-rate and --destination-quality are mutually exclusive\n");
|
||||
exit(256);
|
||||
}
|
||||
|
||||
//
|
||||
// Read Configuration
|
||||
//
|
||||
rdconfig=new RDConfig();
|
||||
rdconfig->load();
|
||||
|
||||
//
|
||||
// Open Database
|
||||
//
|
||||
QString err (tr("rdconvert: "));
|
||||
QSqlDatabase *db=RDInitDb(&schema,&err);
|
||||
if(!db) {
|
||||
fprintf(stderr,err.ascii());
|
||||
delete cmd;
|
||||
exit(256);
|
||||
}
|
||||
|
||||
RDAudioConvert *conv=new RDAudioConvert(rdconfig->stationName(),this);
|
||||
conv->setSourceFile(source_filename);
|
||||
conv->setDestinationFile(destination_filename);
|
||||
conv->setDestinationSettings(destination_settings);
|
||||
conv->setRange(start_point,end_point);
|
||||
conv->setSpeedRatio(speed_ratio);
|
||||
conv_err=conv->convert();
|
||||
if(conv_err!=RDAudioConvert::ErrorOk) {
|
||||
fprintf(stderr,"%s\n",(const char *)RDAudioConvert::errorText(conv_err));
|
||||
exit(256);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
new MainObject();
|
||||
return a.exec();
|
||||
}
|
56
utils/rdconvert/rdconvert.h
Normal file
56
utils/rdconvert/rdconvert.h
Normal file
@ -0,0 +1,56 @@
|
||||
// rdconvert.h
|
||||
//
|
||||
// Rivendell file format converter.
|
||||
//
|
||||
// (C) Copyright 2010-2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef RDCONVERT_H
|
||||
#define RDCONVERT_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qsqldatabase.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rdsettings.h>
|
||||
#include <rdcmd_switch.cpp>
|
||||
|
||||
#define RDCONVERT_USAGE "[options] <src-file>\n\nTest the Rivendell audio converter routines\n\nOptions are:\n--destination-file=<filename>\n\n--start-point=<msecs>\n\n--end-point=<msecs>\n\n--destination-format=<fmt>\n Supported formats are:\n 0 - PCM16 WAV\n 2 - MPEG Layer 2\n 3 - MPEG Layer 3\n 4 - FLAC\n 5 - OggVorbis\n 6 - MPEG Layer 2 WAV\n 7 - PCM24 WAV\n\n--destination-channels=<chans>\n\n--destination-sample-rate=<rate>\n\n--destination-bit-rate=<rate>\n\n--destination-quality=<qual>\n\n--normalization-level=<dbfs>\n\n--speed-ratio=<ratio>\n\n"
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
RDConfig *rdconfig;
|
||||
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
||||
public:
|
||||
MainObject(QObject *parent=0);
|
||||
|
||||
private:
|
||||
QString source_filename;
|
||||
QString destination_filename;
|
||||
int start_point;
|
||||
int end_point;
|
||||
float speed_ratio;
|
||||
RDSettings *destination_settings;
|
||||
};
|
||||
|
||||
|
||||
#endif // RDCONVERT_H
|
Loading…
x
Reference in New Issue
Block a user