Opened 12 hours ago
#11314 new defect
stuttering audio / strange audio pts when capturing v4l2 stream
Reported by: | chconnor | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | ffmpeg |
Version: | 7.0 | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
(I an non-expert -- apologies in advance if this is my confusion or a bug in my capture card's driver!)
I am capturing an audio stream and a v4l2 stream from an S/Video capture card (Hauppauge USB-Live2) like this:
ffmpeg -report -f alsa -ac 2 -i hw:CARD=Cx231xxAudio,DEV=0 -f v4l2 -i /dev/video2 -c:a copy -c:v rawvideo broken.avi
It generates a broken file that has stuttering audio, even though the individual audio and video streams work fine if demuxed. If I remux the file like this the result also works:
ffmpeg -i broken.avi -c:a copy -c:v copy working-remuxed.avi
If I manually specify the audio sample type and rate at capture, it works:
ffmpeg -report -f alsa -ac 2 -i hw:CARD=Cx231xxAudio,DEV=0 -f v4l2 -i /dev/video2 -c:a pcm_s16le -ar 48000 -c:v rawvideo working.avi
This strikes me as odd since in the broken case ffmpeg correctly identifies the incoming audio as pcm_s16le and 48kHz.
If I analyze the broken file with ashowinfo, it shows audio pts that are increasing by 4x the nb_samples. I don't know if this is wrong or not, but the "working" version has audio pts that increase by 1x the nb_samples.
Broken version (see how first nb_samples is 1024 and pts goes from 0 to 4096):
$ ffmpeg -i test.avi -vf showinfo -af ashowinfo -fps_mode passthrough -copyts -f null /dev/null 2> pts.txt ... [Parsed_ashowinfo_0 @ 0x70654c002f80] n:0 pts:0 pts_time:0 fmt:s16 channels:2 chlayout:stereo rate:48000 nb_samples:1024 checksum:73F22CAC plane_checksums: [ 73F22CAC ] [Parsed_ashowinfo_0 @ 0x70654c002f80] n:1 pts:4096 pts_time:0.0853333 fmt:s16 channels:2 chlayout:stereo rate:48000 nb_samples:256 checksum:929680FC plane_checksums: [ 929680FC ] [Parsed_ashowinfo_0 @ 0x70654c002f80] n:2 pts:5120 pts_time:0.106667 fmt:s16 channels:2 chlayout:stereo rate:48000 nb_samples:1024 checksum:7A55BBD5 plane_checksums: [ 7A55BBD5 ]
I note that I get non-monotonic DTS warnings when capturing (either broken or working version).
Attached is a log for working and broken capture, as well as ashowinfo results for working and broken.
Log of capture (broken version)