) and found only small changes are needed.
This could be of general interest, because the changes are related to using a private ffmpeg APIs - i.e. it doesn't seem they were intended to be exposed and used outside of ffmpeg itself.
Do you think it'd be worth it to try to work with ffmpeg upstream to figure out how to make this a public API instead that Chrome could use?
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 155e980..7ba327a 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -966,24 +966,6 @@ void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb,
// If no estimate is found, the stream entry will be kInfiniteDuration().
std::vector<base::TimeDelta> start_time_estimates(format_context->nb_streams,
kInfiniteDuration());
- const AVFormatInternal* internal = format_context->internal;
- if (internal && internal->packet_buffer &&
- format_context->start_time != static_cast<int64>(AV_NOPTS_VALUE)) {
- struct AVPacketList* packet_buffer = internal->packet_buffer;
- while (packet_buffer != internal->packet_buffer_end) {
- DCHECK_LT(static_cast<size_t>(packet_buffer->pkt.stream_index),
- start_time_estimates.size());
- const AVStream* stream =
- format_context->streams[packet_buffer->pkt.stream_index];
- if (packet_buffer->pkt.pts != static_cast<int64>(AV_NOPTS_VALUE)) {
- const base::TimeDelta packet_pts =
- ConvertFromTimeBase(stream->time_base, packet_buffer->pkt.pts);
- if (packet_pts < start_time_estimates[stream->index])
- start_time_estimates[stream->index] = packet_pts;
- }
- packet_buffer = packet_buffer->next;
- }
- }
AVStream* audio_stream = NULL;
AudioDecoderConfig audio_config;
FWIW when actually linked against system ffmpeg 2.8 (not that easy on Ubuntu Trusty, I was using a Gentoo Linux chroot for this), the following tests fail:
[ RUN ] PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed_MediaSource
../../media/test/pipeline_integration_test.cc:877: Failure
Value of: GetAudioHash()
Actual: "-6.73,-4.16,-0.90,-0.41,-2.76,-5.68,"
Expected: kOpusEndTrimmingHash_1
Which is: "-4.56,-5.65,-6.51,-6.29,-4.36,-3.59,"
../../media/test/pipeline_integration_test.cc:885: Failure
Value of: GetAudioHash()
Actual: "-5.64,-4.37,-3.87,-4.65,-5.96,-6.76,"
Expected: kOpusEndTrimmingHash_2
Which is: "-11.89,-11.09,-8.25,-7.11,-7.84,-9.97,"
../../media/test/pipeline_integration_test.cc:894: Failure
Value of: GetAudioHash()
Actual: "-8.54,-8.24,-8.01,-8.37,-8.03,-8.00,"
Expected: kOpusEndTrimmingHash_3
Which is: "-13.28,-14.35,-13.67,-11.68,-10.18,-10.46,"
[ FAILED ] PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed_MediaSource (115 ms)
[2412/2414] PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed_MediaSource (115 ms)
[ RUN ] PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed
../../media/test/pipeline_integration_test.cc:851: Failure
Value of: GetAudioHash()
Actual: "-6.73,-4.16,-0.90,-0.41,-2.76,-5.68,"
Expected: kOpusEndTrimmingHash_1
Which is: "-4.56,-5.65,-6.51,-6.29,-4.36,-3.59,"
../../media/test/pipeline_integration_test.cc:857: Failure
Value of: GetAudioHash()
Actual: "-5.64,-4.37,-3.87,-4.65,-5.96,-6.76,"
Expected: kOpusEndTrimmingHash_2
Which is: "-11.89,-11.09,-8.25,-7.11,-7.84,-9.97,"
../../media/test/pipeline_integration_test.cc:864: Failure
Value of: GetAudioHash()
Actual: "-8.54,-8.24,-8.01,-8.37,-8.03,-8.00,"
Expected: kOpusEndTrimmingHash_3
Which is: "-13.28,-14.35,-13.67,-11.68,-10.18,-10.46,"
[ FAILED ] PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed (129 ms)
[2413/2414] PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed (129 ms)
[ RUN ] PipelineIntegrationTest.BasicPlaybackOpusOggTrimmingHashed
../../media/test/pipeline_integration_test.cc:828: Failure
Value of: GetAudioHash()
Actual: "-6.73,-4.16,-0.90,-0.41,-2.76,-5.68,"
Expected: kOpusEndTrimmingHash_1
Which is: "-4.56,-5.65,-6.51,-6.29,-4.36,-3.59,"
../../media/test/pipeline_integration_test.cc:834: Failure
Value of: GetAudioHash()
Actual: "-5.64,-4.37,-3.87,-4.65,-5.96,-6.76,"
Expected: kOpusEndTrimmingHash_2
Which is: "-11.89,-11.09,-8.25,-7.11,-7.84,-9.97,"
../../media/test/pipeline_integration_test.cc:841: Failure
Value of: GetAudioHash()
Actual: "-8.54,-8.24,-8.01,-8.37,-8.03,-8.00,"
Expected: kOpusEndTrimmingHash_3
Which is: "-13.28,-14.35,-13.67,-11.68,-10.18,-10.46,"
[ FAILED ] PipelineIntegrationTest.BasicPlaybackOpusOggTrimmingHashed (127 ms)
[2414/2414] PipelineIntegrationTest.BasicPlaybackOpusOggTrimmingHashed (127 ms)
3 tests failed:
PipelineIntegrationTest.BasicPlaybackOpusOggTrimmingHashed (../../media/test/pipeline_integration_test.cc:821)
PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed (../../media/test/pipeline_integration_test.cc:844)
PipelineIntegrationTest.BasicPlaybackOpusWebmTrimmingHashed_MediaSource (../../media/test/pipeline_integration_test.cc:868)
For completeness, I've needed one more change to make things work with system ffmpeg 2.8 (note how the #defines being removed affect the ABI - otherwise the code would crash when linked against system ffmpeg):
diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h
index 677bd76..23a21f8 100644
--- a/media/ffmpeg/ffmpeg_common.h
+++ b/media/ffmpeg/ffmpeg_common.h
@@ -19,20 +19,12 @@
// Include FFmpeg header files.
extern "C" {
-// Disable deprecated features which result in spammy compile warnings. This
-// list of defines must mirror those in the 'defines' section of the ffmpeg.gyp
-// file or the headers below will generate different structures.
-#define FF_API_PIX_FMT_DESC 0
-#define FF_API_OLD_DECODE_AUDIO 0
-#define FF_API_DESTRUCT_PACKET 0
-#define FF_API_GET_BUFFER 0
// Temporarily disable possible loss of data warning.
// TODO(scherkus): fix and upstream the compiler warnings.
MSVC_PUSH_DISABLE_WARNING(4244);
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
-#include <libavformat/internal.h>
#include <libavformat/avio.h>
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>