Skip to content

Commit

Permalink
音视频同步已解决,音频倍速问题已解决(PCM原始帧帧长太短,16KHZ 、160samples/帧 导致过多帧,发生了丢帧导致的)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanDaYu002 committed Jan 23, 2019
1 parent fbe1ee6 commit f4cb073
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions AVFileParse/libfmp4Encode/Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern "C"

//#define ONE_SECOND_DURATION (12800) //1秒时间分割数
#define VIDEO_TIME_SCALE (90000) //视频的内部时间戳(1s的分割数)
#define AUDIO_TIME_SCALE (90000) //音频的内部时间戳(1s的分割数)
#define AUDIO_TIME_SCALE (16000) //音频的内部时间戳(1s的分割数),填入采样率,用样本数来表述


#define VIDEO_ONE_MSC_LEN (VIDEO_TIME_SCALE/1000) //视频实际每毫秒对应内部时间长度
Expand All @@ -30,7 +30,7 @@ extern "C"
//#define AUDIO_SOURCE_SAMPLE_RATE (44100) //音频元数据的样本率 ,该参数已经对外层开放
#define AUDIO_FREAME_SAMPLES (1024) //一帧 AAC audio 帧的采样点数

#define ONE_AAC_FRAME_DURATION (AUDIO_TIME_SCALE * AUDIO_FREAME_SAMPLES/AUDIO_SOURCE_SAMPLE_RATE) //((AUDIO_FREAME_SAMPLES/AUDIO_SOURCE_SAMPLE_RATE)* AUDIO_TIME_SCALE) 1帧AAC音频帧播放时所占内部时长
//#define ONE_AAC_FRAME_DURATION (AUDIO_TIME_SCALE * AUDIO_FREAME_SAMPLES/AUDIO_SOURCE_SAMPLE_RATE) //((AUDIO_FREAME_SAMPLES/AUDIO_SOURCE_SAMPLE_RATE)* AUDIO_TIME_SCALE) 1帧AAC音频帧播放时所占内部时长


typedef unsigned int Fmp4TrackId; //轨道ID
Expand Down
2 changes: 1 addition & 1 deletion AVFileParse/libfmp4Encode/fmp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ int remuxAudio(void *audio_frame,unsigned int frame_length,unsigned int frame_ra
}
// DEBUG_LOG("A_tmp_sample_duration (%d)\n",tmp_sample_duration);
A_pre_time_scale_ms = time_scale;//记录当前帧时间戳,下一帧来时使用。
buf_remux_audio.sample_info[buf_remux_audio.write_index].trun_sample.sample_duration = t_htonl(tmp_sample_duration);//t_htonl(tmp_sample_duration);//t_htonl(ONE_AAC_FRAME_DURATION);//t_htonl(tmp_sample_duration);//t_htonl(1024)
buf_remux_audio.sample_info[buf_remux_audio.write_index].trun_sample.sample_duration = t_htonl(tmp_sample_duration);//t_htonl(AUDIO_FREAME_SAMPLES);//t_htonl(tmp_sample_duration);//t_htonl(ONE_AAC_FRAME_DURATION);//t_htonl(1024)
buf_remux_audio.sample_info[buf_remux_audio.write_index].trun_sample.sample_size = t_htonl(frame_length);
#if 0 // sample_flags 部分
buf_remux_audio.sample_info[buf_remux_audio.write_index].trun_sample.sample_flags = t_htonl(33554432 ); //audio 不使用该参数
Expand Down
Binary file modified AVFileParse/libfmp4Encode/fmp4.o
Binary file not shown.
Binary file modified AVFileParse/libfmp4Encode/libfmp4Encode.a
Binary file not shown.

0 comments on commit f4cb073

Please sign in to comment.