资源简介
利用MP4v2将rtsp流保存为MP4,ffmpeg版本为4.0.1,其中的dll,lib,include可在博客中提供的地址下载,或者官网下载,编译环境为vs2012

代码片段和文件信息
#pragma once
#include “MP4Encoder.h“
#define DEFAULT_VIDEO_TRACK_NUM 3
#define DEFAULT_VIDEO_PROFILE_LEVEL 1
#define DEFAULT_AUDIO_PROFILE_LEVEL 2
MP4Encoder::MP4Encoder(void)
: m_hFile(MP4_INVALID_FILE_HANDLE)
m_videoTrack(MP4_INVALID_TRACK_ID)
m_audioTrack(MP4_INVALID_TRACK_ID)
{
}
MP4Encoder::~MP4Encoder(void)
{
}
int MP4Encoder::MP4CreateFile(const char *sFileNameint Movie_Time_Scale)
{
m_hFile = MP4Create(sFileName);
if (m_hFile == MP4_INVALID_FILE_HANDLE)
{
printf(“create mp4 file error!\n“);
return -1;
}
if (!MP4SetTimeScale(m_hFile Movie_Time_Scale))
{
printf(“set time Scale error!\n“);
return -1;
}
return 0;
}
int MP4Encoder::MP4AddH264Track(const uint8_t *sData int nSize
int nWidth int nHeight int nframeRate int Video_Time_Scale)
{
int sps pps;
for (sps = 0; sps < nSize;)
if (sData[sps++] == 0x00 && sData[sps++] == 0x00 && sData[sps++] == 0x00
&& sData[sps++] == 0x01)
break;
for (pps = sps; pps < nSize;)
if (sData[pps++] == 0x00 && sData[pps++] == 0x00 && sData[pps++] == 0x00
&& sData[pps++] == 0x01)
break;
if (sps >= nSize || pps >= nSize)
return -1;
m_videoTrack = MP4AddH264VideoTrack(m_hFile Video_Time_Scale
Video_Time_Scale / nframeRate nWidth nHeight
sData[sps + 1] sData[sps + 2] sData[sps + 3] DEFAULT_VIDEO_TRACK_NUM);//sps 后面的三个字节
if (MP4_INVALID_TRACK_ID == m_videoTrack)
{
printf(“add video track error!\n“);
return -1;
}
MP4SetVideoProfileLevel(m_hFile DEFAULT_VIDEO_PROFILE_LEVEL);
MP4AddH264SequenceParameterSet(m_hFile m_videoTrack sData + spspps - sps - 4);//sps 内容 起始位置+长度
MP4AddH264PictureParameterSet(m_hFile m_videoTrack sData + ppsnSize - pps);// pps 内容 起始位置+长度
return 0;
}
int MP4Encoder::MP4AddAACTrack(const uint8_t *sData int nSizeint Audio_Time_Scale)
{
m_audioTrack = MP4AddAudioTrack(m_hFile Audio_Time_Scale1024 MP4_MPEG4_AUDIO_TYPE);
if (MP4_INVALID_TRACK_ID == m_audioTrack)
{
printf(“add audio track error!\n“);
return -1;
}
MP4SetAudioProfileLevel(m_hFile DEFAULT_AUDIO_PROFILE_LEVEL);
if (!MP4SetTrackESConfiguration(m_hFile m_audioTrack sData nSize))
{
printf(“set track ESConfiguration error!\n“);
return -1;
}
return 0;
}
int MP4Encoder::MP4WriteH264Data(uint8_t *sData int nSize)
{
bool result = false;
sData[0] = (nSize - 4) >> 24;
sData[1] = (nSize - 4) >> 16;
sData[2] = (nSize - 4) >> 8;
sData[3] = nSize - 4;
if(nSize<0||sData==NULL)
return -1;
if ((sData[4] & 0x1F) == 5)//判断I帧
result = MP4WriteSample(m_hFile m_videoTrack sData nSizeMP4_INVALID_DURATION0true);
else
result = MP4WriteSample(m_hFile m_videoTrack sData nSizeMP4_INVALID_DURATION0false);
if (!result)
{
printf(“write h264 frame error!\n“);
return -1;
}
return 0;
}
int MP4Encoder::MP4WriteAACData(const uint8_t *sData int nSize)
{
bool result = false;
if(nSize<0||sData==NULL)
ret
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-08-22 22:42 MP4Recorder\
目录 0 2018-08-22 22:44 MP4Recorder\Debug\
目录 0 2018-08-22 22:42 MP4Recorder\MP4Recorder\
文件 4603 2018-08-22 21:32 MP4Recorder\MP4Recorder\HeadInfo.h
文件 3426 2018-08-22 21:04 MP4Recorder\MP4Recorder\MP4Encoder.cpp
文件 664 2018-08-22 21:04 MP4Recorder\MP4Recorder\MP4Encoder.h
文件 18294 2018-08-22 22:28 MP4Recorder\MP4Recorder\MP4Recorder.cpp
文件 5028 2018-08-22 21:06 MP4Recorder\MP4Recorder\MP4Recorder.h
文件 4629 2018-08-22 21:36 MP4Recorder\MP4Recorder\MP4Recorder.vcxproj
文件 1437 2018-08-17 20:38 MP4Recorder\MP4Recorder\MP4Recorder.vcxproj.filters
文件 164 2018-08-18 21:00 MP4Recorder\MP4Recorder\MP4Recorder.vcxproj.user
目录 0 2018-08-22 22:44 MP4Recorder\MP4Recorder\include\
目录 0 2018-08-22 22:44 MP4Recorder\MP4Recorder\lib\
文件 253 2018-08-22 21:05 MP4Recorder\MP4Recorder\test.cpp
文件 35454976 2018-08-22 22:42 MP4Recorder\MP4Recorder.sdf
文件 900 2018-08-17 20:35 MP4Recorder\MP4Recorder.sln
文件 45056 2018-08-22 22:42 MP4Recorder\MP4Recorder.v11.suo
- 上一篇:code.tar.gz
- 下一篇:ModbusTools_破解版
相关资源
- ISOMETR图标生成器教程(mp4视频教程)
- MP4编解C源代码
- 监控专用MP4文件播放器
- onvif协议视频转码推流网页播放
- 流媒体相关协议标准RTP/RTSP/RTCP PDF文档
- mp4转TS工具
- 格式工厂所缺失的mp4creator.exe
- qt_ffmpeg_mp4_export_and_import.zip
- 基于ffmpeg将avi视频转换为mp4视频
- (补充)修改output-example,将H.264AAC帧
- ffmpeg转换MP4为JPG帧图片
- ffmpeg提取mp4关键帧保存为jpg.zip
- mp4_play.zip
-
KindEditor与jwpla
yer集成,优化kindEdi - mp4测试视频,可以用它测试处理MP4文
- ffmpeg封装H264成MP4、AVI视频格式,及提
- H264实时编码RTSP直播
- 嵌入式音频视频混合为mp4(mp4v2+faac
- 理光MP4001、5001复印机维修手册
- 将rtsp转码为flv格式用于h5播放前端使
- 10s测试短片MP4
- rtsp-h264.zip
- 使用gpac封装MP4源码(新)
- QLV直转MP4工具
- websocket-rtsp-proxy-test.zip
- rtsp摄像头推流上云使用浏览器播放
-
ijkpla
yer 最新rtsp .ts so库 - qsv转MP4.zip
- MP4超快超清晰压制工具绿色注册版
- rtsp大全
评论
共有 条评论