summaryrefslogtreecommitdiff
path: root/libavformat/nutenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-01 21:56:27 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-02 01:09:12 +0200
commit4eb0f5f635462562275200ecb6b4e1b718fcae37 (patch)
tree73eb2afa736f9a5e1b3a74808d6b2eb48084d8d0 /libavformat/nutenc.c
parentc4dba58f47a9b1b37458ddb2dd8500b7f3ea4d06 (diff)
downloadffmpeg-4eb0f5f635462562275200ecb6b4e1b718fcae37.tar.gz
nutenc: use 1/sample rate as timebase for audio instead of framesize/sample rate
This way audio frames can be exactly stored even when they are not aligned with timestamp 0 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/nutenc.c')
-rw-r--r--libavformat/nutenc.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index f719c8ea59..955a6fb5fa 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -156,6 +156,13 @@ static void build_frame_code(AVFormatContext *s){
int is_audio= codec->codec_type == AVMEDIA_TYPE_AUDIO;
int intra_only= /*codec->intra_only || */is_audio;
int pred_count;
+ int frame_size = av_get_audio_frame_duration(codec, 0);
+
+ if (codec->codec_id == AV_CODEC_ID_VORBIS && !frame_size) {
+ frame_size = 64;
+ }
+ if(!frame_size)
+ frame_size = 1;
for(key_frame=0; key_frame<2; key_frame++){
if(intra_only && keyframe_0_esc && key_frame==0)
@@ -185,7 +192,7 @@ static void build_frame_code(AVFormatContext *s){
ft->stream_id= stream_id;
ft->size_mul=frame_bytes + 2;
ft->size_lsb=frame_bytes + pred;
- ft->pts_delta=pts;
+ ft->pts_delta=pts * frame_size;
ft->header_idx= find_header_idx(s, codec, frame_bytes + pred, key_frame);
start2++;
}
@@ -195,7 +202,7 @@ static void build_frame_code(AVFormatContext *s){
ft->flags= FLAG_KEY | FLAG_SIZE_MSB;
ft->stream_id= stream_id;
ft->size_mul=1;
- ft->pts_delta=1;
+ ft->pts_delta=frame_size;
start2++;
}
#endif
@@ -221,6 +228,8 @@ static void build_frame_code(AVFormatContext *s){
int start3= start2 + (end2-start2)*pred / pred_count;
int end3 = start2 + (end2-start2)*(pred+1) / pred_count;
+ pred_table[pred] *= frame_size;
+
for(index=start3; index<end3; index++){
FrameCode *ft= &nut->frame_code[index];
ft->flags= FLAG_KEY*key_frame;
@@ -653,6 +662,10 @@ static int nut_write_header(AVFormatContext *s){
AVRational time_base;
ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
+ if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) {
+ time_base = (AVRational){1, st->codec->sample_rate};
+ }
+
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
for(j=0; j<nut->time_base_count; j++){