Commit 63aac879 authored by michael's avatar michael

A/V Synch in ffmpeg patch by (Luca Abeni <lucabe72 at email dot it>)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3233 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 7b178680
...@@ -225,6 +225,7 @@ static int64_t audio_size = 0; ...@@ -225,6 +225,7 @@ static int64_t audio_size = 0;
static int64_t extra_size = 0; static int64_t extra_size = 0;
static int nb_frames_dup = 0; static int nb_frames_dup = 0;
static int nb_frames_drop = 0; static int nb_frames_drop = 0;
static int input_sync;
#define DEFAULT_PASS_LOGFILENAME "ffmpeg2pass" #define DEFAULT_PASS_LOGFILENAME "ffmpeg2pass"
...@@ -1655,16 +1656,20 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1655,16 +1656,20 @@ static int av_encode(AVFormatContext **output_files,
/* select the stream that we must read now by looking at the /* select the stream that we must read now by looking at the
smallest output pts */ smallest output pts */
file_index = -1; file_index = -1;
pts_min = 1e10; pts_min = 1e100;
for(i=0;i<nb_ostreams;i++) { for(i=0;i<nb_ostreams;i++) {
double pts; double pts;
ost = ost_table[i]; ost = ost_table[i];
os = output_files[ost->file_index]; os = output_files[ost->file_index];
ist = ist_table[ost->source_index]; ist = ist_table[ost->source_index];
if (input_sync == 0) {
if(ost->st->codec.codec_type == CODEC_TYPE_VIDEO) if(ost->st->codec.codec_type == CODEC_TYPE_VIDEO)
pts = (double)ost->sync_opts * ost->st->codec.frame_rate_base / ost->st->codec.frame_rate; pts = (double)ost->sync_opts * ost->st->codec.frame_rate_base / ost->st->codec.frame_rate;
else else
pts = (double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den; pts = (double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den;
} else {
pts = (double)ist->pts;
}
if (!file_table[ist->file_index].eof_reached && if (!file_table[ist->file_index].eof_reached &&
pts < pts_min) { pts < pts_min) {
pts_min = pts; pts_min = pts;
...@@ -3792,6 +3797,7 @@ int main(int argc, char **argv) ...@@ -3792,6 +3797,7 @@ int main(int argc, char **argv)
} }
if (nb_input_files == 0) { if (nb_input_files == 0) {
input_sync = 1;
prepare_grab(); prepare_grab();
} }
......
...@@ -263,6 +263,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -263,6 +263,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
if (ret == -1 && (errno == EAGAIN || errno == EINTR)) { if (ret == -1 && (errno == EAGAIN || errno == EINTR)) {
av_free_packet(pkt); av_free_packet(pkt);
pkt->size = 0; pkt->size = 0;
pkt->pts = av_gettime() & ((1LL << 48) - 1);
return 0; return 0;
} }
if (!(ret == 0 || (ret == -1 && (errno == EAGAIN || errno == EINTR)))) { if (!(ret == 0 || (ret == -1 && (errno == EAGAIN || errno == EINTR)))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment