Opened 9 years ago
Closed 3 months ago
#4131 closed defect (fixed)
aresample=async=1000:first_pts=0 produced out-of-sync audio with Non-monotonous DTS in output stream warnings
Reported by: | Mika Raento | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avfilter |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
How to reproduce:
$ FFREPORT=1 ffmpeg -y -i broken_audio.ts -af aresample=async=1000:first_pts=0 broken_audio.mp4 ffmpeg version N-67656-g9a69cd6 Copyright (c) 2000-2014 the FFmpeg developers built on Nov 15 2014 14:05:16 with Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
attaching log from FFREPORT and the input file
Attachments (1)
Change History (10)
by , 9 years ago
Attachment: | ffmpeg-20141122-114243.log added |
---|
comment:1 by , 9 years ago
comment:2 by , 9 years ago
I tested the following:
$ ffmpeg -i broken_audio.ts -qscale 2 -vcodec mpeg4 -acodec aac -strict -2 out.mp4
The output file seems to play in sync. Why do you need the aresample filter?
comment:3 by , 9 years ago
I'm building a generic, automated pipeline where many inputs do need aresample (and many would benefit from first_pts) - I don't know which ones before-hand.
Also: this is cut from a larger file that most likely needs aresample; I just wanted to provide a reasonably minimal test case (the whole file is 5G, and the full processing takes a couple of hours with 24 cores).
comment:4 by , 9 years ago
Please provide a sufficiently long sample that allows to reproduce both that aresample is needed and that it does not work correctly. There is no size limit.
comment:5 by , 9 years ago
Why did you provide a sample that was created with FFmpeg and not the original sample?
comment:6 by , 9 years ago
Because it's a multi-stage pipeline and this is the step where it fails.
Also: the pipeline is proprietary and I can't share all the code without getting permission.
comment:7 by , 9 years ago
Sorry for the misunderstanding: I did not mean the code but the original media input that produces the sample you have issues with.
comment:8 by , 3 months ago
I came across this bug independently a few months ago. However, I only recently had time to look into it. Turns out it's due to the resampling context getting reinitialized and losing the state of some variables.
Patch sent to the ML. https://patchwork.ffmpeg.org/project/ffmpeg/patch/20231212112008.2500-1-ffmpeg@gyani.pro/
This is a brief demo of the behaviour.
Command:
ffmpeg -f lavfi -copyts -i sine=r=1000:samples_per_frame=100,asetpts='PTS+S+S*floor(ld(1)/4)+st(1,ld(1)+1)*0',atrim=end=1 -af ashowinfo@pre,aresample=async=300:first_pts=0,ashowinfo@post -f null -
Input frames (ashowinfo@pre):
n:0 pts:100 pts_time:0.1 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:47DC65D2 n:1 pts:200 pts_time:0.2 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:2 pts:300 pts_time:0.3 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:3 pts:400 pts_time:0.4 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:4 pts:600 pts_time:0.6 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:5 pts:700 pts_time:0.7 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:6 pts:800 pts_time:0.8 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:7 pts:900 pts_time:0.9 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0
Output frames - unpatched (ashowinfo@post):
n:0 pts:0 pts_time:0 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:132 checksum:C2981F45 n:1 pts:132 pts_time:0.132 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:68 checksum:E78E468D n:2 pts:200 pts_time:0.2 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:3 pts:300 pts_time:0.3 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:4 pts:400 pts_time:0.4 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:5 pts:0 pts_time:0 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:93 checksum:85CA5DB4 plan n:6 pts:93 pts_time:0.093 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:148 checksum:E39B24BA n:7 pts:241 pts_time:0.241 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:618 checksum:9ECE66E4 n:8 pts:859 pts_time:0.859 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:93 checksum:018B5C5C n:9 pts:952 pts_time:0.952 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:94 checksum:86695D43 n:10 pts:1046 pts_time:1.046 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:16 checksum:02470F0D
Output frames - patched (ashowinfo@post):
n:0 pts:0 pts_time:0 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:132 checksum:C2981F45 n:1 pts:132 pts_time:0.132 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:68 checksum:E78E468D n:2 pts:200 pts_time:0.2 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:3 pts:300 pts_time:0.3 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:4 pts:400 pts_time:0.4 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:100 checksum:D55C67D0 n:5 pts:500 pts_time:0.5 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:93 checksum:85CA5DB4 n:6 pts:593 pts_time:0.593 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:110 checksum:A2655D0B n:7 pts:703 pts_time:0.703 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:108 checksum:95CB6F01 n:8 pts:811 pts_time:0.811 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:108 checksum:F35668B8 n:9 pts:919 pts_time:0.919 fmt:s16 channels:1 chlayout:mono rate:1000 nb_samples:18 checksum:84C2130C
comment:9 by , 3 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The input file is too large for trac, uploaded to upload.ffmpeg.org instead.
If I don't use first_pts, the output is fine.
I would like to use first_pts in my processing pipeline to fill with silence when there is audio missing in the beginning.