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
7c121fdd
Commit
7c121fdd
authored
Jul 17, 2020
by
Jean-Baptiste Mardelle
Browse files
Improve reloading of audio thumbs in some cases
Related to
#761
parent
f3efca85
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/bin.cpp
View file @
7c121fdd
...
...
@@ -1464,6 +1464,7 @@ void Bin::slotDeleteClip()
void
Bin
::
slotReloadClip
()
{
qDebug
()
<<
"---------
\n
RELOADING CLIP
\n
----------------"
;
const
QModelIndexList
indexes
=
m_proxyModel
->
selectionModel
()
->
selectedIndexes
();
for
(
const
QModelIndex
&
ix
:
indexes
)
{
if
(
!
ix
.
isValid
()
||
ix
.
column
()
!=
0
)
{
...
...
@@ -1509,7 +1510,7 @@ void Bin::slotReloadClip()
}
}
}
currentItem
->
reloadProducer
(
false
,
true
);
currentItem
->
reloadProducer
(
false
);
}
}
}
...
...
@@ -3941,7 +3942,7 @@ void Bin::reloadAllProducers(bool reloadThumbs)
if
(
!
xml
.
isNull
())
{
clip
->
setClipStatus
(
AbstractProjectItem
::
StatusWaiting
);
pCore
->
jobManager
()
->
slotDiscardClipJobs
(
clip
->
clipId
());
clip
->
discardAudioThumb
();
clip
->
discardAudioThumb
(
false
);
// We need to set a temporary id before all outdated producers are replaced;
int
jobId
=
pCore
->
jobManager
()
->
startJob
<
LoadJob
>
({
clip
->
clipId
()},
-
1
,
QString
(),
xml
);
if
(
reloadThumbs
)
{
...
...
src/bin/projectclip.cpp
View file @
7c121fdd
...
...
@@ -334,19 +334,34 @@ void ProjectClip::reloadProducer(bool refreshOnly, bool audioStreamChanged, bool
QDomDocument
doc
;
QDomElement
xml
=
toXml
(
doc
);
if
(
!
xml
.
isNull
())
{
bool
hashChanged
=
false
;
pCore
->
jobManager
()
->
discardJobs
(
clipId
(),
AbstractClipJob
::
THUMBJOB
);
m_thumbsProducer
.
reset
();
ClipType
::
ProducerType
type
=
clipType
();
if
(
type
!=
ClipType
::
Color
&&
type
!=
ClipType
::
Image
&&
type
!=
ClipType
::
SlideShow
)
{
xml
.
removeAttribute
(
"out"
);
}
if
(
type
==
ClipType
::
Audio
||
type
==
ClipType
::
AV
)
{
// Check if source file was changed and rebuild audio data if necessary
QString
clipHash
=
getProducerProperty
(
QStringLiteral
(
"kdenlive:file_hash"
));
if
(
!
clipHash
.
isEmpty
())
{
if
(
clipHash
!=
getFileHash
())
{
// Source clip has changed, rebuild data
hashChanged
=
true
;
}
}
}
ThumbnailCache
::
get
()
->
invalidateThumbsForClip
(
clipId
(),
reloadAudio
);
int
loadJob
=
pCore
->
jobManager
()
->
startJob
<
LoadJob
>
({
clipId
()},
loadjobId
,
QString
(),
xml
);
pCore
->
jobManager
()
->
startJob
<
ThumbJob
>
({
clipId
()},
loadJob
,
QString
(),
-
1
,
true
,
true
);
if
(
audioStreamChanged
)
{
if
(
audioStreamChanged
||
hashChanged
)
{
discardAudioThumb
();
pCore
->
jobManager
()
->
startJob
<
AudioThumbJob
>
({
clipId
()},
loadjobId
,
QString
());
}
else
{
// refresh bin/monitor mini thumb only
discardAudioThumb
(
true
);
}
pCore
->
jobManager
()
->
startJob
<
AudioThumbJob
>
({
clipId
()},
loadjobId
,
QString
());
}
}
}
...
...
@@ -1274,19 +1289,32 @@ int ProjectClip::audioChannels() const
return
audioInfo
()
->
channels
();
}
void
ProjectClip
::
discardAudioThumb
()
void
ProjectClip
::
discardAudioThumb
(
bool
miniThumbOnly
)
{
if
(
!
m_audioInfo
)
{
return
;
}
QString
audioThumbPath
=
getAudioThumbPath
(
audioInfo
()
->
ffmpeg_audio_index
());
if
(
!
audioThumbPath
.
isEmpty
())
{
QFile
::
remove
(
audioThumbPath
);
pCore
->
jobManager
()
->
discardJobs
(
clipId
(),
AbstractClipJob
::
AUDIOTHUMBJOB
);
QString
audioThumbPath
;
QList
<
int
>
streams
=
m_audioInfo
->
streams
().
keys
();
if
(
!
miniThumbOnly
)
{
// Delete audio thumbnail data
for
(
int
&
st
:
streams
)
{
audioThumbPath
=
getAudioThumbPath
(
st
);
if
(
!
audioThumbPath
.
isEmpty
())
{
QFile
::
remove
(
audioThumbPath
);
}
}
}
// Delete mini thumb
for
(
int
&
st
:
streams
)
{
audioThumbPath
=
getAudioThumbPath
(
st
,
true
);
if
(
!
audioThumbPath
.
isEmpty
())
{
QFile
::
remove
(
audioThumbPath
);
}
}
qCDebug
(
KDENLIVE_LOG
)
<<
"//////////////////// DISCARD AUDIO THUMBS"
;
m_audioThumbCreated
=
false
;
refreshAudioInfo
();
pCore
->
jobManager
()
->
discardJobs
(
clipId
(),
AbstractClipJob
::
AUDIOTHUMBJOB
);
}
int
ProjectClip
::
getAudioStreamFfmpegIndex
(
int
mltStream
)
...
...
src/bin/projectclip.h
View file @
7c121fdd
...
...
@@ -185,7 +185,7 @@ public:
/** @brief Returns the list of this clip's subclip's ids. */
QStringList
subClipIds
()
const
;
/** @brief Delete cached audio thumb - needs to be recreated */
void
discardAudioThumb
();
void
discardAudioThumb
(
bool
miniThumbOnly
=
false
);
/** @brief Get path for this clip's audio thumbnail */
const
QString
getAudioThumbPath
(
int
stream
,
bool
miniThumb
=
false
);
/** @brief Returns true if this producer has audio and can be splitted on timeline*/
...
...
src/jobs/audiothumbjob.cpp
View file @
7c121fdd
...
...
@@ -159,7 +159,7 @@ bool AudioThumbJob::computeWithFFMPEG()
// We only wanted the thumb generation
return
m_done
;
}
if
(
!
m_dataInCache
&&
!
m_done
)
{
if
(
!
QFile
::
exists
(
m_cachePath
)
&&
!
m_dataInCache
&&
!
m_done
)
{
// Generate timeline audio thumbnail data
m_audioLevels
.
clear
();
std
::
vector
<
std
::
unique_ptr
<
QTemporaryFile
>>
channelFiles
;
...
...
@@ -354,23 +354,16 @@ bool AudioThumbJob::startJob()
QMap
<
int
,
QString
>
streams
=
m_binClip
->
audioInfo
()
->
streams
();
QMapIterator
<
int
,
QString
>
st
(
streams
);
m_done
=
true
;
ClipType
::
ProducerType
type
=
m_binClip
->
clipType
();
while
(
st
.
hasNext
())
{
st
.
next
();
int
stream
=
st
.
key
();
// Generate one thumb per stream
m_audioStream
=
stream
;
m_cachePath
=
m_binClip
->
getAudioThumbPath
(
stream
);
// checking for cached thumbs
QImage
image
(
m_cachePath
);
if
(
!
image
.
isNull
())
{
// Audio cache already exists
continue
;
}
m_done
=
false
;
bool
ok
=
false
;
if
(
m_binClip
->
clipT
ype
()
==
ClipType
::
Playlist
)
{
if
(
t
ype
==
ClipType
::
Playlist
)
{
if
(
KdenliveSettings
::
audiothumbnails
())
{
ok
=
computeWithMlt
();
}
...
...
@@ -387,10 +380,10 @@ bool AudioThumbJob::startJob()
return
false
;
}
if
(
ok
&&
m_done
&&
!
m_audioLevels
.
isEmpty
())
{
if
(
ok
&&
!
QFile
::
exists
(
m_cachePath
)
&&
m_done
&&
!
m_audioLevels
.
isEmpty
())
{
// Put into an image for caching.
int
count
=
m_audioLevels
.
size
();
i
mage
=
QI
mage
((
int
)
lrint
((
count
+
3
)
/
4.0
/
m_channels
),
m_channels
,
QImage
::
Format_ARGB32
);
QI
mage
i
mage
((
int
)
lrint
((
count
+
3
)
/
4.0
/
m_channels
),
m_channels
,
QImage
::
Format_ARGB32
);
int
n
=
image
.
width
()
*
image
.
height
();
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
QRgb
p
;
...
...
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