Fix transcoding of files with missing duration. (f31d4728) · Commits · Multimedia / Kdenlive · GitLab
Admin message
Join us at
Akademy
to celebrate KDE's 30th anniversary!
Travel support requests
are open till May 31st.
Register now
Commit
f31d4728
authored
Jul 24, 2025
by
Jean-Baptiste Mardelle
Browse files
parent
9ef04cac
Loading
Loading
Loading
Loading
Changes
10
Pipelines
Loading
Original line number
Diff line number
Diff line
@@ -48,7 +48,6 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include
"project/dialogs/slideshowclip.h"
#include
"project/invaliddialog.h"
#include
"project/projectmanager.h"
#include
"project/transcodeseek.h"
#include
"projectclip.h"
#include
"projectfolder.h"
#include
"projectitemmodel.h"
@@ -5556,18 +5555,16 @@ void Bin::requestSelectionTranscoding(bool forceReplace)
ObjectId
oid
KdenliveObjectType
::
BinClip
key
().
toInt
(),
QUuid
());
if
clip
->
clipType
()
==
ClipType
::
Timeline
// Ensure we use the correct out point
TranscodeTask
::
start
oid
value
().
first
(),
m_transcodingDialog
->
preParams
(),
m_transcodingDialog
->
params
value
().
at
).
toInt
(),
clip
->
fpsInfo
()),
clip
->
frameDuration
(),
replace
clip
get
(),
false
false
);
TranscodeTask
::
start
oid
value
().
first
(),
m_transcodingDialog
->
preParams
(),
m_transcodingDialog
->
params
key
()),
m_transcodingDialog
->
info
key
()),
clip
->
frameDuration
(),
replace
clip
get
(),
false
false
);
else
if
replace
// Abort audio and proxy tasks as they will run after transcoding
pCore
->
taskManager
discardJobs
ObjectId
KdenliveObjectType
::
BinClip
key
().
toInt
(),
QUuid
()),
AbstractTask
::
AUDIOTHUMBJOB
true
);
pCore
->
taskManager
discardJobs
ObjectId
KdenliveObjectType
::
BinClip
key
().
toInt
(),
QUuid
()),
AbstractTask
::
PROXYJOB
true
);
TranscodeTask
::
start
oid
value
().
first
(),
m_transcodingDialog
->
preParams
(),
m_transcodingDialog
->
params
clip
value
().
at
).
toInt
(),
clip
->
fpsInfo
()),
replace
clip
get
(),
false
false
);
TranscodeTask
::
start
oid
value
().
first
(),
m_transcodingDialog
->
preParams
(),
m_transcodingDialog
->
params
key
()),
m_transcodingDialog
->
info
key
()),
replace
clip
get
(),
false
false
);
m_transcodingDialog
->
deleteLater
();
@@ -5582,23 +5579,26 @@ void Bin::requestSelectionTranscoding(bool forceReplace)
for
const
auto
id
ids
std
::
shared_ptr
ProjectClip
clip
m_itemModel
->
getClipByBinID
id
);
if
clip
TranscodeSeek
::
TranscodeInfo
info
info
type
clip
->
clipType
();
info
url
info
type
==
ClipType
::
Timeline
||
info
type
==
ClipType
::
Text
clip
->
clipName
()
clip
->
clipUrl
();
info
fps_info
clip
->
fpsInfo
();
if
clip
->
statusReady
())
info
vCodec
clip
->
videoCodecProperty
QStringLiteral
"pix_fmt"
));
const
QString
clipService
clip
->
getProducerProperty
QStringLiteral
"mlt_service"
));
QString
suffix
if
clipService
startsWith
QLatin1String
"avformat"
)))
QString
resource
clip
->
clipUrl
();
ClipType
::
ProducerType
type
clip
->
clipType
();
std
::
pair
int
int
fpsInfo
clip
->
fpsInfo
();
int
integerFps
qRound
double
fpsInfo
first
fpsInfo
second
);
QString
suffix
QStringLiteral
"-%1fps"
).
arg
integerFps
);
m_transcodingDialog
->
addUrl
resource
id
suffix
type
QString
());
else
m_transcodingDialog
->
addUrl
clip
->
clipName
(),
id
QString
(),
clip
->
clipType
(),
QString
());
int
integerFps
qRound
double
info
fps_info
first
info
fps_info
second
);
suffix
QStringLiteral
"-%1fps"
).
arg
integerFps
);
m_transcodingDialog
->
addUrl
id
info
suffix
QString
());
m_transcodingDialog
->
show
();
void
Bin
::
requestTranscoding
const
QString
url
const
QString
id
int
type
bool
checkProfile
const
QString
suffix
const
QString
message
void
Bin
::
requestTranscoding
const
QString
id
TranscodeSeek
::
TranscodeInfo
info
bool
checkProfile
const
QString
suffix
const
QString
message
if
m_transcodingDialog
==
nullptr
m_transcodingDialog
new
TranscodeSeek
false
false
this
);
@@ -5612,10 +5612,13 @@ void Bin::requestTranscoding(const QString &url, const QString &id, int type, bo
next
();
std
::
shared_ptr
ProjectClip
clip
m_itemModel
->
getClipByBinID
key
());
if
clip
==
nullptr
TranscodeTask
::
start
ObjectId
KdenliveObjectType
::
NoItem
key
().
toInt
(),
QUuid
()),
value
().
first
(),
m_transcodingDialog
->
preParams
(),
m_transcodingDialog
->
params
key
()),
m_transcodingDialog
->
info
key
()),
true
clip
get
(),
false
key
()
==
firstId
checkProfile
false
);
continue
TranscodeTask
::
start
ObjectId
KdenliveObjectType
::
BinClip
key
().
toInt
(),
QUuid
()),
value
().
first
(),
m_transcodingDialog
->
preParams
(),
m_transcodingDialog
->
params
clip
value
().
at
).
toInt
(),
clip
->
fpsInfo
()),
true
clip
get
(),
false
m_transcodingDialog
->
params
key
()),
m_transcodingDialog
->
info
key
()),
true
clip
get
(),
false
key
()
==
firstId
checkProfile
false
);
@@ -5651,16 +5654,16 @@ void Bin::requestTranscoding(const QString &url, const QString &id, int type, bo
std
::
shared_ptr
ProjectClip
clip
m_itemModel
->
getClipByBinID
id
);
if
clip
ClipType
::
ProducerType
cType
ClipType
::
ProducerType
type
if
cType
==
ClipType
::
Unknown
cType
clip
->
clipType
();
if
info
type
==
ClipType
::
Unknown
info
type
clip
->
clipType
();
if
url
isEmpt
())
QString
resource
clip
->
clipUrl
);
m_transcodingDialog
->
addUrl
resource
id
suffix
cType
message
);
else
m_transcodingDialog
->
addUrl
url
id
suffix
cType
message
);
if
clip
->
statusRead
())
info
vCodec
clip
->
videoCodecProperty
QStringLiteral
"pix_fmt"
);
if
info
url
isEmpty
())
info
url
clip
->
clipUrl
);
m_transcodingDialog
->
addUrl
id
info
suffix
message
);
m_transcodingDialog
->
show
();
Original line number
Diff line number
Diff line
@@ -9,6 +9,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include
"abstractprojectitem.h"
#include
"project/transcodeseek.h"
#include
"utils/timecode.h"
#include
@@ -521,7 +522,8 @@ public Q_SLOTS:
/** @brief Check if a clip profile matches project, propose switch otherwise */
void
slotCheckProfile
const
QString
binId
);
/** @brief A non seekable clip was added to project, propose transcoding */
void
requestTranscoding
const
QString
url
const
QString
id
int
type
bool
checkProfile
const
QString
suffix
QString
(),
const
QString
message
QString
());
void
requestTranscoding
const
QString
id
TranscodeSeek
::
TranscodeInfo
info
bool
checkProfile
const
QString
suffix
QString
(),
const
QString
message
QString
());
/** @brief Display the transcode to edit friendly format for currenly selected bin clips */
void
requestSelectionTranscoding
bool
forceReplace
false
);
/** @brief Build the project bin audio/video icons according to color theme */
Original line number
Diff line number
Diff line
@@ -3043,9 +3043,17 @@ void ProjectClip::removeSequenceWarpResources() {}
std
::
pair
int
int
ProjectClip
::
fpsInfo
()
const
if
m_clipStatus
==
FileStatus
::
StatusReady
return
fpsInfo
m_masterProducer
);
return
pCore
->
getProjectFpsInfo
();
std
::
pair
int
int
ProjectClip
::
fpsInfo
std
::
shared_ptr
Mlt
::
Producer
producer
if
producer
std
::
vector
int
allowedfps
125
1001
};
int
fps_num
m_masterP
roducer
->
get_int
"meta.media.frame_rate_num"
);
int
fps_den
m_masterP
roducer
->
get_int
"meta.media.frame_rate_den"
);
int
fps_num
roducer
->
get_int
"meta.media.frame_rate_num"
);
int
fps_den
roducer
->
get_int
"meta.media.frame_rate_den"
);
if
std
::
find
allowedfps
begin
(),
allowedfps
end
(),
fps_den
==
allowedfps
end
())
// This is not an allowed fps_den, adjust
double
target_fps
double
fps_num
fps_den
Original line number
Diff line number
Diff line
@@ -161,6 +161,7 @@ public:
double
getOriginalFps
()
const
/** @brief Returns the original clip's fps as {frame_rate_num, frame_rate_den}. */
std
::
pair
int
int
fpsInfo
()
const
static
std
::
pair
int
int
fpsInfo
std
::
shared_ptr
Mlt
::
Producer
producer
);
bool
rename
const
QString
name
int
column
override
Original line number
Diff line number
Diff line
@@ -15,6 +15,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include
"kdenlivesettings.h"
#include
"mltcontroller/clipcontroller.h"
#include
"project/dialogs/slideshowclip.h"
#include
"project/transcodeseek.h"
#include
"utils/thumbnailcache.hpp"
#include
"xml/xml.hpp"
@@ -498,23 +499,26 @@ void ClipLoadTask::run()
if
producer
->
get_length
()
==
INT_MAX
&&
producer
->
get
"eof"
==
QLatin1String
"loop"
))
// This is a live source or broken clip
// Check for AV
ClipType
::
ProducerType
cType
type
TranscodeSeek
::
TranscodeInfo
info
info
url
resource
info
fps_info
ProjectClip
::
fpsInfo
producer
);
if
producer
if
mltService
startsWith
QLatin1String
"avformat"
))
&&
cT
ype
==
ClipType
::
Unknown
if
mltService
startsWith
QLatin1String
"avformat"
))
&&
ype
==
ClipType
::
Unknown
// Check if it is an audio or video only clip
if
producer
->
get_int
"video_index"
==
cT
ype
ClipType
::
Audio
ype
ClipType
::
Audio
else
if
producer
->
get_int
"audio_index"
==
cT
ype
ClipType
::
Video
ype
ClipType
::
Video
else
cT
ype
ClipType
::
AV
ype
ClipType
::
AV
producer
reset
();
QMetaObject
::
invokeMethod
pCore
->
bin
(),
"requestTranscoding"
Qt
::
QueuedConnection
Q_ARG
QString
resource
),
Q_ARG
QString
QString
::
number
m_owner
itemId
)),
Q_ARG
int
cType
),
Q_ARG
bool
pCore
->
bin
()
->
shouldCheckProfile
),
Q_ARG
QString
QString
()),
info
type
type
QMetaObject
::
invokeMethod
pCore
->
bin
(),
"requestTranscoding"
Qt
::
QueuedConnection
Q_ARG
QString
QString
::
number
m_owner
itemId
)),
Q_ARG
TranscodeSeek
::
TranscodeInfo
info
),
Q_ARG
bool
pCore
->
bin
()
->
shouldCheckProfile
),
Q_ARG
QString
QString
()),
Q_ARG
QString
i18n
"Duration of file %1 cannot be determined."
QFileInfo
resource
).
fileName
())));
if
pCore
->
bin
()
->
shouldCheckProfile
pCore
->
bin
()
->
shouldCheckProfile
false
@@ -694,19 +698,22 @@ void ClipLoadTask::run()
if
checkProfile
pCore
->
bin
()
->
shouldCheckProfile
false
ClipType
::
ProducerType
cType
type
if
cType
==
ClipType
::
Unknown
TranscodeSeek
::
TranscodeInfo
info
info
url
resource
info
fps_info
ProjectClip
::
fpsInfo
producer
);
if
type
==
ClipType
::
Unknown
// Check if it is an audio or video only clip
if
hasVideo
cT
ype
ClipType
::
Audio
ype
ClipType
::
Audio
else
if
hasAudio
cT
ype
ClipType
::
Video
ype
ClipType
::
Video
else
cT
ype
ClipType
::
AV
ype
ClipType
::
AV
QMetaObject
::
invokeMethod
pCore
->
bin
(),
"requestTranscoding"
Qt
::
QueuedConnection
Q_ARG
QString
resource
),
Q_ARG
QString
QString
::
number
m_owner
itemId
)),
Q_ARG
int
cType
),
Q_ARG
bool
checkProfile
),
Q_ARG
QString
QString
()),
info
type
type
QMetaObject
::
invokeMethod
pCore
->
bin
(),
"requestTranscoding"
Qt
::
QueuedConnection
Q_ARG
QString
QString
::
number
m_owner
itemId
)),
Q_ARG
TranscodeSeek
::
TranscodeInfo
info
),
Q_ARG
bool
checkProfile
),
Q_ARG
QString
QString
()),
Q_ARG
QString
i18n
"File %1 is not seekable."
QFileInfo
resource
).
fileName
())));
@@ -721,21 +728,23 @@ void ClipLoadTask::run()
int
integerFps
qRound
fps
);
adjustedFpsString
QStringLiteral
"-%1fps"
).
arg
integerFps
);
ClipType
::
ProducerType
cType
type
if
cType
==
ClipType
::
Unknown
TranscodeSeek
::
TranscodeInfo
info
info
url
resource
info
fps_info
ProjectClip
::
fpsInfo
producer
);
if
type
==
ClipType
::
Unknown
// Check if it is an audio or video only clip
if
hasVideo
cT
ype
ClipType
::
Audio
ype
ClipType
::
Audio
else
if
hasAudio
cT
ype
ClipType
::
Video
ype
ClipType
::
Video
else
cT
ype
ClipType
::
AV
ype
ClipType
::
AV
info
type
type
producer
->
set
"_wait_for_transcode"
);
QMetaObject
::
invokeMethod
pCore
->
bin
(),
"requestTranscoding"
Qt
::
QueuedConnection
Q_ARG
QString
resource
),
Q_ARG
QString
QString
::
number
m_owner
itemId
)),
Q_ARG
int
cType
),
Q_ARG
bool
checkProfile
),
Q_ARG
QString
adjustedFpsString
),
QMetaObject
::
invokeMethod
pCore
->
bin
(),
"requestTranscoding"
Qt
::
QueuedConnection
Q_ARG
QString
QString
::
number
m_owner
itemId
)),
Q_ARG
TranscodeSeek
::
TranscodeInfo
info
),
Q_ARG
bool
checkProfile
),
Q_ARG
QString
adjustedFpsString
),
Q_ARG
QString
i18n
"File %1 has a variable frame rate."
QFileInfo
resource
).
fileName
())));
Loading
US