[Libav-user] How to handle files with variable sample rate?
Kitchen PC
xirexx at gmail.com
Sat Sep 18 20:24:39 EEST 2021
Hi,
I've got a .dts file, which I'm decoding using FFmpeg libraries.
The file is detected as DTS 96/24, which would be fine, but the thing is
that only some first frames have sample_rate 96000 while all the rest ones
have sample_rate 48000.
As a result the decoded audio is assumed to be 96000, but in the reality
it's 48000 and it plays back at wrong speed.
FFmpeg handles this file fine, the result output is 96Khz audio, played at
a proper speed.
My question is how to handle files like this? Do I need to re-sample those
frames to the 96000 or that can be handled via FFmpeg automatically?
I modified ffprobe to print the sample_rate for each frame, as it does not
it by default, and the output is like this:
ffprobe.exe -v debug -show_frames -show_format file.dts
...
up until this all frames are 96000
...
media_type=audio
stream_index=0
sample_rate=96000 -- !
key_frame=1
pts=132480
pts_time=1.472000
pkt_dts=132480
pkt_dts_time=1.472000
best_effort_timestamp=132480
best_effort_timestamp_time=1.472000
pkt_duration=960
pkt_duration_time=0.010667
pkt_pos=277794
pkt_size=2013
sample_fmt=fltp
nb_samples=1024
channels=6
channel_layout=5.1(side)
[SIDE_DATA]
side_data_type=AVMatrixEncoding
[/SIDE_DATA]
[/FRAME]
And starting from here, all the following frames have sample_rate 48000
[FRAME]
media_type=audio
stream_index=0
sample_rate=48000 -- !
key_frame=1
pts=133440
pts_time=1.482667
pkt_dts=133440
pkt_dts_time=1.482667
best_effort_timestamp=133440
best_effort_timestamp_time=1.482667
pkt_duration=960
pkt_duration_time=0.010667
pkt_pos=279807
pkt_size=2013
sample_fmt=fltp
nb_samples=512
channels=6
channel_layout=5.1(side)
[SIDE_DATA]
side_data_type=AVMatrixEncoding
[/SIDE_DATA]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210918/bcc7cd76/attachment.htm>
More information about the Libav-user
mailing list