Got ffmpeg and juce compiling and mostly everything working again. FFmpeg is the newest version, and so is JUCE.

This commit is contained in:
Jonathan Thomas
2012-06-16 02:12:48 -05:00
parent 57520f0ba3
commit b775fff325
10 changed files with 39 additions and 47 deletions

View File

@@ -25,7 +25,7 @@
<option id="org.eclipse.cdt.build.core.settings.holder.libpaths.140246732" name="Library Paths" superClass="org.eclipse.cdt.build.core.settings.holder.libpaths"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1015291342" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1997837481" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath"/>
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1997837481" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths"/>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.676494018" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.458268777" name="UPC" superClass="org.eclipse.cdt.build.core.settings.holder">

View File

@@ -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)

View File

@@ -11,7 +11,7 @@
#define __JUCE_UNITTEST_JUCEHEADER__
#include <iomanip>
#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;

View File

@@ -14,7 +14,7 @@
#include <sstream>
#include <queue>
#include "Magick++.h"
#include "juce.h"
#include "JuceLibraryCode/JuceHeader.h"
#include "AudioBufferSource.h"
#include "Fraction.h"

View File

@@ -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();

View File

@@ -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

View File

@@ -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));
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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})
#add_executable(Example_Juce Example_Juce.cpp)
#target_link_libraries(Example_Juce ${LIBJUCE_LIBRARIES})