Opened 10 years ago
Closed 10 years ago
#3797 closed defect (fixed)
AVStream.time_base is causing audio/video sync issues and growing videos
Reported by: | Roman Gaufman | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avformat |
Version: | git-master | Keywords: | regression |
Cc: | Michael Niedermayer | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I'm recording from a D-Link DCS-2230 IP Camera with this command:
ffmpeg -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i 'rtsp://admin:@192.168.1.83/live1.sdp' -dn -map 0 -codec:a libfdk_aac -flags +qscale -global_quality 1 -afterburner 1 -ar 44100 -codec:v copy -f segment -segment_time 60 -segment_wrap 10 -segment_list_flags live -segment_list_size 10 -reset_timestamps 1 -segment_list test.csv -y test_%02d.mkv
With Trunk from 2014/04/09 all works correctly and each output video is exactly 1 minute long. With Trunk from 2014/07/18 the audio duration slowly grows in size and the duration of each video gets 10 seconds longer:
With 2014/04/09 trunk:
deployer@XanBox:~/test$ mediainfo *.mkv | grep -i duration Duration : 1mn 0s Duration : 1mn 0s Duration : 1mn 0s Duration : 1mn 0s Duration : 1mn 0s Duration : 1mn 0s Duration : 1mn 0s Duration : 1mn 0s
With 2014/07/18 trunk:
deployer@XanBox:~/test$ mediainfo *.mkv | grep -i duration Duration : 1mn 1s Duration : 1mn 1s Duration : 1mn 1s Duration : 1mn 1s Duration : 1mn 1s Duration : 1mn 11s Duration : 1mn 11s Duration : 1mn 21s Duration : 1mn 21s
Any ideas what could have been changed/broken to cause this to happen?
Attachments (2)
Change History (29)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
I will try to narrow down when the breaking change happened but it is between 2014/04/09 and 2014/07/18 (today's trunk is also broken 2014/07/23).
Here are the complete uncut console outputs from the working and non working versions of ffmpeg:
2014/04/09 working version:
deployer@XanBox:~/test$ ffmpeg -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i rtsp://localhost:10103/proxyStream -dn -map 0 -codec:a libfdk_aac -flags +qscale -global_quality 1 -afterburner 1 -ar 44100 -codec:v copy -f segment -segment_time 60 -segment_wrap 10 -segment_list_flags live -segment_list_size 10 -reset_timestamps 1 -segment_list test.csv -y test_%02d.mkv ffmpeg version N-62296-g4484152 Copyright (c) 2000-2014 the FFmpeg developers built on Apr 9 2014 09:19:33 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9) configuration: --enable-pic --enable-shared --extra-ldflags=-ldl --enable-gpl --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --extra-cflags=-fPIC --extra-ldflags=-fPIC libavutil 52. 75.100 / 52. 75.100 libavcodec 55. 58.103 / 55. 58.103 libavformat 55. 36.102 / 55. 36.102 libavdevice 55. 11.100 / 55. 11.100 libavfilter 4. 3.100 / 4. 3.100 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 [tcp @ 0x17c1500] Connection to tcp://localhost:10103?timeout=0 failed (Connection refused), trying next address Guessed Channel Layout for Input Stream #0.1 : mono Input #0, rtsp, from 'rtsp://localhost:10103/proxyStream': Metadata: title : LIVE555 Streaming Media v2014.07.18 comment : LIVE555 Streaming Media v2014.07.18 Duration: N/A, start: 1406133663.110367, bitrate: 64 kb/s Stream #0:0: Video: h264 (High), yuvj420p(pc), 1920x1080, 12.50 fps, 12.50 tbr, 90k tbn, 25 tbc Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s [libfdk_aac @ 0x18d4720] Note, the VBR setting is unsupported and only works with some parameter combinations Output #0, segment, to 'test_%02d.mkv': Metadata: title : LIVE555 Streaming Media v2014.07.18 comment : LIVE555 Streaming Media v2014.07.18 encoder : Lavf55.36.102 Stream #0:0: Video: h264, yuvj420p, 1920x1080, q=2-31, 12.50 fps, 90k tbn, 12.50 tbc Stream #0:1: Audio: aac (libfdk_aac), 44100 Hz, mono, s16 Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (pcm_mulaw -> libfdk_aac) Press [q] to stop, [?] for help [libfdk_aac @ 0x18d4720] Queue input is backward in time [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 83051, current: 81429; changing to 83052. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x18d4720] Queue input is backward in time [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 163451, current: 162873; changing to 163452. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x18d4720] Queue input is backward in timerate=N/A [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 200406, current: 198233; changing to 200407. This may result in incorrect timestamps in the output file. [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 200407, current: 200322; changing to 200408. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x18d4720] Queue input is backward in time [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 231963, current: 229880; changing to 231964. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x18d4720] Queue input is backward in timerate=N/A [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 268761, current: 267173; changing to 268762. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x18d4720] Queue input is backward in timerate=N/A [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 370937, current: 367886; changing to 370938. This may result in incorrect timestamps in the output file. [segment @ 0x17c6d00] Non-monotonous DTS in output stream 0:1; previous: 370938, current: 369976; changing to 370939. This may result in incorrect timestamps in the output file. frame= 78 fps= 21 q=-1.0 Lsize=N/A time=00:00:05.30 bitrate=N/A
2014/07/18 broken version:
deployer@XanBox:~/test$ ffmpeg -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i rtsp://localhost:10103/proxyStream -dn -map 0 -codec:a libfdk_aac -flags +qscale -global_quality 1 -afterburner 1 -ar 44100 -codec:v copy -f segment -segment_time 60 -segment_wrap 10 -segment_list_flags live -segment_list_size 10 -reset_timestamps 1 -segment_list test.csv -y test_%02d.mkv ffmpeg version N-64763-gcb8cb85 Copyright (c) 2000-2014 the FFmpeg developers built on Jul 18 2014 16:39:59 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1) configuration: --enable-pic --enable-shared --extra-ldflags=-ldl --enable-gpl --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --extra-cflags=-fPIC --extra-ldflags=-fPIC libavutil 52. 92.101 / 52. 92.101 libavcodec 55. 69.100 / 55. 69.100 libavformat 55. 48.101 / 55. 48.101 libavdevice 55. 13.102 / 55. 13.102 libavfilter 4. 11.102 / 4. 11.102 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 [tcp @ 0x1c60760] Connection to tcp://localhost:10103?timeout=0 failed (Connection refused), trying next address Guessed Channel Layout for Input Stream #0.1 : mono Input #0, rtsp, from 'rtsp://localhost:10103/proxyStream': Metadata: title : LIVE555 Streaming Media v2014.07.18 comment : LIVE555 Streaming Media v2014.07.18 Duration: N/A, start: 1406133752.034367, bitrate: 64 kb/s Stream #0:0: Video: h264 (High), yuvj420p(pc), 1920x1080, 12.50 fps, 12.50 tbr, 90k tbn, 25 tbc Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s [libfdk_aac @ 0x1d09d60] Note, the VBR setting is unsupported and only works with some parameter combinations [matroska @ 0x1c490c0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead. Last message repeated 1 times Output #0, segment, to 'test_%02d.mkv': Metadata: title : LIVE555 Streaming Media v2014.07.18 comment : LIVE555 Streaming Media v2014.07.18 encoder : Lavf55.48.101 Stream #0:0: Video: h264, yuvj420p, 1920x1080, q=2-31, 12.50 fps, 12.50 tbn, 12.50 tbc Stream #0:1: Audio: aac (libfdk_aac), 44100 Hz, mono, s16 Metadata: encoder : Lavc55.69.100 libfdk_aac Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (libfdk_aac)) Press [q] to stop, [?] for help [libfdk_aac @ 0x1d09d60] Queue input is backward in time [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 15703, current: 15035; changing to 15704. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x1d09d60] Queue input is backward in time [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 20155, current: 19062; changing to 20156. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 20156, current: 20086; changing to 20157. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x1d09d60] Queue input is backward in time [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 30812, current: 29659; changing to 30813. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 30813, current: 30683; changing to 30814. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x1d09d60] Queue input is backward in time [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 59280, current: 59130; changing to 59281. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 17, current: 17; changing to 18. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x1d09d60] Queue input is backward in time [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 70136, current: 68999; changing to 70137. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 70137, current: 70023; changing to 70138. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 18, current: 18; changing to 19. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 19, current: 19; changing to 20. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 20, current: 20; changing to 21. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 21, current: 21; changing to 22. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 22, current: 22; changing to 23. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 24, current: 24; changing to 25. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 25, current: 25; changing to 26. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 26, current: 26; changing to 27. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 27, current: 26; changing to 28. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 28, current: 27; changing to 29. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 29, current: 28; changing to 30. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 30, current: 28; changing to 31. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 31, current: 29; changing to 32. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 32, current: 30; changing to 33. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 33, current: 31; changing to 34. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x1d09d60] Queue input is backward in time [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:1; previous: 115859, current: 114860; changing to 115860. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 34, current: 32; changing to 35. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 35, current: 33; changing to 36. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 36, current: 34; changing to 37. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 37, current: 35; changing to 38. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 38, current: 36; changing to 39. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 39, current: 37; changing to 40. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 40, current: 38; changing to 41. This may result in incorrect timestamps in the output file. [segment @ 0x1c663e0] Non-monotonous DTS in output stream 0:0; previous: 41, current: 38; changing to 42. This may result in incorrect timestamps in the output file. frame= 27 fps= 17 q=-1.0 Lsize=N/A time=00:00:03.44 bitrate=N/A
comment:3 by , 10 years ago
I've identified what specific commit caused this issue and it is:
commit ac293b66851f6c4461eab03ca91af59d5ee4e02e Merge: 8851437 194be1f Author: Michael Niedermayer <michaelni@gmx.at> Date: Wed Jun 18 18:18:25 2014 +0200 Merge commit '194be1f43ea391eb986732707435176e579265aa' * commit '194be1f43ea391eb986732707435176e579265aa': lavf: switch to AVStream.time_base as the hint for the muxer timebase Conflicts: doc/APIchanges libavformat/filmstripenc.c libavformat/movenc.c libavformat/mxfenc.c libavformat/oggenc.c libavformat/swf.h libavformat/version.h tests/ref/lavf/mkv Merged-by: Michael Niedermayer <michaelni@gmx.at>
This is the diff of what was changed: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=ac293b66851f6c4461eab03ca91af59d5ee4e02e
comment:4 by , 10 years ago
Summary: | Latest trunk is not syncing audio/video from RTSP → AVStream.time_base is causing audio/video sync issues and growing videos |
---|
comment:5 by , 10 years ago
Component: | undetermined → avformat |
---|
comment:6 by , 10 years ago
Status: | new → open |
---|
comment:7 by , 10 years ago
Keywords: | regression added |
---|
comment:8 by , 10 years ago
please provide a publically available rtsp url with which this can be reproduced or a local input file if it can be reproduced without rtsp
so we can debug, test and fix this. Ive fixes some related issues but i suspect this is still not working
comment:9 by , 10 years ago
I'm not quite sure how to get a local input file - any example? -- Otherwise I will connect and set up port forwarding tomorrow.
comment:10 by , 10 years ago
you could try to copy the rtsp stuff into some container and check if its reproduceabel with that.
something like ffmpeg -i rstp... -vcodec copy -acodec copy file.nut / file.mkv
comment:11 by , 10 years ago
Cc: | added |
---|
comment:13 by , 10 years ago
Correction, the stream is on: rtsp://86.146.232.61/proxyStream
To reproduce, if you are using homebrew on a Mac, compile ffmpeg with fdk-aac: brew install ffmpeg --with-fdk-aac --HEAD
Then run:
ffmpeg -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i 'rtsp://86.146.232.61/proxyStream' -dn -map 0 -codec:a libfdk_aac -ar 44100 -codec:v copy -f segment -segment_time 60 -segment_wrap 10 -segment_list_flags live -segment_list_size 10 -reset_timestamps 1 -segment_list test.csv -y 'test_%02d.mkv'
comment:14 by , 10 years ago
Is libfdk required to reproduce the problem or is it also reproducible with the native aac encoder?
follow-up: 16 comment:15 by , 10 years ago
I haven't tried the native one as it says "The encoder 'aac' is experimental but experimental codecs are not enabled".
When using libbfaac, the "Non-monotonous DTS" errors are less frequent and the duration doesn't grow, so it does seem to be related to libfdk, not sure if it relates to others too.
comment:16 by , 10 years ago
Replying to hackeron:
I haven't tried the native one as it says "The encoder 'aac' is experimental but experimental codecs are not enabled".
Please test with -acodec aac -strict -2
.
comment:17 by , 10 years ago
There seem to be a lot more errors like this:
[segment @ 0x19a5e20] Non-monotonous DTS in output stream 0:1; previous: 12466764, current: 12460908; changing to 12466765. This may result in incorrect timestamps in the output file. [segment @ 0x19a5e20] Non-monotonous DTS in output stream 0:1; previous: 12466765, current: 12462998; changing to 12466766. This may result in incorrect timestamps in the output file. [aac @ 0x1a45b80] Queue input is backward in time
But the output video time doesn't grow so I guess it is related to libfdk_aac.
This is the full command I'm using:
ffmpeg -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i 'rtsp://86.146.232.61/proxyStream' -dn -map 0 -acodec aac -strict -2 -ar 44100 -codec:v copy -f segment -segment_time 60 -segment_wrap 10 -segment_list_flags live -segment_list_size 10 -reset_timestamps 1 -segment_list test.csv -y 'test_%02d.mkv'
comment:18 by , 10 years ago
Connection to tcp://86.146.232.61:554?timeout=0 failed: Connection timed out
follow-up: 21 comment:20 by , 10 years ago
Hello, i got similar problem (alot of "Non-monotonous DTS" and picture
twitching) with input from mumudvb.
The problem are appear only with "-codec:v copy".
There is no such problem with ffmpeg 2.2.1, and there are with ffmpeg 2.3.3 and 2.4.1
If you need, i can share input stream.
comment:21 by , 10 years ago
Replying to ricky-ticky:
If you need, i can share input stream.
This is only needed if you'd like the issue fixed.
comment:22 by , 10 years ago
The IP address changed, here is the up to date address:
ffmpeg -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i 'rtsp://86.146.233.53/proxyStream' -dn -map 0 -acodec aac -strict -2 -ar 44100 -codec:v copy -f segment -segment_time 60 -segment_wrap 10 -segment_list_flags live -segment_list_size 10 -reset_timestamps 1 -segment_list test.csv -y 'test_%02d.mkv'
comment:23 by , 10 years ago
share my stream too: http://194.85.16.42:9005. IP is static.
use it like this:
/usr/bin/ffmpeg -i http://194.85.16.42:9005 -vcodec copy -threads 4 -strict experimental -acodec libfdk_aac -ar 44100 -ac 2 -ab 96000 -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 /live/stream/hi.m3u8
comment:24 by , 10 years ago
added two attachments with ffmpeg 2.2.1 and 2.4.1 console output for same stream.
comment:25 by , 10 years ago
the rtsp://86.146.233.53/proxyStream
stream freezes after a few seconds with every version i tried. The other results in http://194.85.16.42:9005: No such file or directory
comment:26 by , 10 years ago
The "No such file or directory" was caused by a unicode "zero width space" in there
comment:27 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
If you want to report a regression, please run
git bisect
to find the change introducing the bug.To make this a valid ticket please provide the command line that does not work correctly together with the complete uncut console output.