diff --git a/.cproject b/.cproject
index 4fbd4303..0223f600 100644
--- a/.cproject
+++ b/.cproject
@@ -25,7 +25,7 @@
-
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c524fd2..366201da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,9 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
################### SETUP PROJECT ###################
project(openshot)
set(PROJECT_VERSION 1.3.0)
-message("<< Generating build files for ${PROJECT_NAME} (${PROJECT_VERSION}) >>")
+MESSAGE("--------------------------------------------------------------")
+message("---- Generating build files for ${PROJECT_NAME} (${PROJECT_VERSION})")
+MESSAGE("--------------------------------------------------------------")
############## PROCESS SUB-DIRECTORIES ##############
add_subdirectory(src)
diff --git a/include/AudioBufferSource.h b/include/AudioBufferSource.h
index 6707e93c..da8d508b 100644
--- a/include/AudioBufferSource.h
+++ b/include/AudioBufferSource.h
@@ -11,7 +11,7 @@
#define __JUCE_UNITTEST_JUCEHEADER__
#include
-#include "JuceLibraryCode/JuceHeader.h
+#include "JuceLibraryCode/JuceHeader.h"
using namespace std;
@@ -49,13 +49,13 @@ namespace openshot
void releaseResources();
/// Set the next read position of this source
- void setNextReadPosition (int newPosition);
+ void setNextReadPosition (long long newPosition);
/// Get the next read position of this source
- int getNextReadPosition() const;
+ long long getNextReadPosition() const;
/// Get the total length (in samples) of this audio source
- int getTotalLength() const;
+ long long getTotalLength() const;
/// Determines if this audio source should repeat when it reaches the end
bool isLooping() const;
diff --git a/include/Frame.h b/include/Frame.h
index b1d73b4c..8fb4115f 100644
--- a/include/Frame.h
+++ b/include/Frame.h
@@ -14,7 +14,7 @@
#include
#include
#include "Magick++.h"
-#include "juce.h"
+#include "JuceLibraryCode/JuceHeader.h"
#include "AudioBufferSource.h"
#include "Fraction.h"
diff --git a/src/AudioBufferSource.cpp b/src/AudioBufferSource.cpp
index 1aed59b7..74f11810 100644
--- a/src/AudioBufferSource.cpp
+++ b/src/AudioBufferSource.cpp
@@ -91,7 +91,7 @@ void AudioBufferSource::releaseResources()
};
// Set the next read position of this source
-void AudioBufferSource::setNextReadPosition (int newPosition)
+void AudioBufferSource::setNextReadPosition (long long newPosition)
{
// set position (if the new position is in range)
if (newPosition > 0 && newPosition < buffer->getNumSamples())
@@ -99,14 +99,14 @@ void AudioBufferSource::setNextReadPosition (int newPosition)
};
// Get the next read position of this source
-int AudioBufferSource::getNextReadPosition() const
+long long AudioBufferSource::getNextReadPosition() const
{
// return the next read position
return position;
};
// Get the total length (in samples) of this audio source
-int AudioBufferSource::getTotalLength() const
+long long AudioBufferSource::getTotalLength() const
{
// Get the length
return buffer->getNumSamples();
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 86a9ced3..08dfaa9f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,13 +12,6 @@ FIND_PACKAGE(FFmpeg REQUIRED)
# Include FFmpeg headers (needed for compile)
include_directories(${FFMPEG_INCLUDE_DIR})
-################# JACK AUDIO ###################
-# Find Jack Audio libraries
-#FIND_PACKAGE(Jack REQUIRED)
-
-# Include Jack headers (needed for compile)
-#include_directories(${LIBJACK_INCLUDE_DIR})
-
################# JUCE AUDIO ###################
# Find JUCE Audio libraries
FIND_PACKAGE(Juce REQUIRED)
@@ -33,13 +26,6 @@ FIND_PACKAGE(SDL REQUIRED)
# Include SDL headers (needed for compile)
include_directories(${SDL_INCLUDE_DIR})
-################# GTK2 ###################
-# Find GTK2 libraries
-#FIND_PACKAGE(GTK2 COMPONENTS gtk gtkmm)
-
-# Include GTK headers (needed for compile)
-#include_directories(${GTK2_INCLUDE_DIRS})
-
################### OPENMP #####################
# Check for OpenMP (used for multi-core processing)
FIND_PACKAGE(OpenMP)
@@ -48,7 +34,6 @@ FIND_PACKAGE(OpenMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-
############### CREATE LIBRARY #################
# Create shared openshot library
add_library(openshot SHARED
diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp
index 17cef64c..fb3e24c8 100644
--- a/src/FFmpegReader.cpp
+++ b/src/FFmpegReader.cpp
@@ -21,15 +21,18 @@ FFmpegReader::FFmpegReader(string path) throw(InvalidFile, NoStreamsFound, Inval
void FFmpegReader::Open()
{
+ // Initialize format context
+ pFormatCtx = avformat_alloc_context();
+
// Register all formats and codecs
av_register_all();
// Open video file
- if (av_open_input_file(&pFormatCtx, path.c_str(), NULL, 0, NULL) != 0)
+ if (avformat_open_input(&pFormatCtx, path.c_str(), NULL, NULL) != 0)
throw InvalidFile("File could not be opened.", path);
// Retrieve stream information
- if (av_find_stream_info(pFormatCtx) < 0)
+ if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
throw NoStreamsFound("No streams found in file.", path);
// Dump information about file onto standard error
@@ -41,11 +44,11 @@ void FFmpegReader::Open()
for (unsigned int i = 0; i < pFormatCtx->nb_streams; i++)
{
// Is this a video stream?
- if (pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO && videoStream < 0) {
+ if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && videoStream < 0) {
videoStream = i;
}
// Is this an audio stream?
- if (pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO && audioStream < 0) {
+ if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && audioStream < 0) {
audioStream = i;
}
}
@@ -75,7 +78,7 @@ void FFmpegReader::Open()
throw InvalidCodec("A valid video codec could not be found for this file.", path);
}
// Open video codec
- if (avcodec_open(pCodecCtx, pCodec) < 0)
+ if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0)
throw InvalidCodec("A video codec was found, but could not be opened.", path);
// Update the File Info struct with video details (if a video stream is found)
@@ -98,7 +101,7 @@ void FFmpegReader::Open()
throw InvalidCodec("A valid audio codec could not be found for this file.", path);
}
// Open audio codec
- if (avcodec_open(aCodecCtx, aCodec) < 0)
+ if (avcodec_open2(aCodecCtx, aCodec, NULL) < 0)
throw InvalidCodec("An audio codec was found, but could not be opened.", path);
// Update the File Info struct with audio details (if an audio stream is found)
@@ -121,14 +124,17 @@ void FFmpegReader::Close()
audio_resample_close(resampleCtx);
// Close the video file
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
+
+ // Free the format context
+ //avformat_free_context(pFormatCtx);
}
void FFmpegReader::UpdateAudioInfo()
{
// Set values of FileInfo struct
info.has_audio = true;
- info.file_size = pFormatCtx->file_size;
+ info.file_size = pFormatCtx->pb ? avio_size(pFormatCtx->pb) : -1;
info.acodec = aCodecCtx->codec->name;
info.channels = aCodecCtx->channels;
info.sample_rate = aCodecCtx->sample_rate;
@@ -166,7 +172,7 @@ void FFmpegReader::UpdateVideoInfo()
{
// Set values of FileInfo struct
info.has_video = true;
- info.file_size = pFormatCtx->file_size;
+ info.file_size = pFormatCtx->pb ? avio_size(pFormatCtx->pb) : -1;
info.height = pCodecCtx->height;
info.width = pCodecCtx->width;
info.vcodec = pCodecCtx->codec->name;
@@ -369,8 +375,7 @@ bool FFmpegReader::GetAVFrame()
{
// Decode video frame
int frameFinished = 0;
- avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
- packet.data, packet.size);
+ avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
// Detect interlaced frame (only once)
if (frameFinished && !check_interlace)
@@ -472,8 +477,7 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int
int buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE;
// decode audio packet into samples (put samples in the audio_buf array)
- int used = avcodec_decode_audio2(aCodecCtx, audio_buf, &buf_size,
- packet.data, packet.size);
+ int used = avcodec_decode_audio3(aCodecCtx, audio_buf, &buf_size, &packet);
if (used < 0) {
// Throw exception
@@ -483,7 +487,7 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int
}
// Calculate total number of samples
- packet_samples += (buf_size / (av_get_bits_per_sample_format(aCodecCtx->sample_fmt) / 8));
+ packet_samples += (buf_size / av_get_bytes_per_sample(aCodecCtx->sample_fmt));
// process samples...
packet.data += used;
@@ -492,7 +496,7 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int
// Re-sample audio samples (if needed)
- if(aCodecCtx->sample_fmt != SAMPLE_FMT_S16) {
+ if(aCodecCtx->sample_fmt != AV_SAMPLE_FMT_S16) {
// Audio needs to be converted
if(!resampleCtx)
// Create an audio resample context object (used to convert audio samples)
@@ -501,7 +505,7 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int
info.channels,
info.sample_rate,
info.sample_rate,
- SAMPLE_FMT_S16,
+ AV_SAMPLE_FMT_S16,
aCodecCtx->sample_fmt,
0, 0, 0, 0.0f);
@@ -516,7 +520,7 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int
audio_resample(resampleCtx, (short *)&converted_audio, (short *)&audio_buf, packet_samples);
// Copy audio samples over original samples
- memcpy(&audio_buf, &converted_audio, packet_samples * av_get_bits_per_sample_format(SAMPLE_FMT_S16));
+ memcpy(&audio_buf, &converted_audio, packet_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16));
}
}
diff --git a/src/Frame.cpp b/src/Frame.cpp
index 6186e712..96b99947 100644
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -360,6 +360,7 @@ void Frame::Play()
AudioTransportSource transport1;
transport1.setSource (my_source,
5000, // tells it to buffer this many samples ahead
+ NULL,
(double) sample_rate); // sample rate of source
transport1.setPosition (0);
transport1.setGain(1.0);
diff --git a/src/Main.cpp b/src/Main.cpp
index 79975697..ad18244a 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -32,7 +32,7 @@ int main()
for (int frame = 1; frame < 3000; frame++)
{
Frame f = r.GetFrame(frame);
- f.Play();
+ //f.Play();
f.Display();
f.DisplayWaveform(false);
}
diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt
index 2359c62f..1e6472b1 100644
--- a/src/examples/CMakeLists.txt
+++ b/src/examples/CMakeLists.txt
@@ -1,10 +1,10 @@
############### TEST EXECUTABLES ################
-add_executable(Example_FFmpeg Example_FFmpeg.cpp)
-target_link_libraries(Example_FFmpeg ${FFMPEG_LIBRARIES} ${ImageMagick_LIBRARIES} )
+#add_executable(Example_FFmpeg Example_FFmpeg.cpp)
+#target_link_libraries(Example_FFmpeg ${FFMPEG_LIBRARIES} ${ImageMagick_LIBRARIES} )
add_executable(Example_ImageMagick Example_ImageMagick.cpp)
target_link_libraries(Example_ImageMagick ${ImageMagick_LIBRARIES} )
-add_executable(Example_Juce Example_Juce.cpp)
-target_link_libraries(Example_Juce ${LIBJUCE_LIBRARIES})
\ No newline at end of file
+#add_executable(Example_Juce Example_Juce.cpp)
+#target_link_libraries(Example_Juce ${LIBJUCE_LIBRARIES})
\ No newline at end of file