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.
This commit is contained in:
parent
e2cd654a3e
commit
1ace875391
Notes:
blender-bot
2023-02-14 11:41:29 +01:00
Referenced by issue #37198, Vorbis encoding is broken
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue