Open x850044053wwt opened 2 days ago
To implement the resample functionality, you can resample the audio stream using FFmpeg's aresample filter, with a command like audio_stream.ff_filter('aresample', '48000').
If you choose not to use this approach, you would need to implement resampling internally. In this case, the AVFrame PTS should be adjusted based on the number of samples in the frame, and the AVPacket PTS is typically calculated as the number of samples divided by the sample rate, multiplied by 1e6 to convert it to microseconds.
To implement the resample functionality, you can resample the audio stream using FFmpeg's aresample filter, with a command like audio_stream.ff_filter('aresample', '48000').
If you choose not to use this approach, you would need to implement resampling internally. In this case, the AVFrame PTS should be adjusted based on the number of samples in the frame, and the AVPacket PTS is typically calculated as the number of samples divided by the sample rate, multiplied by 1e6 to convert it to microseconds.
Thank you for your answer. In my case, pts should be set to the value of nsamples()
I want to construct an audio input stream with a sampling rate of 48000,apkt is an audio generator packet with a sampling rate of 44100,how to specify pts?
......
auto aframe = apkt.get<bmf_sdk::AudioFrame>();
bmf_sdk::AudioFrame af(aframe.planes(), aframe.layout(), aframe.planer());
af.set_sample_rate(aframe.sample_rate());
af.set_time_base(aframe.time_base());
af.set_pts(_video_time_stamp);
auto pkt_audio = Packet(af);
_video_time_stamp += 1024;
_main_pipeline->FillPacket(_audio_enc_in_stream->GetName(), pkt_audio);
......
The result of the above operation is wrong
af.set_pts(_video_time_stamp);
->af.set_pts(frame.pts());
is ok in single audio stream,but i need to maintain time stamp for multi input audio stream