diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-22 20:11:13 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-22 20:15:40 +0400 |
commit | 1ace8753918b9cf067db75921fdb8d246abdd2e8 (patch) | |
tree | 3e7d7fcf16f1bdac5b2741299ce4943020f368bd | |
parent | e2cd654a3e53c8265a2a27f69b861dc2e44106c3 (diff) |
Fix T37198: Vorbis encoding is broken
Issue was caused by wrong PTS calculation. This commit
makes this calculation closer to what's happening in
FFmpeg itself.
Seems everything is working now including newer FFmpeg,
but there's one thing which still doesn't work: writing
avi files with h264 codec and Vorbis audio doesn't play
correct in mplayer here. But didn't manage to get this
working even using FFmpeg CLI, so this might be just a
bug in FFmpeg/mplayer. Since this file works fine in
blender just fine wouldn't consider this is crucial thing
to look into at this moment.
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 713f970f1e5..d975e60146f 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -141,6 +141,7 @@ static int write_audio_frame(void) #ifdef FFMPEG_HAVE_ENCODE_AUDIO2 frame = avcodec_alloc_frame(); + frame->pts = audio_time / av_q2d(c->time_base); frame->nb_samples = audio_input_samples; frame->format = c->sample_fmt; #ifdef FFMPEG_HAVE_FRAME_CHANNEL_LAYOUT @@ -188,10 +189,12 @@ static int write_audio_frame(void) #endif if (got_output) { - if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { - pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); - PRINT("Audio Frame PTS: %d\n", (int) pkt.pts); - } + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts = av_rescale_q(pkt.pts, c->time_base, audio_stream->time_base); + if (pkt.dts != AV_NOPTS_VALUE) + pkt.dts = av_rescale_q(pkt.dts, c->time_base, audio_stream->time_base); + if (pkt.duration > 0) + pkt.duration = av_rescale_q(pkt.duration, c->time_base, audio_stream->time_base); pkt.stream_index = audio_stream->index; |