Opened 13 years ago
Closed 13 years ago
#428 closed defect (fixed)
avisynth generate wrong audio pts
Reported by: | chinshou | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | unspecified | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I just found avisynth.c generate very large audio pts.
we can use ffplay to play following avs
a0=DirectShowSource("1.avi")
v1=ImageSource("1.jpg", start=0, end = 14900, fps=30).BilinearResize(320,240)
video=FlipVertical(v1)
audio=(a0)
AudioDubEx(video,audio)
From the ffplay console log
18178.97 A-V:18166.132 s:0.0 aq= 314KB vq= 8552KB sq= 0B f=0/0 /0
I noticed that audio pts was very large than video pts.It seems we should remove following code from avisynth_read_packet function
pkt->pts = stream->read;<-------------remove this line
and correct pts should be
pkt->pts = avs->streams[stream_id].read / avs->streams[stream_id].chunck_samples;
static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
{
...
if (av_new_packet(pkt, stream->chunck_size))
return AVERROR(EIO);
pkt->stream_index = stream_id;
pkt->pts = avs->streams[stream_id].read / avs->streams[stream_id].chunck_samples;
res = AVIStreamRead(stream->handle, stream->read, stream->chunck_samples, pkt->data, stream->chunck_size, &read_size, NULL);
pkt->pts = stream->read;<-------------remove this line
pkt->size = read_size;
stream->read += stream->chunck_samples;
...
}
best regards
chinshou
Attachments (3)
Change History (8)
comment:1 by , 13 years ago
Status: | new → open |
---|
by , 13 years ago
Attachment: | patchavisynth.diff added |
---|
comment:2 by , 13 years ago
I have upload the patch, besides pts bug fix, this patch also fix the image displayed upside down bug .The upsidedown bug can be reproduced by following avs script
ImageSource("Sample1.jpg", start=0, end = 40, fps=25)
follow-up: 4 comment:3 by , 13 years ago
The indentation looks wrong, if the setting of pts is really wrong (I don't know, but in your original report you suggest an alternative calculation), please remove the line (do not just outcomment it), and unfortunately, we absolutely require "one patch per issue", so please attach (or send to ffmpeg-devel) one patch for the original (pts) issue and one patch for upside-down.
by , 13 years ago
Attachment: | patchavisynthpts.diff added |
---|
by , 13 years ago
Attachment: | patchavisynthupsidedown.diff added |
---|
comment:4 by , 13 years ago
Replying to cehoyos:
The indentation looks wrong, if the setting of pts is really wrong (I don't know, but in your original report you suggest an alternative calculation), please remove the line (do not just outcomment it), and unfortunately, we absolutely require "one patch per issue", so please attach (or send to ffmpeg-devel) one patch for the original (pts) issue and one patch for upside-down.
I have split the fix to two patches, original avisynth calculate the pts two times, the finally calculation was wrong , so I only delete one line in the pts patch.
Please produce your patch with "git diff libavformat/avisynth.c >patchavisynth.diff" and send the resulting file patchavisynth.diff to ffmpeg-devel (or attach it here).