使用libmp4v2解封装MP4文件

2024-08-21 16:04
文章标签 使用 封装 mp4 libmp4v2

本文主要是介绍使用libmp4v2解封装MP4文件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

最近研究了一下使用libmp4v2库解封装MP4文件,将MP4文件解封装成H264视频文件和AAC音频文件

libmp4v2源码下载:https://github.com/TechSmith/mp4v2

示例代码:

/*
使用libmp4v2库解封装出视频帧和音频帧编译:gcc -g mp4_unpack.c  -o mp4_unpack -I./include -L./lib -lmp4v2参考文献:
https://blog.csdn.net/jay100500/article/details/52955232
https://blog.csdn.net/andyhuabing/article/details/40983423
https://www.cnblogs.com/0error1warning/p/13755920.html
https://blog.nowcoder.net/n/e8f9c78aa2e0453aa2800cce162435c5
https://blog.csdn.net/liukun321/article/details/25337425
https://www.cnblogs.com/zhangxuan/p/8809245.html*/
#include <stdio.h>
#include <mp4v2/mp4v2.h>
#include <stdlib.h>
#include <string.h>#define FRAME_WRITE_FILE  (1)
#define USE_PROVIDER      (0)
#define ADTS_HEADER_SIZE7  (7)
#define ADTS_HEADER_SIZE9  (9)#if defined(USE_PROVIDER) && (USE_PROVIDER != 0)
static void* my_open( const char* name, MP4FileMode mode)
{FILE *fp = NULL;const char* om;if (name == NULL || name[0] == '\0'){printf("[%s:%d] name is NULL\n", __FUNCTION__, __LINE__);return NULL; }switch(mode) {case FILEMODE_READ:     om = "rb";  break;case FILEMODE_MODIFY:   om = "r+b"; break;case FILEMODE_CREATE:   om = "w+b"; break;case FILEMODE_UNDEFINED:default:om = "rb";break;}fp = fopen(name, om);if (fp == NULL){printf("[%s:%d] file(%s) open failed!\n", __FUNCTION__, __LINE__, name);}return fp;
}static int my_seek(void* handle, int64_t pos)
{if (!handle){printf("[%s:%d] handle is NULL\n", __FUNCTION__, __LINE__);return 0;}int ret = fseeko((FILE*)handle, pos, SEEK_SET); // fseeko用于处理大文件return (ret != 0);
}static int my_read(void* handle, void* buffer, int64_t size, int64_t* nin, int64_t maxChunkSize)
{if (!handle){printf("[%s:%d] handle is NULL\n", __FUNCTION__, __LINE__);return 1;}if (!buffer || size <= 0){printf("[%s:%d] param is invalid\n", __FUNCTION__, __LINE__);return 1;}if (fread(buffer, size, 1, (FILE*)handle) != 1){return 1;}if (nin != NULL)*nin = size;return 0;
}static int my_write(void* handle, const void* buffer, int64_t size, int64_t* nout, int64_t maxChunkSize)
{if (!handle){printf("[%s:%d] handle is NULL\n", __FUNCTION__, __LINE__);return 1;}if (!buffer || size <= 0){printf("[%s:%d] param is invalid\n", __FUNCTION__, __LINE__);return 1;}if (fwrite( buffer, size, 1, (FILE*)handle ) != 1)return 1;if (nout != NULL)*nout = size;return 0;
}static int my_close (void* handle)
{if (!handle){printf("[%s:%d] handle is NULL\n", __FUNCTION__, __LINE__);return 0;}int ret = fclose((FILE*)handle); return (ret != 0);
}
#endif/*
获取h264视频流*/
static int get_h264_stream(const char *out_file, 
MP4FileHandle file_handle, 
MP4TrackId video_track_id, 
MP4SampleId total_frame,
uint8_t *sps, 
uint32_t spslen,
uint8_t *pps,
uint32_t ppslen)
{if (!file_handle){printf("[%s:%d] param file_handle error\n", __FUNCTION__, __LINE__);return -1;}#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0)if (out_file == NULL || out_file[0] == '\0'){printf("[%s:%d] param out_file is empty\n", __FUNCTION__, __LINE__);return -1;}FILE *fp = fopen(out_file, "wb");if (fp == NULL){printf("[%s:%d] fopen:%s failed\n", __FUNCTION__, __LINE__, out_file);return -1;}
#endifuint8_t nal_header[] = {0x00, 0x00, 0x00, 0x01};    uint8_t* data = NULL;uint32_t size = 0;MP4Timestamp start_time;MP4Duration duration;MP4Duration render_offset;bool is_sync_sample = 0; // 是否是关键帧MP4SampleId sample_id = 0;uint8_t* frame_data = NULL;uint16_t vid_width = MP4GetTrackVideoWidth(file_handle, video_track_id);uint16_t vid_height = MP4GetTrackVideoHeight(file_handle, video_track_id);double vid_fps = MP4GetTrackVideoFrameRate(file_handle, video_track_id);printf("[%s:%d] vid_width:%d, vid_height:%d, vid_fps:%f\n", __FUNCTION__, __LINE__, vid_width, vid_height, vid_fps);while(sample_id < total_frame){   sample_id++; // sample id can't be zeroif (!MP4ReadSample(file_handle, video_track_id, sample_id, &data, &size, &start_time, &duration, &render_offset, &is_sync_sample)){printf("[%s:%d] MP4ReadSample failed\n", __FUNCTION__, __LINE__);if (data != NULL){free(data);data = NULL;}continue;}frame_data = (uint8_t *)malloc(spslen + ppslen + size);if (!frame_data){printf("[%s:%d] out of memory\n", __FUNCTION__, __LINE__);if (data != NULL){free(data);data = NULL;}continue;}uint8_t *pos = frame_data;//IDR֡帧,写入sps和ppsif (is_sync_sample){//printf("[%s:%d] sample_id:%lu, total_frame:%lu\n", __FUNCTION__, __LINE__, sample_id, total_frame);memcpy(pos, sps, spslen); pos += spslen;memcpy(pos, pps, ppslen);pos += ppslen;}//h264frame 标准的h264帧,前面几个字节就是frame的长度,需要替换为标准的h264 nal头if (data != NULL && size > 4){data[0] = 0x00;data[1] = 0x00;data[2] = 0x00;data[3] = 0x01;memcpy(pos, data, size);pos += size;}/*如果传入MP4ReadSample的视频pData是null它内部就会new 一个内存如果传入的是已知的内存区域,则需要保证空间bigger than max frames size.*/if (data != NULL){free(data);data = NULL;}/*收集sps pps 和 sample Data,拼接成一帧h264数据*/if (pos != frame_data){
#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0) fwrite(frame_data, (pos - frame_data), 1, fp);
#endif// TODO:这里送入解码器解码}if (frame_data != NULL){free(frame_data);frame_data = NULL;}if (sample_id == total_frame)printf("[%s:%d] video sample finished, sample_id:%lu, total_frame:%lu\n", __FUNCTION__, __LINE__, sample_id, total_frame);}       #if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0) fflush(fp);fclose(fp);  
#endifreturn 0;
}/*
填充atds头参考
https://www.cnblogs.com/lidabo/p/7261558.html
https://blog.nowcoder.net/n/e8f9c78aa2e0453aa2800cce162435c5Structure{AAAAAAAA AAAABCCD EEFFFFGH HHIJKLMM MMMMMMMM MMMOOOOO OOOOOOPP (QQQQQQQQ QQQQQQQQ)Header consists of 7 or 9 bytes (without or with CRC).
}
Letter Length (bits) Description
A     12      syncword 0xFFF, all bits must be 1
B     1       MPEG Version: 0 for MPEG-4, 1 for MPEG-2
C     2       Layer: always 0
D     1       protection absent, Warning, set to 1 if there is no CRC and 0 if there is CRC
E     2       profile, the MPEG-4 Audio Object Type minus 1
F     4       MPEG-4 Sampling Frequency Index (15 is forbidden)
G     1       private stream, set to 0 when encoding, ignore when decoding
H     3       MPEG-4 Channel Configuration (in the case of 0, the channel configuration is sent via an inband PCE)
I     1       originality, set to 0 when encoding, ignore when decoding
J     1       home, set to 0 when encoding, ignore when decoding
K     1       copyrighted stream, set to 0 when encoding, ignore when decoding
L     1       copyright start, set to 0 when encoding, ignore when decoding
M     13      frame length, this value must include 7 or 9 bytes of header length: FrameLength =(D == 1 ? 7 : 9) + size(AACFrame)
O     11      Buffer fullness
P     2       Number of AAC frames (RDBs) in ADTS frame minus 1, for maximum compatibility always use 1 AAC frame per ADTS frame
Q     16      CRC if protection absent is 0Usage in MPEG-TS
ADTS packet must be a content of PES packet. Pack AAC data inside ADTS frame, than pack inside PES packet, then mux by TS packetizer.Usage in Shoutcast
ADTS frames goes one by one in TCP stream. Look for syncword, parse header and look for next syncword after.
*/
int fill_adts_header(
uint8_t* header, 
int head_size, 
int packet_len, 
int audio_rate_index, 
int audio_channel_count, 
uint8_t audio_type)
{int ret = -1;if (header == NULL){printf("[%s:%d] header is NULL\n", __FUNCTION__, __LINE__);return -1;} if (head_size != ADTS_HEADER_SIZE7 && head_size != (ADTS_HEADER_SIZE9)){printf("[%s:%d] param error, head_size:%d\n", __FUNCTION__, __LINE__, head_size);return -1;} int toal_len = head_size + packet_len; // ADTS帧长度包括 ADTS头大小 + AAC帧长//printf("[%s:%d] head_size:%d, packet_len:%d\n", __FUNCTION__, __LINE__, head_size, packet_len);if (ADTS_HEADER_SIZE7 == head_size) // fill in ADTS data{header[0] = (uint8_t)0xFF;header[1] = (uint8_t)0xF1;header[2] = (uint8_t)(((audio_type - 1) << 6) + (audio_rate_index << 2) + (audio_channel_count >> 2));header[3] = (uint8_t)(((audio_channel_count & 0x03) << 6) + (toal_len >> 11));header[4] = (uint8_t)((toal_len & 0x07FF) >> 3);header[5] = (uint8_t)(((toal_len & 0x07) << 5) + 0x1F);header[6] = (uint8_t)0xFC;ret = 0;}return ret;
}/*
获取acc数据
total_frame 音频总帧数
audio_rate_index 音频采样率索引
audio_channel_count 音频声道数
audio_type 音频类型,例如MPEG-4 AAC LC的值为0x02*/
static int get_aac_stream(
const char *out_file, 
MP4FileHandle file_handle, 
MP4TrackId audio_track_id, 
MP4SampleId total_frame,
int audio_rate_index,
int audio_channel_count,
uint8_t audio_type)
{if (!file_handle){printf("[%s:%d] param file_handle error\n", __FUNCTION__, __LINE__);return -1;}#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0)if (out_file == NULL || out_file[0] == '\0'){printf("[%s:%d] param out_file is empty\n", __FUNCTION__, __LINE__);return -1;}FILE *fp = fopen(out_file, "wb");if (fp == NULL){printf("[%s:%d] open file failed\n", __FUNCTION__, __LINE__);return -1;}
#endifMP4SampleId frame_index = 0; // uint8_t* data = NULL;uint32_t size = 0;MP4Timestamp start_time;MP4Duration duration;MP4Duration render_offset;bool is_sync_sample = 0; // 是否是关键帧while (frame_index < total_frame) // 获取acc数据帧{frame_index++; //MP4ReadSample函数的参数要求是从1开始/*如果传入MP4ReadSample的音频data是null,它内部就会new 一个内存如果传入的是已知的内存区域,则需要保证空间bigger then max frames size.*/if (!MP4ReadSample(file_handle, audio_track_id, frame_index, &data, &size, &start_time, &duration, &render_offset, &is_sync_sample)){printf("[%s:%d] MP4ReadSample failed\n", __FUNCTION__, __LINE__);if (data != NULL){free(data);data = NULL;}continue;}#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0)uint8_t header[ADTS_HEADER_SIZE7] = { 0 };// 编码AAC裸流的时候,会遇到写出来的AAC文件并不能在PC和手机上播放,很大的可能就是AAC文件的每一帧里缺少了ADTS头信息文件的包装拼接fill_adts_header(header, ADTS_HEADER_SIZE7, size, audio_rate_index, audio_channel_count, audio_type);fwrite(header, ADTS_HEADER_SIZE7, 1, fp); // 先写入adts头fwrite(data, size, 1, fp); // 再写入acc数据#endif// TODO:收集一帧acc数据,送入解码器if (data){free(data);data = NULL;}if (frame_index == total_frame)printf("[%s:%d] audio sample finished, frame_index:%lu, total_frame:%lu\n", __FUNCTION__, __LINE__, frame_index, total_frame);}#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0)	if (fp != NULL){fflush(fp);fclose(fp);}
#endifreturn 0;
} /*
解封装MP4文件成视频和音频*/
static int unpack_mp4_file(const char* mp4_file, const char *video_file, const char *audio_file)
{if (mp4_file == NULL || mp4_file[0] == '\0'){printf("[%s:%d] param mp4_file is empty\n", __FUNCTION__, __LINE__);   return -1;}#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0) if (video_file == NULL || video_file[0] == '\0'){printf("[%s:%d] param video_file is empty\n", __FUNCTION__, __LINE__);   return -1;}if (audio_file == NULL || audio_file[0] == '\0'){printf("[%s:%d] param audio_file is empty\n", __FUNCTION__, __LINE__);   return -1;}
#endifMP4FileHandle file_handle = MP4_INVALID_FILE_HANDLE;
#if defined(USE_PROVIDER) && (USE_PROVIDER != 0)MP4FileProvider provider;provider.open  = my_open;provider.seek  = my_seek;provider.read  = my_read;provider.write = my_write;provider.close = my_close;file_handle = MP4ReadProvider(mp4_file, &provider);
#elsefile_handle = MP4Read(mp4_file);
#endifif (file_handle == MP4_INVALID_FILE_HANDLE) {printf("[%s:%d] MP4Read failed\n", __FUNCTION__, __LINE__);return -1;}if (!MP4Dump(file_handle, 0)){printf("[%s:%d] MP4Dump failed\n", __FUNCTION__, __LINE__);}uint32_t track_count = MP4GetNumberOfTracks(file_handle, NULL, 0); // 获取所有的轨道数printf("[%s:%d] track_count = %u\n", __FUNCTION__, __LINE__, track_count);uint32_t file_time_scale = MP4GetTimeScale(file_handle); // 获取文件每秒刻度数printf("[%s:%d] file_time_scale = %u\n", __FUNCTION__, __LINE__, file_time_scale);MP4Duration file_duration = MP4GetDuration(file_handle); // 获取文件总刻度数printf("[%s:%d] file_duration = %llu\n", __FUNCTION__, __LINE__, file_duration);uint32_t msec = file_duration * 1000 / file_time_scale;// 总毫秒数 = 总刻度数*1000/每秒刻度数 => 先乘法可以降低误差printf("[%s:%d] msec = %u\n\n", __FUNCTION__, __LINE__, msec);MP4TrackId track_id = MP4_INVALID_TRACK_ID;MP4TrackId track_id_vid = MP4_INVALID_TRACK_ID;MP4TrackId tarck_id_aud = MP4_INVALID_TRACK_ID;uint32_t track_index = 0;MP4SampleId vid_samples_count = 0;MP4SampleId aud_samples_count = 0;uint32_t spslen = 0, ppslen = 0;uint8_t *sps = NULL;uint8_t *pps = NULL;int audio_rate_index = -1; // 音频采样率索引int audio_channel_count = 0; // 音频声道数uint8_t audio_type = 0x00; // 音频类型,例如MPEG-4 AAC LC的值为0x02for (track_index = 0; track_index < track_count; track_index++){track_id = MP4FindTrackId(file_handle, track_index, NULL, 0);printf("[%s:%d] track_index:%u, track_id:%u\n", __FUNCTION__, __LINE__, track_index, track_id);const char* type = MP4GetTrackType(file_handle, track_id);printf("[%s:%d] type:%s\n", __FUNCTION__, __LINE__, type);if (MP4_IS_VIDEO_TRACK_TYPE(type)) // 视频类型{const char* track_name = MP4GetTrackMediaDataName(file_handle, track_id);printf("[%s:%d] track_name:%s\n", __FUNCTION__, __LINE__, track_name);uint32_t time_scale = MP4GetTrackTimeScale(file_handle, track_id);printf("[%s:%d] time_scale:%u\n", __FUNCTION__, __LINE__, time_scale);//MP4Duration duration = MP4GetTrackDuration(file_handle, track_id);//printf("[%s:%d] duration:%llu\n", __FUNCTION__, __LINE__, duration);vid_samples_count = MP4GetTrackNumberOfSamples(file_handle, track_id);printf("[%s:%d] vid_samples_count:%u\n", __FUNCTION__, __LINE__, vid_samples_count);uint32_t bit_rate = MP4GetTrackBitRate(file_handle, track_id); // 比特率printf("[%s:%d] bit_rate:%u\n", __FUNCTION__, __LINE__, bit_rate);double video_frame_rate = MP4GetTrackVideoFrameRate(file_handle, track_id);printf("[%s:%d] video_frame_rate(fps):%f\n", __FUNCTION__, __LINE__, video_frame_rate);uint16_t vid_width = MP4GetTrackVideoWidth(file_handle, track_id);uint16_t vid_height = MP4GetTrackVideoHeight(file_handle, track_id);printf("[%s:%d] vid_width:%d, vid_height:%d\n", __FUNCTION__, __LINE__, vid_width, vid_height);uint32_t max_video = MP4GetTrackMaxSampleSize(file_handle, track_id);printf("[%s:%d] max_video:%u\n", __FUNCTION__, __LINE__, max_video);char* info = MP4Info(file_handle, track_id);if (info != NULL){printf("[%s:%d] info: %s\n", __FUNCTION__, __LINE__, info);free(info);}track_id_vid = track_id;uint8_t **seq_header;uint8_t **pict_header;uint32_t *pict_header_size;uint32_t *seq_header_size;uint32_t index = 0;uint32_t size = 0;uint8_t nal_header[] = {0x00, 0x00, 0x00, 0x01}; /*获取sps和pps*/if (!MP4GetTrackH264SeqPictHeaders(file_handle, track_id, &seq_header, &seq_header_size, &pict_header, &pict_header_size)){printf("[%s:%d] MP4GetTrackH264SeqPictHeaders failed\n", __FUNCTION__, __LINE__);continue;}// 统计sps的长度size = 4; // 加上4个字节的nal头for (index = 0; seq_header_size[index] != 0; index++){size += seq_header_size[index];printf("[%s:%d] size = %d, seq_header_size[%d] = %d\n", __FUNCTION__, __LINE__, size, index, seq_header_size[index]);}printf("[%s:%d] sps with nal size:%u\n", __FUNCTION__, __LINE__, size);sps = (uint8_t *)malloc(size);if (sps == NULL){MP4Free(seq_header);MP4Free(seq_header_size);MP4Free(pict_header);MP4Free(pict_header_size);goto end;}uint8_t *sps_base = sps;memcpy(sps_base, nal_header, 4);sps_base += 4;for (index = 0; seq_header_size[index] != 0; index++){memcpy(sps_base, seq_header[index], seq_header_size[index]);sps_base += seq_header_size[index];MP4Free(seq_header[index]);}MP4Free(seq_header);MP4Free(seq_header_size);spslen = size;// 统计pps的长度size = 4; //加上4个字节的nal头for (index = 0; pict_header_size[index] != 0; index++){size += pict_header_size[index];printf("[%s:%d] size = %u, pict_header_size[%d] = %u\n", __FUNCTION__, __LINE__, size, index, pict_header_size[index]);}printf("[%s:%d] pps with nal size:%lu\n", __FUNCTION__, __LINE__, size);pps = (uint8_t *)malloc(size);if (pps == NULL){MP4Free(seq_header);MP4Free(seq_header_size);MP4Free(pict_header);MP4Free(pict_header_size);goto end;}uint8_t *pps_base = pps;memcpy(pps_base, nal_header, 4);pps_base += 4;for (index = 0; pict_header_size[index] != 0; index++){memcpy(pps_base, pict_header[index], pict_header_size[index]);pps_base += pict_header_size[index];MP4Free(pict_header[index]);}MP4Free(pict_header);MP4Free(pict_header_size);ppslen = size;printf("[%s:%d] spslen(with nal):%u, ppslen(with nal):%u\n\n", __FUNCTION__, __LINE__, spslen, ppslen);}else if (MP4_IS_AUDIO_TRACK_TYPE(type)) // 音频类型{const char* track_name = MP4GetTrackMediaDataName(file_handle, track_id);printf("[%s:%d] track_name:%s\n", __FUNCTION__, __LINE__, track_name);uint32_t time_scale = MP4GetTrackTimeScale(file_handle, track_id); // 采样率printf("[%s:%d] time_scale:%u\n", __FUNCTION__, __LINE__, time_scale);//MP4Duration duration = MP4GetTrackDuration(file_handle, track_id);//printf("[%s:%d] duration:%llu\n", __FUNCTION__, __LINE__, duration);uint32_t bit_rate = MP4GetTrackBitRate(file_handle, track_id); // 比特率printf("[%s:%d] bit_rate:%u\n", __FUNCTION__, __LINE__, bit_rate);aud_samples_count = MP4GetTrackNumberOfSamples(file_handle, track_id); // 音频总帧数printf("[%s:%d] aud_samples_count:%u\n", __FUNCTION__, __LINE__, aud_samples_count);audio_channel_count = MP4GetTrackAudioChannels(file_handle, track_id); // 声道数printf("[%s:%d] channel_count:%d\n", __FUNCTION__, __LINE__, audio_channel_count);audio_type = MP4GetTrackAudioMpeg4Type(file_handle, track_id); // 音频类型printf("[%s:%d] audio_type:0x%02X\n", __FUNCTION__, __LINE__, audio_type);uint8_t audio_profile_level = MP4GetAudioProfileLevel(file_handle);printf("[%s:%d] audio_profile_level:0x%02X\n", __FUNCTION__, __LINE__, audio_profile_level);uint32_t max_audio = MP4GetTrackMaxSampleSize(file_handle, track_id);printf("[%s:%d] max_audio:%u\n", __FUNCTION__, __LINE__, max_audio);char* info = MP4Info(file_handle, track_id);if (info != NULL){printf("[%s:%d] info: %s\n", __FUNCTION__, __LINE__, info);free(info);}// 采样率与下标的关系, 参考 ffmpeg mpeg4audio.c int avpriv_mpeg4audio_sample_rates[16]uint32_t audio_sample_rates[] = {96000, 88200, 64000, 48000, 44100, 32000,24000, 22050, 16000, 12000, 11025, 8000, 7350};int i = 0;for (i = 0; i < sizeof(audio_sample_rates)/sizeof(int); i++){if (time_scale == audio_sample_rates[i]){audio_rate_index = i; // 例如: audio_time_scale == 48000 hz, audio_rate_index = 3break;}}if (audio_rate_index == -1){printf("[%s:%d] audio sample rate %d is not supported, audio_rate_index = %d\n", __FUNCTION__, __LINE__, time_scale, audio_rate_index);goto end;}tarck_id_aud = track_id;}else{printf("[%s:%d] unknow track type:%s\n", __FUNCTION__, __LINE__, type);}}// 解析视频帧if (track_id_vid > 0){get_h264_stream(video_file, file_handle, track_id_vid, vid_samples_count, sps, spslen, pps, ppslen);}// 解析音频帧if (tarck_id_aud > 0){get_aac_stream(audio_file, file_handle, tarck_id_aud, aud_samples_count, audio_rate_index, audio_channel_count, audio_type);}end:if (sps){free(sps);sps = NULL;}if (pps){free(pps);pps = NULL;}if (file_handle){MP4Close(file_handle, 0);file_handle = MP4_INVALID_FILE_HANDLE;}return 0;
}int main(int argc, char*argv[])
{char * video_file = NULL;char * audio_file = NULL;#if defined(FRAME_WRITE_FILE) && (FRAME_WRITE_FILE != 0) if (argc != 4) {printf("[%s:%d] usage: %s file.mp4 out_video.h264 out_audio.acc\n", __FUNCTION__, __LINE__, argv[0]);return -1;} 
#endifchar * file_name = argv[1];video_file = argv[2];audio_file = argv[3];unpack_mp4_file(file_name, video_file, audio_file);return 0;
}

这篇关于使用libmp4v2解封装MP4文件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1093630

相关文章

springboot security快速使用示例详解

《springbootsecurity快速使用示例详解》:本文主要介绍springbootsecurity快速使用示例,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝... 目录创www.chinasem.cn建spring boot项目生成脚手架配置依赖接口示例代码项目结构启用s

Python如何使用__slots__实现节省内存和性能优化

《Python如何使用__slots__实现节省内存和性能优化》你有想过,一个小小的__slots__能让你的Python类内存消耗直接减半吗,没错,今天咱们要聊的就是这个让人眼前一亮的技巧,感兴趣的... 目录背景:内存吃得满满的类__slots__:你的内存管理小助手举个大概的例子:看看效果如何?1.

java中使用POI生成Excel并导出过程

《java中使用POI生成Excel并导出过程》:本文主要介绍java中使用POI生成Excel并导出过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录需求说明及实现方式需求完成通用代码版本1版本2结果展示type参数为atype参数为b总结注:本文章中代码均为

SpringBoot中封装Cors自动配置方式

《SpringBoot中封装Cors自动配置方式》:本文主要介绍SpringBoot中封装Cors自动配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录SpringBoot封装Cors自动配置背景实现步骤1. 创建 GlobalCorsProperties

Spring Boot3虚拟线程的使用步骤详解

《SpringBoot3虚拟线程的使用步骤详解》虚拟线程是Java19中引入的一个新特性,旨在通过简化线程管理来提升应用程序的并发性能,:本文主要介绍SpringBoot3虚拟线程的使用步骤,... 目录问题根源分析解决方案验证验证实验实验1:未启用keep-alive实验2:启用keep-alive扩展建

使用Java实现通用树形结构构建工具类

《使用Java实现通用树形结构构建工具类》这篇文章主要为大家详细介绍了如何使用Java实现通用树形结构构建工具类,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录完整代码一、设计思想与核心功能二、核心实现原理1. 数据结构准备阶段2. 循环依赖检测算法3. 树形结构构建4. 搜索子

GORM中Model和Table的区别及使用

《GORM中Model和Table的区别及使用》Model和Table是两种与数据库表交互的核心方法,但它们的用途和行为存在著差异,本文主要介绍了GORM中Model和Table的区别及使用,具有一... 目录1. Model 的作用与特点1.1 核心用途1.2 行为特点1.3 示例China编程代码2. Tab

SpringBoot使用OkHttp完成高效网络请求详解

《SpringBoot使用OkHttp完成高效网络请求详解》OkHttp是一个高效的HTTP客户端,支持同步和异步请求,且具备自动处理cookie、缓存和连接池等高级功能,下面我们来看看SpringB... 目录一、OkHttp 简介二、在 Spring Boot 中集成 OkHttp三、封装 OkHttp

使用Python实现获取网页指定内容

《使用Python实现获取网页指定内容》在当今互联网时代,网页数据抓取是一项非常重要的技能,本文将带你从零开始学习如何使用Python获取网页中的指定内容,希望对大家有所帮助... 目录引言1. 网页抓取的基本概念2. python中的网页抓取库3. 安装必要的库4. 发送HTTP请求并获取网页内容5. 解

使用Python实现网络设备配置备份与恢复

《使用Python实现网络设备配置备份与恢复》网络设备配置备份与恢复在网络安全管理中起着至关重要的作用,本文为大家介绍了如何通过Python实现网络设备配置备份与恢复,需要的可以参考下... 目录一、网络设备配置备份与恢复的概念与重要性二、网络设备配置备份与恢复的分类三、python网络设备配置备份与恢复实