From 03c9f06708e4f835894844b54d7cc062fab4e1c4 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sun, 2 Aug 2015 20:32:33 -0500 Subject: [PATCH] Fixed many audio issues with the FFmpegWriter. Planar formats were not being handled correctly. Framesize was also wrong on some formats. Also, added a new method to a Frame to fill with audio silence. Lastly, cleaned up some unused imports and C++ warnings. --- include/FFmpegUtilities.h | 6 +- include/FFmpegWriter.h | 2 + include/Frame.h | 3 + src/FFmpegReader.cpp | 2 - src/FFmpegWriter.cpp | 82 +++++----- src/Frame.cpp | 8 + src/Qt/PlayerDemo.cpp | 3 - src/Qt/VideoRenderWidget.cpp | 2 - src/Qt/VideoRenderer.cpp | 2 - src/Qt/demo/main.cpp | 1 - src/examples/Example.cpp | 140 +++++++++--------- .../jsoncpp/src/lib_json/json_reader.cpp | 2 - .../jsoncpp/src/lib_json/json_value.cpp | 1 - .../jsoncpp/src/lib_json/json_writer.cpp | 1 - 14 files changed, 124 insertions(+), 131 deletions(-) diff --git a/include/FFmpegUtilities.h b/include/FFmpegUtilities.h index 8115dba9..2cab4000 100644 --- a/include/FFmpegUtilities.h +++ b/include/FFmpegUtilities.h @@ -64,13 +64,17 @@ #ifndef AV_ERROR_MAX_STRING_SIZE #define AV_ERROR_MAX_STRING_SIZE 64 #endif + #ifndef AUDIO_PACKET_ENCODING_SIZE + #define AUDIO_PACKET_ENCODING_SIZE 768000 // 48khz * S16 (2 bytes) * max channels (8) + #endif // This wraps an unsafe C macro to be C++ compatible function static const std::string av_make_error_string(int errnum) { char errbuf[AV_ERROR_MAX_STRING_SIZE]; av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE); - return (std::string)errbuf; + std::string errstring(errbuf); + return errstring; } // Redefine the C macro to use our new C++ function diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index 4272546a..b749f3cf 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -164,6 +164,7 @@ namespace openshot double audio_pts, video_pts; int16_t *samples; uint8_t *audio_outbuf; + uint8_t *audio_encoder_buffer; int num_of_rescalers; int rescaler_position; @@ -173,6 +174,7 @@ namespace openshot int audio_input_frame_size; int initial_audio_input_frame_size; int audio_input_position; + int audio_encoder_buffer_size; AVAudioResampleContext *avr; AVAudioResampleContext *avr_planar; diff --git a/include/Frame.h b/include/Frame.h index 4a3b5808..25ac561d 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -173,6 +173,9 @@ namespace openshot /// Add audio samples to a specific channel void AddAudio(bool replaceSamples, int destChannel, int destStartSample, const float* source, int numSamples, float gainToApplyToSource); + /// Add audio silence + void AddAudioSilence(int numSamples); + /// Apply gain ramp (i.e. fading volume) void ApplyGainRamp(int destChannel, int destStartSample, int numSamples, float initial_gain, float final_gain); diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 1978ce6c..7dde9266 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -380,8 +380,6 @@ void FFmpegReader::UpdateVideoInfo() info.video_length = round(info.duration * info.fps.ToDouble()); } - cout << info.fps.ToFloat() << endl; - // Override an invalid framerate if (info.fps.ToFloat() > 120.0f || (info.fps.num == 0 || info.fps.den == 0)) { diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 7bb742f2..730b7b2b 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -38,7 +38,7 @@ FFmpegWriter::FFmpegWriter(string path) throw (InvalidFile, InvalidFormat, Inval initial_audio_input_frame_size(0), img_convert_ctx(NULL), cache_size(8), num_of_rescalers(32), rescaler_position(0), video_codec(NULL), audio_codec(NULL), is_writing(false), write_video_count(0), write_audio_count(0), original_sample_rate(0), original_channels(0), avr(NULL), avr_planar(NULL), is_open(false), prepare_streams(false), - write_header(false), write_trailer(false) + write_header(false), write_trailer(false), audio_encoder_buffer_size(0), audio_encoder_buffer(NULL) { // Disable audio & video (so they can be independently enabled) @@ -682,8 +682,13 @@ void FFmpegWriter::close_audio(AVFormatContext *oc, AVStream *st) avcodec_close(st->codec); audio_codec = NULL; + // Clear buffers delete[] samples; delete[] audio_outbuf; + delete[] audio_encoder_buffer; + samples = NULL; + audio_outbuf = NULL; + audio_encoder_buffer = NULL; // Deallocate resample buffer if (avr) { @@ -969,19 +974,23 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) } } else { // Set frame size based on the codec - audio_input_frame_size = audio_codec->frame_size * info.channels; + audio_input_frame_size = audio_codec->frame_size; } // Set the initial frame size (since it might change during resampling) initial_audio_input_frame_size = audio_input_frame_size; // Allocate array for samples - samples = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + samples = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE]; // Set audio output buffer (used to store the encoded audio) - audio_outbuf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE; + audio_outbuf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; audio_outbuf = new uint8_t[audio_outbuf_size]; + // Set audio packet encoding buffer + audio_encoder_buffer_size = AUDIO_PACKET_ENCODING_SIZE; + audio_encoder_buffer = new uint8_t[audio_encoder_buffer_size]; + AppendDebugMethod("FFmpegWriter::open_audio", "audio_codec->thread_count", audio_codec->thread_count, "audio_input_frame_size", audio_input_frame_size, "buffer_size", AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, "", -1, "", -1, "", -1); } @@ -1022,7 +1031,7 @@ void FFmpegWriter::write_audio_packets(bool final) ChannelLayout channel_layout_in_frame = LAYOUT_MONO; // default channel layout // Create a new array (to hold all S16 audio samples, for the current queued frames - int16_t* all_queued_samples = new int16_t[(queued_audio_frames.size() * AVCODEC_MAX_AUDIO_FRAME_SIZE) + FF_INPUT_BUFFER_PADDING_SIZE]; + int16_t* all_queued_samples = new int16_t[(queued_audio_frames.size() * AVCODEC_MAX_AUDIO_FRAME_SIZE)]; int16_t* all_resampled_samples = NULL; int16_t* final_samples_planar = NULL; int16_t* final_samples = NULL; @@ -1084,7 +1093,7 @@ void FFmpegWriter::write_audio_packets(bool final) // Fill input frame with sample data avcodec_fill_audio_frame(audio_frame, channels_in_frame, AV_SAMPLE_FMT_S16, (uint8_t *) all_queued_samples, - audio_frame->nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * channels_in_frame, 1); + audio_encoder_buffer_size, 0); // Do not convert audio to planar format (yet). We need to keep everything interleaved at this point. switch (audio_codec->sample_fmt) @@ -1114,7 +1123,6 @@ void FFmpegWriter::write_audio_packets(bool final) // Update total samples & input frame size (due to bigger or smaller data types) total_frame_samples *= (float(info.sample_rate) / sample_rate_in_frame); // adjust for different byte sizes total_frame_samples *= (float(info.channels) / channels_in_frame); // adjust for different # of channels - total_frame_samples *= (float(av_get_bytes_per_sample(output_sample_fmt)) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)); // Set remaining samples remaining_frame_samples = total_frame_samples; @@ -1152,14 +1160,10 @@ void FFmpegWriter::write_audio_packets(bool final) audio_frame->nb_samples); // number of input samples to convert // Create a new array (to hold all resampled S16 audio samples) - all_resampled_samples = new int16_t[nb_samples * info.channels * (av_get_bytes_per_sample(output_sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) + FF_INPUT_BUFFER_PADDING_SIZE)]; + all_resampled_samples = new int16_t[nb_samples * info.channels * (av_get_bytes_per_sample(output_sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16))]; // Copy audio samples over original samples - memcpy(all_resampled_samples, audio_converted->data[0], nb_samples * av_get_bytes_per_sample(output_sample_fmt) * info.channels); - - // Update remaining samples (since we just resampled the audio, and things might have changed) - remaining_frame_samples = nb_samples * (float(av_get_bytes_per_sample(output_sample_fmt)) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)) * info.channels; - //remaining_frame_samples = nb_samples * info.channels; + memcpy(all_resampled_samples, audio_converted->data[0], nb_samples * info.channels * av_get_bytes_per_sample(output_sample_fmt)); // Remove converted audio av_freep(&audio_frame[0]); // this deletes the all_queued_samples array @@ -1174,7 +1178,7 @@ void FFmpegWriter::write_audio_packets(bool final) // Loop until no more samples while (remaining_frame_samples > 0 || final) { // Get remaining samples needed for this packet - int remaining_packet_samples = audio_input_frame_size - audio_input_position; + int remaining_packet_samples = (audio_input_frame_size * info.channels) - audio_input_position; // Determine how many samples we need int diff = 0; @@ -1185,20 +1189,20 @@ void FFmpegWriter::write_audio_packets(bool final) // Copy frame samples into the packet samples array if (!final) - memcpy(samples + audio_input_position, all_resampled_samples + samples_position, diff * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)); + //TODO: Make this more sane + memcpy(samples + (audio_input_position * (av_get_bytes_per_sample(output_sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16))), all_resampled_samples + samples_position, diff * av_get_bytes_per_sample(output_sample_fmt)); // Increment counters audio_input_position += diff; - samples_position += diff; + samples_position += diff * (av_get_bytes_per_sample(output_sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)); remaining_frame_samples -= diff; remaining_packet_samples -= diff; // Do we have enough samples to proceed? - if (audio_input_position < audio_input_frame_size && !final) + if (audio_input_position < (audio_input_frame_size * info.channels) && !final) // Not enough samples to encode... so wait until the next frame break; - // Convert to planar (if needed by audio codec) AVFrame *frame_final = avcodec_alloc_frame(); avcodec_get_frame_defaults(frame_final); @@ -1226,18 +1230,18 @@ void FFmpegWriter::write_audio_packets(bool final) audio_frame->nb_samples = audio_input_position / info.channels; // Create a new array - final_samples_planar = new int16_t[audio_frame->nb_samples * info.channels * (av_get_bytes_per_sample(output_sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) + FF_INPUT_BUFFER_PADDING_SIZE)]; + final_samples_planar = new int16_t[audio_frame->nb_samples * info.channels * (av_get_bytes_per_sample(output_sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16))]; // Copy audio into buffer for frame - memcpy(final_samples_planar, samples, audio_frame->nb_samples * av_get_bytes_per_sample(output_sample_fmt) * info.channels); + memcpy(final_samples_planar, samples, audio_frame->nb_samples * info.channels * av_get_bytes_per_sample(output_sample_fmt)); // Fill input frame with sample data avcodec_fill_audio_frame(audio_frame, info.channels, output_sample_fmt, (uint8_t *) final_samples_planar, - audio_frame->nb_samples * av_get_bytes_per_sample(output_sample_fmt) * info.channels, 1); + audio_encoder_buffer_size, 0); // Create output frame (and allocate arrays) - frame_final->nb_samples = audio_frame->nb_samples; - av_samples_alloc(frame_final->data, frame_final->linesize, info.channels, audio_frame->nb_samples, audio_codec->sample_fmt, 0); + frame_final->nb_samples = audio_input_frame_size; + av_samples_alloc(frame_final->data, frame_final->linesize, info.channels, frame_final->nb_samples, audio_codec->sample_fmt, 0); // Convert audio samples int nb_samples = avresample_convert(avr_planar, // audio resample context @@ -1249,7 +1253,8 @@ void FFmpegWriter::write_audio_packets(bool final) audio_frame->nb_samples); // number of input samples to convert // Copy audio samples over original samples - memcpy(samples, frame_final->data[0], nb_samples * av_get_bytes_per_sample(audio_codec->sample_fmt) * info.channels); + if (nb_samples > 0) + memcpy(samples, frame_final->data[0], nb_samples * av_get_bytes_per_sample(audio_codec->sample_fmt) * info.channels); // deallocate AVFrame av_freep(&audio_frame[0]); // delete final_samples_planar array @@ -1258,40 +1263,29 @@ void FFmpegWriter::write_audio_packets(bool final) AppendDebugMethod("FFmpegWriter::write_audio_packets (Successfully completed 2nd resampling for Planar formats)", "nb_samples", nb_samples, "", -1, "", -1, "", -1, "", -1, "", -1); } else { - // Create a new array - final_samples = new int16_t[audio_input_position * (av_get_bytes_per_sample(audio_codec->sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) + FF_INPUT_BUFFER_PADDING_SIZE)]; + final_samples = new int16_t[audio_input_position * (av_get_bytes_per_sample(audio_codec->sample_fmt) / av_get_bytes_per_sample(AV_SAMPLE_FMT_S16))]; // Copy audio into buffer for frame memcpy(final_samples, samples, audio_input_position * av_get_bytes_per_sample(audio_codec->sample_fmt)); + // Init the nb_samples property + frame_final->nb_samples = audio_input_frame_size; + // Fill the final_frame AVFrame with audio (non planar) avcodec_fill_audio_frame(frame_final, audio_codec->channels, audio_codec->sample_fmt, (uint8_t *) final_samples, - audio_input_position * av_get_bytes_per_sample(audio_codec->sample_fmt), 1); + audio_encoder_buffer_size, 0); } - - // Increment PTS (in samples and scaled to the codec's timebase) -#if LIBAVFORMAT_VERSION_MAJOR >= 54 - // for some reason, it requires me to multiply channels X 2 - write_audio_count += av_rescale_q(audio_input_position / (audio_codec->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)), (AVRational){1, info.sample_rate}, audio_codec->time_base); -#else - write_audio_count += av_rescale_q(audio_input_position / audio_codec->channels, (AVRational){1, info.sample_rate}, audio_codec->time_base); -#endif - - // Set the # of samples -#if LIBAVFORMAT_VERSION_MAJOR >= 54 - frame_final->nb_samples = audio_input_position / (audio_codec->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)); -#else - frame_final->nb_samples = audio_input_frame_size / audio_codec->channels; -#endif + // Increment PTS (in samples) + write_audio_count += audio_input_frame_size; frame_final->pts = write_audio_count; // Set the AVFrame's PTS // Init the packet AVPacket pkt; av_init_packet(&pkt); - pkt.data = NULL; - pkt.size = 0; + pkt.data = audio_encoder_buffer; + pkt.size = audio_encoder_buffer_size; // Set the packet's PTS prior to encoding pkt.pts = pkt.dts = write_audio_count; diff --git a/src/Frame.cpp b/src/Frame.cpp index f4489a0a..5d8920fc 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -933,3 +933,11 @@ void Frame::cleanUpBuffer(void *info) ptr_to_qbuffer = NULL; } } + +// Add audio silence +void Frame::AddAudioSilence(int numSamples) +{ + // Resize audio container + audio->setSize(channels, numSamples, false, true, false); + audio->clear(); +} diff --git a/src/Qt/PlayerDemo.cpp b/src/Qt/PlayerDemo.cpp index 7037d757..19a40b0a 100644 --- a/src/Qt/PlayerDemo.cpp +++ b/src/Qt/PlayerDemo.cpp @@ -26,11 +26,8 @@ */ #include "stdio.h" -#include "string.h" #include "../../include/QtPlayer.h" #include "../../include/Qt/PlayerDemo.h" -#include "../../include/Qt/VideoRenderWidget.h" -#include "../../include/Qt/VideoRenderer.h" #include #include diff --git a/src/Qt/VideoRenderWidget.cpp b/src/Qt/VideoRenderWidget.cpp index d5c8d630..8dd6a73c 100644 --- a/src/Qt/VideoRenderWidget.cpp +++ b/src/Qt/VideoRenderWidget.cpp @@ -26,9 +26,7 @@ */ #include "../../include/Qt/VideoRenderWidget.h" -#include "../../include/Qt/VideoRenderer.h" #include -#include VideoRenderWidget::VideoRenderWidget(QWidget *parent) : QWidget(parent), renderer(new VideoRenderer(this)) diff --git a/src/Qt/VideoRenderer.cpp b/src/Qt/VideoRenderer.cpp index da2e51a6..4c30dac1 100644 --- a/src/Qt/VideoRenderer.cpp +++ b/src/Qt/VideoRenderer.cpp @@ -26,8 +26,6 @@ */ #include "../../include/Qt/VideoRenderer.h" -#include -#include VideoRenderer::VideoRenderer(QObject *parent) diff --git a/src/Qt/demo/main.cpp b/src/Qt/demo/main.cpp index 255e9e1e..795b3c25 100644 --- a/src/Qt/demo/main.cpp +++ b/src/Qt/demo/main.cpp @@ -26,7 +26,6 @@ */ #include "../../../include/Qt/PlayerDemo.h" -#include int main(int argc, char *argv[]) { diff --git a/src/examples/Example.cpp b/src/examples/Example.cpp index 9c42dae5..bd6e746c 100644 --- a/src/examples/Example.cpp +++ b/src/examples/Example.cpp @@ -27,14 +27,8 @@ #include #include -#include -#include #include #include "../../include/OpenShot.h" -#include "../../include/Json.h" -#include -#include -#include using namespace openshot; @@ -44,66 +38,66 @@ using namespace tr1; int main(int argc, char* argv[]) { - FFmpegReader r110("/home/jonathan/apps/libopenshot/src/examples/piano-mono.wav"); - r110.Open(); +// FFmpegReader r110("/home/jonathan/apps/libopenshot/src/examples/piano-mono.wav"); +// r110.Open(); +// +// FrameMapper m110(&r110, Fraction(24,1), PULLDOWN_NONE, 22050, 2, LAYOUT_STEREO); +// m110.Open(); +// +// Clip c110(&m110); +// c110.Open(); +// +// Timeline t10(1280, 720, Fraction(24,1), 22050, 2, LAYOUT_STEREO); +// t10.debug = false; +// //Clip c20("/home/jonathan/Pictures/DSC00660.JPG"); +// //c20.End(1000.0); +// //c20.Layer(-1); +// //c20.scale = SCALE_STRETCH; +// //c20.rotation.AddPoint(1, 0.0); +// //c20.rotation.AddPoint(1000, 360.0); +// Clip c10("/home/jonathan/apps/libopenshot/src/examples/piano-mono.wav"); +// c10.volume.AddPoint(1, 0.0); +// c10.volume.AddPoint(100, 1.0); +//// c10.time.AddPoint(1, 1); +//// c10.time.AddPoint(300, 900); +//// c10.time.AddPoint(600, 300); +//// c10.time.PrintValues(); +// +// //Color background((unsigned char)0, (unsigned char)255, (unsigned char)0, (unsigned char)0); +// //background.red.AddPoint(1000, 255); +// //background.green.AddPoint(1000, 0); +// //t10.color = background; +// +// Color black; +// black.red = Keyframe(0); +// black.green = Keyframe(0); +// black.blue = Keyframe(0); +// +// Keyframe brightness; +// brightness.AddPoint(300, -1.0, BEZIER); +// brightness.AddPoint(370, 0.5, BEZIER); +// brightness.AddPoint(425, -0.5, BEZIER); +// brightness.AddPoint(600, 1.0, BEZIER); +// +// //Negate e; +// //Deinterlace e(false); +// //ChromaKey e(black, Keyframe(30)); +// //QtImageReader mask_reader("/home/jonathan/apps/openshot-qt/src/transitions/extra/big_cross_right_barr.png"); +// //QtImageReader mask_reader1("/home/jonathan/apps/openshot-qt/src/transitions/extra/big_barr.png"); +// //Mask e(&mask_reader, brightness, Keyframe(3.0)); +// //c10.AddEffect(&e); +// //Mask e1(&mask_reader1, brightness, Keyframe(3.0)); +// //c10.AddEffect(&e1); +// +// // add clip to timeline +// t10.AddClip(&c10); +// //t10.AddClip(&c20); +// t10.Open(); - FrameMapper m110(&r110, Fraction(24,1), PULLDOWN_NONE, 22050, 2, LAYOUT_STEREO); - m110.Open(); + FFmpegReader r9("/home/jonathan/Videos/sintel_trailer-720p.mp4"); + r9.Open(); + r9.DisplayInfo(); - Clip c110(&m110); - c110.Open(); - - Timeline t10(1280, 720, Fraction(24,1), 22050, 2, LAYOUT_STEREO); - t10.debug = false; - //Clip c20("/home/jonathan/Pictures/DSC00660.JPG"); - //c20.End(1000.0); - //c20.Layer(-1); - //c20.scale = SCALE_STRETCH; - //c20.rotation.AddPoint(1, 0.0); - //c20.rotation.AddPoint(1000, 360.0); - Clip c10("/home/jonathan/apps/libopenshot/src/examples/piano-mono.wav"); - c10.volume.AddPoint(1, 0.0); - c10.volume.AddPoint(100, 1.0); -// c10.time.AddPoint(1, 1); -// c10.time.AddPoint(300, 900); -// c10.time.AddPoint(600, 300); -// c10.time.PrintValues(); - - //Color background((unsigned char)0, (unsigned char)255, (unsigned char)0, (unsigned char)0); - //background.red.AddPoint(1000, 255); - //background.green.AddPoint(1000, 0); - //t10.color = background; - - Color black; - black.red = Keyframe(0); - black.green = Keyframe(0); - black.blue = Keyframe(0); - - Keyframe brightness; - brightness.AddPoint(300, -1.0, BEZIER); - brightness.AddPoint(370, 0.5, BEZIER); - brightness.AddPoint(425, -0.5, BEZIER); - brightness.AddPoint(600, 1.0, BEZIER); - - //Negate e; - //Deinterlace e(false); - //ChromaKey e(black, Keyframe(30)); - //QtImageReader mask_reader("/home/jonathan/apps/openshot-qt/src/transitions/extra/big_cross_right_barr.png"); - //QtImageReader mask_reader1("/home/jonathan/apps/openshot-qt/src/transitions/extra/big_barr.png"); - //Mask e(&mask_reader, brightness, Keyframe(3.0)); - //c10.AddEffect(&e); - //Mask e1(&mask_reader1, brightness, Keyframe(3.0)); - //c10.AddEffect(&e1); - - // add clip to timeline - t10.AddClip(&c10); - //t10.AddClip(&c20); - t10.Open(); - - // Reader -// FFmpegReader r9("/home/jonathan/Videos/sintel_trailer-720p.mp4"); -// r9.Open(); -// r9.debug = true; // Mapper //FrameMapper map(&r9, Fraction(24,1), PULLDOWN_NONE, 48000, 2, LAYOUT_STEREO); @@ -112,14 +106,16 @@ int main(int argc, char* argv[]) //map.Open(); /* WRITER ---------------- */ - FFmpegWriter w9("/home/jonathan/output-pops.mp3"); + FFmpegWriter w9("/home/jonathan/output-pops.webm"); w9.debug = false; //ImageWriter w9("/home/jonathan/output.gif"); // Set options - //w9.SetAudioOptions(true, "libvorbis", t10.info.sample_rate, t10.info.channels, t10.info.channel_layout, 120000); - w9.SetAudioOptions(true, "libmp3lame", 22050, t10.info.channels, t10.info.channel_layout, 120000); - //w9.SetVideoOptions(true, "libvpx", t10.info.fps, t10.info.width, t10.info.height, t10.info.pixel_ratio, false, false, 1500000); + //w9.SetVideoOptions(true, "libx264", r9.info.fps, 1024, 576, Fraction(1,1), false, false, 1000000); + //w9.SetAudioOptions(true, "mp2", r9.info.sample_rate, r9.info.channels, r9.info.channel_layout, 64000); + w9.SetAudioOptions(true, "libvorbis", r9.info.sample_rate, r9.info.channels, r9.info.channel_layout, 128000); + w9.SetVideoOptions(true, "libvpx", r9.info.fps, 1024, 576, Fraction(1,1), false, false, 3000000); + //w9.SetAudioOptions(true, "libmp3lame", 22050, t10.info.channels, t10.info.channel_layout, 120000); //w9.SetVideoOptions(true, "libx264", t10.info.fps, t10.info.width, t10.info.height, t10.info.pixel_ratio, false, false, 1500000); //w9.SetVideoOptions(true, "rawvideo", r9.info.fps, 400, 2, r9.info.pixel_ratio, false, false, 20000000); //w9.SetVideoOptions("GIF", r9.info.fps, r9.info.width, r9.info.height, 70, 1, true); @@ -144,7 +140,7 @@ int main(int argc, char* argv[]) // 147000 frames, 28100 frames //for (int frame = 1; frame <= (r9.info.video_length - 1); frame++) //for (int z = 0; z < 2; z++) - for (int frame = 1; frame <= 120; frame++) + for (int frame = 1; frame <= 700; frame++) //int frame = 1; //while (true) { @@ -152,7 +148,7 @@ int main(int argc, char* argv[]) int frame_number = frame; cout << "get " << frame << " (frame: " << frame_number << ") " << endl; - tr1::shared_ptr f = t10.GetFrame(frame_number); + tr1::shared_ptr f = r9.GetFrame(frame_number); cout << "mapped frame channel layouts: " << f->ChannelsLayout() << endl; cout << "display it (" << f->number << ", " << f << ")" << endl; //r9.GetFrame(frame_number)->DisplayWaveform(); @@ -178,8 +174,8 @@ int main(int argc, char* argv[]) w9.Close(); // Close timeline - //r9.Close(); - t10.Close(); + r9.Close(); + //t10.Close(); /* ---------------- */ cout << "happy ending" << endl; diff --git a/thirdparty/jsoncpp/src/lib_json/json_reader.cpp b/thirdparty/jsoncpp/src/lib_json/json_reader.cpp index 4eb2d11f..93fbe262 100644 --- a/thirdparty/jsoncpp/src/lib_json/json_reader.cpp +++ b/thirdparty/jsoncpp/src/lib_json/json_reader.cpp @@ -1,10 +1,8 @@ #include -#include #include #include #include #include -#include #include #if _MSC_VER >= 1400 // VC++ 8.0 diff --git a/thirdparty/jsoncpp/src/lib_json/json_value.cpp b/thirdparty/jsoncpp/src/lib_json/json_value.cpp index 573205f1..0c387599 100644 --- a/thirdparty/jsoncpp/src/lib_json/json_value.cpp +++ b/thirdparty/jsoncpp/src/lib_json/json_value.cpp @@ -8,7 +8,6 @@ #ifdef JSON_USE_CPPTL # include #endif -#include // size_t #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR # include "json_batchallocator.h" #endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR diff --git a/thirdparty/jsoncpp/src/lib_json/json_writer.cpp b/thirdparty/jsoncpp/src/lib_json/json_writer.cpp index cdf4188f..e96a5e98 100644 --- a/thirdparty/jsoncpp/src/lib_json/json_writer.cpp +++ b/thirdparty/jsoncpp/src/lib_json/json_writer.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include