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
3e871332
Commit
3e871332
authored
Jun 14, 2022
by
Jean-Baptiste Mardelle
Browse files
Fix incorrect behavior of external proxies, allow multiple patterns by profile
CCBUG: 455140
parent
e5911772
Changes
5
Hide whitespace changes
Inline
Side-by-side
data/externalproxies.rc
View file @
3e871332
...
...
@@ -6,7 +6,9 @@
# * prefix
# * suffix
# * This sequence of 6 parameters can be be repeated to offer several naming schemes
[proxy]
Sony PXW=../Sub;;S03.MP4;../Clip;;.MXF
GoPro LRV=./;GL;.LRV;./;GX;.MP4
GoPro LRV=./;GL;.LRV;./;GX;.MP4
;./;GP;.LRV;./;GP;.MP4
src/bin/projectclip.cpp
View file @
3e871332
...
...
@@ -516,38 +516,25 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool gene
QMutexLocker
locker
(
&
m_producerMutex
);
FileStatus
::
ClipStatus
currentStatus
=
m_clipStatus
;
bool
skipProducer
=
false
;
if
(
pCore
->
currentDoc
()
->
useExternalProxy
())
{
QStringList
externalParams
=
pCore
->
currentDoc
()
->
getDocumentProperty
(
QStringLiteral
(
"externalproxyparams"
)).
split
(
QLatin1Char
(
';'
));
if
(
pCore
->
currentDoc
()
->
useExternalProxy
()
&&
producer
->
get
(
"kdenlive:proxy"
)
!=
QLatin1String
(
"-"
))
{
// We have a camcorder profile, check if we have opened a proxy clip
QString
path
=
producer
->
get
(
"resource"
);
if
(
QFileInfo
(
path
).
isRelative
())
{
path
.
prepend
(
pCore
->
currentDoc
()
->
documentRoot
());
producer
->
set
(
"resource"
,
path
.
toUtf8
().
constData
());
}
if
(
externalParams
.
count
()
>=
6
)
{
QFileInfo
info
(
path
);
QDir
dir
=
info
.
absoluteDir
();
dir
.
cd
(
externalParams
.
at
(
3
));
QString
fileName
=
info
.
fileName
();
if
(
fileName
.
startsWith
(
externalParams
.
at
(
1
)))
{
fileName
.
remove
(
0
,
externalParams
.
at
(
1
).
size
());
fileName
.
prepend
(
externalParams
.
at
(
4
));
}
if
(
!
externalParams
.
at
(
2
).
isEmpty
())
{
fileName
.
chop
(
externalParams
.
at
(
2
).
size
());
}
fileName
.
append
(
externalParams
.
at
(
5
));
if
(
dir
.
exists
(
fileName
))
{
// Match, we opened a proxy clip
setProducerProperty
(
QStringLiteral
(
"kdenlive:proxy"
),
path
);
m_path
=
dir
.
absoluteFilePath
(
fileName
);
setProducerProperty
(
QStringLiteral
(
"kdenlive:originalurl"
),
m_path
);
if
(
m_name
==
QFileInfo
(
path
).
fileName
())
{
m_name
=
QFileInfo
(
m_path
).
fileName
();
}
getFileHash
();
skipProducer
=
true
;
QString
original
=
getOriginalFromProxy
(
path
);
if
(
!
original
.
isEmpty
())
{
// Match, we opened a proxy clip
setProducerProperty
(
QStringLiteral
(
"kdenlive:proxy"
),
path
);
m_path
=
original
;
setProducerProperty
(
QStringLiteral
(
"kdenlive:originalurl"
),
m_path
);
// Use original clip name
if
(
m_name
==
QFileInfo
(
path
).
fileName
())
{
m_name
=
QFileInfo
(
m_path
).
fileName
();
}
getFileHash
();
skipProducer
=
true
;
}
}
// Make sure we have a hash for this clip
...
...
@@ -677,7 +664,77 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool gene
return
true
;
}
void
ProjectClip
::
setThumbProducer
(
std
::
shared_ptr
<
Mlt
::
Producer
>
prod
)
const
QString
ProjectClip
::
getOriginalFromProxy
(
QString
proxyPath
)
const
{
QStringList
externalParams
=
pCore
->
currentDoc
()
->
getDocumentProperty
(
QStringLiteral
(
"externalproxyparams"
)).
split
(
QLatin1Char
(
';'
));
if
(
externalParams
.
count
()
>=
6
)
{
QFileInfo
info
(
proxyPath
);
QDir
dir
=
info
.
absoluteDir
();
dir
.
cd
(
externalParams
.
at
(
3
));
QString
fileName
=
info
.
fileName
();
bool
matchFound
=
false
;
while
(
externalParams
.
count
()
>=
6
)
{
if
(
fileName
.
startsWith
(
externalParams
.
at
(
1
)))
{
matchFound
=
true
;
break
;
}
externalParams
=
externalParams
.
mid
(
6
);
}
if
(
matchFound
)
{
fileName
.
remove
(
0
,
externalParams
.
at
(
1
).
size
());
fileName
.
prepend
(
externalParams
.
at
(
4
));
if
(
!
externalParams
.
at
(
2
).
isEmpty
())
{
if
(
!
fileName
.
endsWith
(
externalParams
.
at
(
2
)))
{
// File does not match, abort
return
QString
();
}
fileName
.
chop
(
externalParams
.
at
(
2
).
size
());
}
fileName
.
append
(
externalParams
.
at
(
5
));
if
(
fileName
!=
proxyPath
&&
dir
.
exists
(
fileName
))
{
return
dir
.
absoluteFilePath
(
fileName
);
}
}
}
return
QString
();
}
const
QString
ProjectClip
::
getProxyFromOriginal
(
QString
originalPath
)
const
{
QStringList
externalParams
=
pCore
->
currentDoc
()
->
getDocumentProperty
(
QStringLiteral
(
"externalproxyparams"
)).
split
(
QLatin1Char
(
';'
));
if
(
externalParams
.
count
()
>=
6
)
{
QFileInfo
info
(
originalPath
);
QDir
dir
=
info
.
absoluteDir
();
dir
.
cd
(
externalParams
.
at
(
0
));
QString
fileName
=
info
.
fileName
();
bool
matchFound
=
false
;
while
(
externalParams
.
count
()
>=
6
)
{
if
(
fileName
.
startsWith
(
externalParams
.
at
(
4
)))
{
matchFound
=
true
;
break
;
}
externalParams
=
externalParams
.
mid
(
6
);
}
if
(
matchFound
)
{
fileName
.
remove
(
0
,
externalParams
.
at
(
4
).
size
());
fileName
.
prepend
(
externalParams
.
at
(
1
));
if
(
!
externalParams
.
at
(
5
).
isEmpty
())
{
if
(
!
fileName
.
endsWith
(
externalParams
.
at
(
5
)))
{
// File does not match, abort
return
QString
();
}
fileName
.
chop
(
externalParams
.
at
(
5
).
size
());
}
fileName
.
append
(
externalParams
.
at
(
2
));
if
(
fileName
!=
originalPath
&&
dir
.
exists
(
fileName
))
{
return
dir
.
absoluteFilePath
(
fileName
);
}
}
}
return
QString
();
}
void
ProjectClip
::
setThumbProducer
(
std
::
shared_ptr
<
Mlt
::
Producer
>
prod
)
{
m_thumbsProducer
=
std
::
move
(
prod
);
}
...
...
src/bin/projectclip.h
View file @
3e871332
...
...
@@ -61,6 +61,15 @@ public:
static
std
::
shared_ptr
<
ProjectClip
>
construct
(
const
QString
&
id
,
const
QDomElement
&
description
,
const
QIcon
&
thumb
,
std
::
shared_ptr
<
ProjectItemModel
>
model
);
/**
* @brief Retreive original clip from proxy path when using external proxies
*/
const
QString
getOriginalFromProxy
(
QString
proxyPath
)
const
;
/**
* @brief Retreive original clip from proxy path when using external proxies
*/
const
QString
getProxyFromOriginal
(
QString
originalPath
)
const
;
protected:
ProjectClip
(
const
QString
&
id
,
const
QIcon
&
thumb
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
std
::
shared_ptr
<
Mlt
::
Producer
>
producer
);
ProjectClip
(
const
QString
&
id
,
const
QDomElement
&
description
,
const
QIcon
&
thumb
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
);
...
...
src/doc/kdenlivedoc.cpp
View file @
3e871332
...
...
@@ -1228,7 +1228,6 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<std::shared_ptr<Proje
}
// Parse clips
QStringList
externalProxyParams
=
m_documentProperties
.
value
(
QStringLiteral
(
"externalproxyparams"
)).
split
(
QLatin1Char
(
';'
));
for
(
int
i
=
0
;
i
<
clipList
.
count
();
++
i
)
{
const
std
::
shared_ptr
<
ProjectClip
>
&
item
=
clipList
.
at
(
i
);
ClipType
::
ProducerType
t
=
item
->
clipType
();
...
...
@@ -1256,24 +1255,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<std::shared_ptr<Proje
newProps
.
clear
();
QString
path
;
if
(
useExternalProxy
()
&&
item
->
hasLimitedDuration
())
{
if
(
externalProxyParams
.
count
()
>=
3
)
{
QFileInfo
info
(
item
->
url
());
QDir
clipDir
=
info
.
absoluteDir
();
if
(
clipDir
.
cd
(
externalProxyParams
.
at
(
0
)))
{
// Find correct file
QString
fileName
=
info
.
fileName
();
if
(
!
externalProxyParams
.
at
(
1
).
isEmpty
())
{
fileName
.
prepend
(
externalProxyParams
.
at
(
1
));
}
if
(
!
externalProxyParams
.
at
(
2
).
isEmpty
())
{
fileName
=
fileName
.
section
(
QLatin1Char
(
'.'
),
0
,
-
2
);
fileName
.
append
(
externalProxyParams
.
at
(
2
));
}
if
(
clipDir
.
exists
(
fileName
))
{
path
=
clipDir
.
absoluteFilePath
(
fileName
);
}
}
}
path
=
item
->
getProxyFromOriginal
(
item
->
url
());
}
if
(
path
.
isEmpty
())
{
path
=
dir
.
absoluteFilePath
(
item
->
hash
()
+
(
t
==
ClipType
::
Image
?
QStringLiteral
(
".png"
)
:
extension
));
...
...
src/project/dialogs/projectsettings.cpp
View file @
3e871332
...
...
@@ -295,13 +295,32 @@ void ProjectSettings::slotExternalProxyChanged(bool enabled)
void
ProjectSettings
::
setExternalProxyProfileData
(
const
QString
&
profileData
)
{
auto
params
=
profileData
.
split
(
";"
);
if
(
params
.
count
()
<
6
)
return
;
le_relPathOrigToProxy
->
setText
(
params
.
at
(
0
));
le_prefix_proxy
->
setText
(
params
.
at
(
1
));
le_suffix_proxy
->
setText
(
params
.
at
(
2
));
le_relPathProxyToOrig
->
setText
(
params
.
at
(
3
));
le_prefix_clip
->
setText
(
params
.
at
(
4
));
le_suffix_clip
->
setText
(
params
.
at
(
5
));
QString
val1
,
val2
,
val3
,
val4
,
val5
,
val6
;
int
count
=
0
;
while
(
params
.
count
()
>=
6
)
{
if
(
count
>
0
)
{
val1
.
append
(
QLatin1Char
(
';'
));
val2
.
append
(
QLatin1Char
(
';'
));
val3
.
append
(
QLatin1Char
(
';'
));
val4
.
append
(
QLatin1Char
(
';'
));
val5
.
append
(
QLatin1Char
(
';'
));
val6
.
append
(
QLatin1Char
(
';'
));
}
val1
.
append
(
params
.
at
(
0
));
val2
.
append
(
params
.
at
(
1
));
val3
.
append
(
params
.
at
(
2
));
val4
.
append
(
params
.
at
(
3
));
val5
.
append
(
params
.
at
(
4
));
val6
.
append
(
params
.
at
(
5
));
params
=
params
.
mid
(
6
);
count
++
;
}
le_relPathOrigToProxy
->
setText
(
val1
);
le_prefix_proxy
->
setText
(
val2
);
le_suffix_proxy
->
setText
(
val3
);
le_relPathProxyToOrig
->
setText
(
val4
);
le_prefix_clip
->
setText
(
val5
);
le_suffix_clip
->
setText
(
val6
);
}
void
ProjectSettings
::
slotExternalProxyProfileChanged
(
const
QString
&
)
...
...
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