You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
- Clip reader init should consider paths with a % to use FFmpegReader by default (i.e. image sequences)
- FFmpegReader info struct should not be initialized during Open() after it is initially populated - so our SetJson() method can properly override it's values - FrameMapper Json() method should include it's mapped Reader JSON - even though it is not yet possible to read it back in yet - New unit tests for Timeline ApplyJsonDiff, and verification that we can override FFmpegReader info struct (i.e. updating FPS, time bases, etc...) - Some whitespace fixes
This commit is contained in:
@@ -164,9 +164,9 @@ Clip::Clip(std::string path) : resampler(NULL), reader(NULL), allocated_reader(N
|
||||
std::string ext = get_file_extension(path);
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||
|
||||
// Determine if common video formats
|
||||
// Determine if common video formats (or image sequences)
|
||||
if (ext=="avi" || ext=="mov" || ext=="mkv" || ext=="mpg" || ext=="mpeg" || ext=="mp3" || ext=="mp4" || ext=="mts" ||
|
||||
ext=="ogg" || ext=="wav" || ext=="wmv" || ext=="webm" || ext=="vob")
|
||||
ext=="ogg" || ext=="wav" || ext=="wmv" || ext=="webm" || ext=="vob" || path.find("%") != std::string::npos)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -670,13 +670,20 @@ bool FFmpegReader::HasAlbumArt() {
|
||||
}
|
||||
|
||||
void FFmpegReader::UpdateAudioInfo() {
|
||||
// Set default audio channel layout (if needed)
|
||||
if (AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout == 0)
|
||||
AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout = av_get_default_channel_layout(AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels);
|
||||
|
||||
if (info.sample_rate > 0) {
|
||||
// Skip init - if info struct already populated
|
||||
return;
|
||||
}
|
||||
|
||||
// Set values of FileInfo struct
|
||||
info.has_audio = true;
|
||||
info.file_size = pFormatCtx->pb ? avio_size(pFormatCtx->pb) : -1;
|
||||
info.acodec = aCodecCtx->codec->name;
|
||||
info.channels = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels;
|
||||
if (AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout == 0)
|
||||
AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout = av_get_default_channel_layout(AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels);
|
||||
info.channel_layout = (ChannelLayout) AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout;
|
||||
info.sample_rate = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->sample_rate;
|
||||
info.audio_bit_rate = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->bit_rate;
|
||||
@@ -722,14 +729,14 @@ void FFmpegReader::UpdateAudioInfo() {
|
||||
info.height = 480;
|
||||
|
||||
// Use timeline to set correct width & height (if any)
|
||||
Clip *parent = (Clip *) ParentClip();
|
||||
if (parent) {
|
||||
if (parent->ParentTimeline()) {
|
||||
// Set max width/height based on parent clip's timeline (if attached to a timeline)
|
||||
info.width = parent->ParentTimeline()->preview_width;
|
||||
info.height = parent->ParentTimeline()->preview_height;
|
||||
}
|
||||
}
|
||||
Clip *parent = (Clip *) ParentClip();
|
||||
if (parent) {
|
||||
if (parent->ParentTimeline()) {
|
||||
// Set max width/height based on parent clip's timeline (if attached to a timeline)
|
||||
info.width = parent->ParentTimeline()->preview_width;
|
||||
info.height = parent->ParentTimeline()->preview_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix invalid video lengths for certain types of files (MP3 for example)
|
||||
@@ -747,6 +754,11 @@ void FFmpegReader::UpdateAudioInfo() {
|
||||
}
|
||||
|
||||
void FFmpegReader::UpdateVideoInfo() {
|
||||
if (info.vcodec.length() > 0) {
|
||||
// Skip init - if info struct already populated
|
||||
return;
|
||||
}
|
||||
|
||||
// Set values of FileInfo struct
|
||||
info.has_video = true;
|
||||
info.file_size = pFormatCtx->pb ? avio_size(pFormatCtx->pb) : -1;
|
||||
|
||||
@@ -727,6 +727,9 @@ Json::Value FrameMapper::JsonValue() const {
|
||||
// Create root json object
|
||||
Json::Value root = ReaderBase::JsonValue(); // get parent properties
|
||||
root["type"] = "FrameMapper";
|
||||
if (reader) {
|
||||
root["reader"] = reader->JsonValue();
|
||||
}
|
||||
|
||||
// return JsonValue
|
||||
return root;
|
||||
@@ -741,6 +744,12 @@ void FrameMapper::SetJson(const std::string value) {
|
||||
const Json::Value root = openshot::stringToJson(value);
|
||||
// Set all values that match
|
||||
SetJsonValue(root);
|
||||
|
||||
if (!root["reader"].isNull()) // does Json contain a reader?
|
||||
{
|
||||
// Placeholder to load reader
|
||||
// TODO: need a createReader method for this and Clip JSON methods
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user