ts or ps muxer not support mjpeg video codec ignore it (#2593)

This commit is contained in:
xiongguangjie 2023-06-28 14:56:06 +08:00 committed by GitHub
parent 2ad44bc773
commit d5bf99a27b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View File

@ -40,7 +40,7 @@ typedef enum {
XX(CodecVP8, TrackVideo, 7, "VP8", PSI_STREAM_VP8) \ XX(CodecVP8, TrackVideo, 7, "VP8", PSI_STREAM_VP8) \
XX(CodecVP9, TrackVideo, 8, "VP9", PSI_STREAM_VP9) \ XX(CodecVP9, TrackVideo, 8, "VP9", PSI_STREAM_VP9) \
XX(CodecAV1, TrackVideo, 9, "AV1", PSI_STREAM_AV1) \ XX(CodecAV1, TrackVideo, 9, "AV1", PSI_STREAM_AV1) \
XX(CodecJPEG, TrackVideo, 10, "JPEG", PSI_STREAM_JPEG_2000) XX(CodecJPEG, TrackVideo, 10, "JPEG", PSI_STREAM_RESERVED)
typedef enum { typedef enum {
CodecInvalid = -1, CodecInvalid = -1,

View File

@ -30,19 +30,18 @@ MpegMuxer::~MpegMuxer() {
releaseContext(); releaseContext();
} }
#define XX(name, type, value, str, mpeg_id) \ #define XX(name, type, value, str, mpeg_id) \
case name : { \ case name: { \
if (mpeg_id == PSI_STREAM_RESERVED) { \ if (mpeg_id == PSI_STREAM_RESERVED) { \
break; \ break; \
} \ } \
_codec_to_trackid[track->getCodecId()] = mpeg_muxer_add_stream((::mpeg_muxer_t *)_context, mpeg_id, nullptr, 0); \ if (track->getTrackType() == TrackVideo) { \
return true; \ _have_video = true; \
} \
_codec_to_trackid[track->getCodecId()] = mpeg_muxer_add_stream((::mpeg_muxer_t *)_context, mpeg_id, nullptr, 0); \
return true; \
} }
bool MpegMuxer::addTrack(const Track::Ptr &track) { bool MpegMuxer::addTrack(const Track::Ptr &track) {
if (track->getTrackType() == TrackVideo) {
_have_video = true;
}
switch (track->getCodecId()) { switch (track->getCodecId()) {
CODEC_MAP(XX) CODEC_MAP(XX)
default: break; default: break;
@ -85,6 +84,11 @@ bool MpegMuxer::inputFrame(const Frame::Ptr &frame) {
//没有视频时才以音频时间戳为TS的时间戳 //没有视频时才以音频时间戳为TS的时间戳
_timestamp = frame->dts(); _timestamp = frame->dts();
} }
if(frame->getTrackType() == TrackType::TrackVideo){
_key_pos = frame->keyFrame();
_timestamp = frame->dts();
}
_max_cache_size = 512 + 1.2 * frame->size(); _max_cache_size = 512 + 1.2 * frame->size();
mpeg_muxer_input((::mpeg_muxer_t *)_context, track_id, frame->keyFrame() ? 0x0001 : 0, frame->pts() * 90LL, frame->dts() * 90LL, frame->data(), frame->size()); mpeg_muxer_input((::mpeg_muxer_t *)_context, track_id, frame->keyFrame() ? 0x0001 : 0, frame->pts() * 90LL, frame->dts() * 90LL, frame->data(), frame->size());
flushCache(); flushCache();