Hi --
I'm capturing from a Hauppauge USB-Live2 capture card on kubuntu 24.10. ffmpeg command looks like this:
...when I try to play test.avi in vlc, the video looks fine but the audio is broken into bits and dragged longer than it should be. In other words, what should beffmpeg -f alsa -ac 2 -i hw:CARD=Cx231xxAudio,DEV=0 -f v4l2 -i /dev/video2 -c:a copy -c:v rawvideo test.avi
is actually played in pieces asCode:123456
If I play VLC to play it, the video is fine but the audio skips. If I use ffplay to play it, the audio plays fine, but the video is sped up way too fast. Smells like pts issues?Code:1 2 3 4 5 6
If I demux the video and audio using ffmpeg, the individual files play fine. This tells me that there is some kind of timing data being stored in the file that is incorrect. If I do this:
...the resulting files are identical when checked with ffprobe, but the "remuxed" version plays fine. If I extract the pts values like this:Code:ffmpeg -i test.avi -c:a copy -c:v copy test-remuxed.avi
...and I compared the broken original with the "remuxed" version, the pts for the video frames are the same in both versions, but the audio chunk pts are different. In the original, when ashowinfo reports x samples, it adds 4x to the pts; if you see here, nb_samples is 1024 but it jumps to pts:4096, then nb_samples is 256 and it jumps to pts:5120Code:ffmpeg -i test.avi -vf showinfo -af ashowinfo -fps_mode passthrough -copyts -f null /dev/null 2> pts.txt
In the working "remuxed" version the pts are linear with respect to the nb_samples:[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 ]
One other clue that may be important: when capturing, I get numerous errors like:[Parsed_ashowinfo_0 @ 0x76a788002f80] 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 @ 0x76a788002f80] n:1 pts:1024 pts_time:0.0213333 fmt:s16 channels:2 chlayout:stereo rate:48000 nb_samples:256 checksum:929680FC plane_checksums: [ 929680FC ]
[Parsed_ashowinfo_0 @ 0x76a788002f80] n:2 pts:1280 pts_time:0.0266667 fmt:s16 channels:2 chlayout:stereo rate:48000 nb_samples:1024 checksum:7A55BBD5 plane_checksums: [ 7A55BBD5 ]
and:[vost#0:0/rawvideo @ 0x55f451f6b280] Clipping frame in rate conversion by 0.011955
Any idea what's going on? Thanks![aost#0:1/copy @ 0x55f451f75440] Non-monotonic DTS; previous: 29662, current: 29564; changing to 29663. This may result in incorrect timestamps in the output file.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 8 of 8
Thread
-
-
-
Thanks! I'll give it a shot tomorrow.
All the documentation i find for reset_timestamps seems to imply that it's for the system stream segmenter muxer - am i somehow using that in the background of this process?Last edited by chconnor; 17th Nov 2024 at 18:12.
-
Tried it -- couldn't get the command to work. Am I missing something?
If I insert it before the audio stream spec (-i) I get:
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x480, 165722 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn
Output #0, alsa, to 'hw:CARD=Cx231xxAudio,DEV=0':
[out#0/alsa @ 0x647afc8110c0] Output file does not contain any stream
Error opening output file hw:CARD=Cx231xxAudio,DEV=0.
Error opening output files: Invalid argument
[video4linux2,v4l2 @ 0x647afc80ec80] Some buffers are still owned by the caller on close.
ioctl(VIDIOC_QBUF): Bad file descriptor
If I insert it before the video stream:
Output #0, video4linux2,v4l2, to '/dev/video2':
[out#0/video4linux2,v4l2 @ 0x5ff5a1379340] Output file does not contain any stream
Error opening output file /dev/video2.
Error opening output files: Invalid argument
If before the output filename it just doesn't see the output filename and gives a warning "Trailing option(s) found in the command: may be ignored."
I tried a variety of locations and couldn't get it to work... any other thoughts? -
try adding a 1 after reset_timestamps (-reset_timestamps 1) see if that works.
or try adding -fflags +genpts to your command This flag tells FFmpeg to generate PTS values based on the input stream’s timestamps, ensuring consistent and monotonically increasing values. Google ffmpeg -pts issue for more infoLast edited by october262; 17th Nov 2024 at 19:48.
-
Argh, sorry for being dense! I put -reset_timestamps 1 just before the output filename (other locations it said "unknown option") -- no change in results, unfortunately.
Also tried --fflags +genpts -- no change in results.
I googled ffmpeg -pts issue but didn't find anything obvious that you might have been referring to... ?
(I also tried various versions of -bsf:a setts=... but I don't really know what I'm doing and wasn't able to make anything good happen.) -
Progress: I discovered that if I specify the sample rate and format, even though I am specifying exactly what the stream already is detected to be, the result works and the pts values increment as expected:
ffmpeg -f alsa -ac 2 -i hw:CARD=Cx231xxAudio,DEV=0 -f v4l2 -i /dev/video2 -c:a pcm_s16le -ar 48000 -c:v rawvideo test.avi
Not sure if this is a bug? -
Suspected bug in ffmpeg; see here for more: https://trac.ffmpeg.org/ticket/11314
Similar Threads
-
Trying to fix video with out of sync PTS ffmpeg
By koala_ in forum Newbie / General discussionsReplies: 0Last Post: 29th Sep 2024, 07:51 -
weird image capturing with ezcap device
By kerm007 in forum Capturing and VCRReplies: 0Last Post: 15th Sep 2024, 16:38 -
Using FFMPEG to copy PTS from one video to another video, is this possible?
By Cyrax9 in forum MacReplies: 1Last Post: 11th Feb 2022, 18:37 -
Input raw audio 512 floating-point values into FFMPEG?
By ntphcm in forum Video ConversionReplies: 3Last Post: 30th Sep 2021, 22:14 -
How do I pass values from FFProbe to FFmpeg?
By Bassquake in forum ProgrammingReplies: 12Last Post: 10th Feb 2021, 10:39