summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-03-15 15:59:58 +0000
committerComment <tim@gray.(none)>2013-03-15 15:59:58 +0000
commit7f88d63097332810dc8335d87dfa8fa465180c7b (patch)
treee16acd76a5e3bc56bed3fba4e1ae726933708b8e
parent3ef1995d460169ad8c8863cca12f57db1cdf51a9 (diff)
ffmpeg workin
-rw-r--r--rotord/Makefile2
-rw-r--r--rotord/rotor.cpp47
2 files changed, 13 insertions, 36 deletions
diff --git a/rotord/Makefile b/rotord/Makefile
index 6bf75a0..3ccbfc2 100644
--- a/rotord/Makefile
+++ b/rotord/Makefile
@@ -4,7 +4,7 @@ MY_CFLAGS = -fpermissive -std=c++11
# -I ../ffmpeg
# The linker options.
-MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -lavcodec -lavutil -lavformat -lavfilter -lavdevice
+MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lavcodec -lavutil -lavformat -lavfilter -lavdevice
# The pre-processor options used by the cpp (man cpp for more).
CPPFLAGS = -Wall
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp
index 0662379..f8d48c1 100644
--- a/rotord/rotor.cpp
+++ b/rotord/rotor.cpp
@@ -333,52 +333,29 @@ bool Render_context::load_audio(string &filename){
std::shared_ptr<AVFormatContext> avFormat(avformat_alloc_context(), &avformat_free_context);
auto avFormatPtr = avFormat.get();
- if (avformat_open_input(&avFormatPtr,filename.c_str(), NULL, NULL) != 0) {
+ if (avformat_open_input(&avFormatPtr,filename.c_str(),nullptr, nullptr) != 0) {
cerr <<"Error while calling avformat_open_input (probably invalid file format)" << endl;
return false;
}
- if (avformat_find_stream_info(avFormat.get(), NULL) < 0) {
+ if (avformat_find_stream_info(avFormat.get(), nullptr) < 0) {
cerr << "Error while calling avformat_find_stream_info" << endl;
return false;
}
av_dump_format(avFormat.get(), 0, 0, false);
- for (unsigned int i = 0; i < avFormat->nb_streams; ++i) {
- auto stream = avFormat->streams[i]; // pointer to a structure describing the stream
- auto codecType = stream->codec->codec_type; // the type of data in this stream, notable values are AVMEDIA_TYPE_VIDEO and AVMEDIA_TYPE_AUDIO
- auto codecID = stream->codec->codec_id; // identifier for the codec
- cerr << "stream " << i << ": codec type: "<< codecType << " , id: "<<codecID <<endl;
- }
-
- static int audio_stream_idx = -1;
- static AVCodecContext *audio_dec_ctx;
- static AVStream *audio_stream = NULL;
-
- auto fmt_ctx=avFormat.get();
-
- if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
- int nb_planes;
- audio_stream = fmt_ctx->streams[audio_stream_idx];
- audio_dec_ctx = audio_stream->codec;
-
- /*
- audio_dst_file = fopen(audio_dst_filename, "wb");
- if (!audio_dst_file) {
- cerr << "Could not open destination file %s\n"<< endl;
- return false;
+ AVStream* stream = nullptr;
+ for (auto i = 0; i < avFormat->nb_streams; ++i) {
+ if (avFormat->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ // we've found a video stream!
+ stream = avFormat->streams[i];
+ break;
}
- nb_planes = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ?
- audio_dec_ctx->channels : 1;
- audio_dst_data = av_mallocz(sizeof(uint8_t *) * nb_planes);
- if (!audio_dst_data) {
- cerr << "Could not allocate audio data buffers\n"<< endl;
- return false;
- */
- }
- else {
- cerr << "Could not get codec context" << endl;
+ }
+
+ if (!stream)
+ cerr <<"Didn't find any audio stream in the file"<< endl;
return false;
}