Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
8701571d
Commit
8701571d
authored
Oct 23, 2019
by
Jean-Baptiste Mardelle
Browse files
Move audio stream processing to AudioStreamInfo class
parent
7d1b11bd
Pipeline
#9373
passed with stage
in 16 minutes and 14 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/audio/audioStreamInfo.cpp
View file @
8701571d
...
...
@@ -11,6 +11,7 @@ the Free Software Foundation, either version 3 of the License, or
#include "audioStreamInfo.h"
#include "kdenlive_debug.h"
#include <KLocalizedString>
#include <QString>
#include <cstdlib>
...
...
@@ -105,3 +106,42 @@ void AudioStreamInfo::setAudioIndex(const std::shared_ptr<Mlt::Producer> &produc
}
}
}
QMap
<
int
,
QString
>
AudioStreamInfo
::
streamInfo
(
Mlt
::
Properties
sourceProperties
)
{
QMap
<
int
,
QString
>
streamInfo
;
char
property
[
200
];
for
(
int
ix
:
m_audioStreams
)
{
memset
(
property
,
0
,
200
);
snprintf
(
property
,
sizeof
(
property
),
"meta.media.%d.codec.channels"
,
ix
);
int
chan
=
sourceProperties
.
get_int
(
property
);
QString
channelDescription
;
switch
(
chan
)
{
case
1
:
channelDescription
=
i18n
(
"Mono "
);
break
;
case
2
:
channelDescription
=
i18n
(
"Stereo "
);
break
;
default:
channelDescription
=
i18n
(
"%1 channels "
,
chan
);
break
;
}
// Frequency
memset
(
property
,
0
,
200
);
snprintf
(
property
,
sizeof
(
property
),
"meta.media.%d.codec.sample_rate"
,
ix
);
QString
frequency
(
sourceProperties
.
get
(
property
));
if
(
frequency
.
endsWith
(
QLatin1String
(
"000"
)))
{
frequency
.
chop
(
3
);
frequency
.
append
(
i18n
(
"kHz "
));
}
else
{
frequency
.
append
(
i18n
(
"Hz "
));
}
channelDescription
.
append
(
frequency
);
memset
(
property
,
0
,
200
);
snprintf
(
property
,
sizeof
(
property
),
"meta.media.%d.codec.name"
,
ix
);
channelDescription
.
append
(
sourceProperties
.
get
(
property
));
streamInfo
.
insert
(
ix
,
channelDescription
);
}
return
streamInfo
;
}
src/lib/audio/audioStreamInfo.h
View file @
8701571d
...
...
@@ -35,6 +35,7 @@ public:
int
ffmpeg_audio_index
()
const
;
void
dumpInfo
()
const
;
void
setAudioIndex
(
const
std
::
shared_ptr
<
Mlt
::
Producer
>
&
producer
,
int
ix
);
QMap
<
int
,
QString
>
streamInfo
(
Mlt
::
Properties
sourceProperties
);
private:
int
m_audioStreamIndex
;
...
...
src/mltcontroller/clippropertiescontroller.cpp
View file @
8701571d
...
...
@@ -593,7 +593,11 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
}
// Audio index
if
(
!
m_audioStreams
.
isEmpty
())
{
QMap
<
int
,
QString
>
audioStreamsInfo
;
if
(
m_controller
->
audioInfo
())
{
m_controller
->
audioInfo
()
->
streamInfo
(
m_sourceProperties
);
}
if
(
!
audioStreamsInfo
.
isEmpty
())
{
QString
vix
=
m_sourceProperties
.
get
(
"audio_index"
);
m_originalProperties
.
insert
(
QStringLiteral
(
"audio_index"
),
vix
);
hlay
=
new
QHBoxLayout
;
...
...
@@ -608,7 +612,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
hlay
->
addWidget
(
tbv
);
hlay
->
addWidget
(
new
QLabel
(
i18n
(
"Audio stream"
)));
auto
*
audioStream
=
new
QComboBox
(
this
);
QMapIterator
<
int
,
QString
>
i
(
m_
audioStreams
);
QMapIterator
<
int
,
QString
>
i
(
audioStreams
Info
);
while
(
i
.
hasNext
())
{
i
.
next
();
audioStream
->
addItem
(
QString
(
"%1: %2"
).
arg
(
i
.
key
()).
arg
(
i
.
value
()),
i
.
key
());
...
...
@@ -618,7 +622,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
}
ac
->
setActive
(
vix
.
toInt
()
==
-
1
);
audioStream
->
setEnabled
(
vix
.
toInt
()
>
-
1
);
audioStream
->
setVisible
(
m_
audioStreams
.
size
()
>
0
);
audioStream
->
setVisible
(
audioStreams
Info
.
size
()
>
0
);
connect
(
ac
,
&
KDualAction
::
activeChanged
,
[
this
,
audioStream
](
bool
activated
)
{
QMap
<
QString
,
QString
>
properties
;
int
vindx
=
-
1
;
...
...
@@ -973,7 +977,6 @@ void ClipPropertiesController::fillProperties()
// Find maximum stream index values
m_videoStreams
.
clear
();
m_audioStreams
.
clear
();
int
aStreams
=
m_sourceProperties
.
get_int
(
"meta.media.nb_streams"
);
for
(
int
ix
=
0
;
ix
<
aStreams
;
++
ix
)
{
char
property
[
200
];
...
...
@@ -981,37 +984,6 @@ void ClipPropertiesController::fillProperties()
QString
type
=
m_sourceProperties
.
get
(
property
);
if
(
type
==
QLatin1String
(
"video"
))
{
m_videoStreams
<<
ix
;
}
else
if
(
type
==
QLatin1String
(
"audio"
))
{
memset
(
property
,
0
,
200
);
snprintf
(
property
,
sizeof
(
property
),
"meta.media.%d.codec.channels"
,
ix
);
int
chan
=
m_sourceProperties
.
get_int
(
property
);
QString
channelDescription
;
switch
(
chan
)
{
case
1
:
channelDescription
=
i18n
(
"Mono "
);
break
;
case
2
:
channelDescription
=
i18n
(
"Stereo "
);
break
;
default:
channelDescription
=
i18n
(
"%1 channels "
,
chan
);
break
;
}
// Frequency
memset
(
property
,
0
,
200
);
snprintf
(
property
,
sizeof
(
property
),
"meta.media.%d.codec.sample_rate"
,
ix
);
QString
frequency
(
m_sourceProperties
.
get
(
property
));
if
(
frequency
.
endsWith
(
QLatin1String
(
"000"
)))
{
frequency
.
chop
(
3
);
frequency
.
append
(
i18n
(
"kHz "
));
}
else
{
frequency
.
append
(
i18n
(
"Hz "
));
}
channelDescription
.
append
(
frequency
);
memset
(
property
,
0
,
200
);
snprintf
(
property
,
sizeof
(
property
),
"meta.media.%d.codec.name"
,
ix
);
channelDescription
.
append
(
m_sourceProperties
.
get
(
property
));
m_audioStreams
.
insert
(
ix
,
channelDescription
);
}
}
m_clipProperties
.
insert
(
QStringLiteral
(
"default_video"
),
QString
::
number
(
vindex
));
...
...
src/mltcontroller/clippropertiescontroller.h
View file @
8701571d
...
...
@@ -102,7 +102,6 @@ private:
QMap
<
QString
,
QString
>
m_originalProperties
;
QMap
<
QString
,
QString
>
m_clipProperties
;
QList
<
int
>
m_videoStreams
;
QMap
<
int
,
QString
>
m_audioStreams
;
QTreeWidget
*
m_propertiesTree
;
QWidget
*
m_propertiesPage
;
QWidget
*
m_markersPage
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment