mirror of
https://github.com/v0l/zap-stream-core.git
synced 2025-06-21 14:10:45 +00:00
fix: remuxed packet timestamps
This commit is contained in:
@ -4,14 +4,16 @@ use std::ptr;
|
|||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use ffmpeg_sys_next::{
|
use ffmpeg_sys_next::{
|
||||||
av_dump_format, av_interleaved_write_frame, av_opt_set, avcodec_parameters_copy,
|
av_dump_format, av_interleaved_write_frame, av_opt_set, av_packet_rescale_ts,
|
||||||
avcodec_parameters_from_context, avformat_alloc_output_context2, avformat_free_context, avformat_write_header, AVFormatContext, AVPacket, AVStream,
|
avcodec_parameters_copy, avcodec_parameters_from_context, avformat_alloc_output_context2,
|
||||||
|
avformat_free_context, avformat_write_header, AVFormatContext, AVPacket, AVStream,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::info;
|
use log::info;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::egress::{map_variants_to_streams, EgressConfig};
|
use crate::egress::{map_variants_to_streams, EgressConfig};
|
||||||
|
use crate::encode::dump_pkt_info;
|
||||||
use crate::pipeline::{AVPacketSource, PipelinePayload, PipelineProcessor};
|
use crate::pipeline::{AVPacketSource, PipelinePayload, PipelineProcessor};
|
||||||
use crate::return_ffmpeg_error;
|
use crate::return_ffmpeg_error;
|
||||||
use crate::utils::get_ffmpeg_error_msg;
|
use crate::utils::get_ffmpeg_error_msg;
|
||||||
@ -192,7 +194,6 @@ impl HlsEgress {
|
|||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
av_dump_format(self.ctx, 0, ptr::null(), 1);
|
av_dump_format(self.ctx, 0, ptr::null(), 1);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -203,15 +204,19 @@ impl HlsEgress {
|
|||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let variant = match src {
|
let variant = match src {
|
||||||
AVPacketSource::Encoder(v) => find_stream(&self.variants, v)?,
|
AVPacketSource::Encoder(v) => find_stream(&self.variants, v)?,
|
||||||
AVPacketSource::Demuxer(v) => self
|
AVPacketSource::Demuxer(v) => {
|
||||||
|
let var = self
|
||||||
.variants
|
.variants
|
||||||
.iter()
|
.iter()
|
||||||
.find(|x| x.src_index() == (*(*v)).index as usize)
|
.find(|x| x.src_index() == (*(*v)).index as usize)
|
||||||
.ok_or(Error::msg("Demuxer packet didn't match any variant"))?,
|
.ok_or(Error::msg("Demuxer packet didn't match any variant"))?;
|
||||||
|
let dst_stream = Self::get_dst_stream(self.ctx, var.dst_index());
|
||||||
|
av_packet_rescale_ts(pkt, (*(*v)).time_base, (*dst_stream).time_base);
|
||||||
|
var
|
||||||
|
}
|
||||||
};
|
};
|
||||||
(*pkt).stream_index = variant.dst_index() as libc::c_int;
|
(*pkt).stream_index = variant.dst_index() as libc::c_int;
|
||||||
|
|
||||||
//dump_pkt_info(pkt);
|
|
||||||
let ret = av_interleaved_write_frame(self.ctx, pkt);
|
let ret = av_interleaved_write_frame(self.ctx, pkt);
|
||||||
return_ffmpeg_error!(ret);
|
return_ffmpeg_error!(ret);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Reference in New Issue
Block a user