⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedump.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 4 页
字号:
			sprintf(szBuf, "%s_%d_text.%s", inName, trackID, (dump_type==2) ? "svg" : ((dump_type==1) ? "srt" : "ttxt") );		dump = fopen(szBuf, "wt");	} else {		dump = stdout;	}	e = gf_isom_text_dump(file, track, dump, dump_type);	if (inName) fclose(dump);	if (e) fprintf(stdout, "Conversion failed (%s)\n", gf_error_to_string(e));	else fprintf(stdout, "Conversion done\n");}void DumpSDP(GF_ISOFile *file, char *inName){	const char *sdp;	u32 size, i;	FILE *dump;	char szBuf[1024];	if (inName) {		char *ext;		strcpy(szBuf, inName);		ext = strchr(szBuf, '.');		if (ext) ext[0] = 0;		strcat(szBuf, "_sdp.txt");		dump = fopen(szBuf, "wt");	} else {		dump = stdout;		fprintf(dump, "* File SDP content *\n\n");	}	//get the movie SDP	gf_isom_sdp_get(file, &sdp, &size);	fprintf(dump, "%s", sdp);	fprintf(dump, "\r\n");	//then tracks	for (i=0; i<gf_isom_get_track_count(file); i++) {		if (gf_isom_get_media_type(file, i+1) != GF_ISOM_MEDIA_HINT) continue;		gf_isom_sdp_track_get(file, i+1, &sdp, &size);		fprintf(dump, "%s", sdp);	}	fprintf(dump, "\n\n");	if (inName) fclose(dump);}static char *format_duration(u64 dur, u32 timescale, char *szDur){	u32 h, m, s, ms;	dur = (u64) (( ((Double) (s64) dur)/timescale)*1000);	h = (u32) (dur / 3600000);	m = (u32) (dur/ 60000) - h*60;	s = (u32) (dur/1000) - h*3600 - m*60;	ms = (u32) (dur) - h*3600000 - m*60000 - s*1000;	if (h<=24) {		sprintf(szDur, "%02d:%02d:%02d.%03d", h, m, s, ms);	} else {		u32 d = (u32) (dur / 3600000 / 24);		h = (u32) (dur/3600000)-24*d;		if (d<=365) {			sprintf(szDur, "%d Days, %02d:%02d:%02d.%03d", d, h, m, s, ms);		} else {			u32 y=0;			while (d>365) {				y++;				d-=365;				if (y%4) d--;			}			sprintf(szDur, "%d Years %d Days, %02d:%02d:%02d.%03d", y, d, h, m, s, ms);		}	}	return szDur;}static char *format_date(u64 time, char *szTime){	time_t now;	if (!time) {		strcpy(szTime, "UNKNOWN DATE");	} else {		time -= 2082758400;		now = (u32) time;		sprintf(szTime, "GMT %s", asctime(gmtime(&now)) );	}	return szTime;}static void DumpMetaItem(GF_ISOFile *file, Bool root_meta, u32 tk_num, char *name){	u32 i, count, brand, primary_id;	brand = gf_isom_get_meta_type(file, root_meta, tk_num);	if (!brand) return;	count = gf_isom_get_meta_item_count(file, root_meta, tk_num);	primary_id = gf_isom_get_meta_primary_item_id(file, root_meta, tk_num);	fprintf(stdout, "%s type: \"%s\" - %d resource item(s)\n", name, gf_4cc_to_str(brand), (count+(primary_id>0)));	switch (gf_isom_has_meta_xml(file, root_meta, tk_num)) {	case 1: fprintf(stdout, "Meta has XML resource\n"); break;	case 2: fprintf(stdout, "Meta has BinaryXML resource\n"); break;	}	if (primary_id) {		fprintf(stdout, "Primary Item - ID %d\n", primary_id); 	} 	for (i=0; i<count; i++) {		const char *it_name, *mime, *enc, *url, *urn;		Bool self_ref;		u32 ID;		gf_isom_get_meta_item_info(file, root_meta, tk_num, i+1, &ID, NULL, &self_ref, &it_name, &mime, &enc, &url, &urn);		fprintf(stdout, "Item #%d - ID %d", i+1, ID);		if (self_ref) fprintf(stdout, " - Self-Reference");		else if (it_name) fprintf(stdout, " - Name: %s", it_name);		if (mime) fprintf(stdout, " - MimeType: %s", mime);		if (enc) fprintf(stdout, " - ContentEncoding: %s", enc);		fprintf(stdout, "\n");		if (url) fprintf(stdout, "URL: %s\n", url);		if (urn) fprintf(stdout, "URN: %s\n", urn);	}}void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump){	Float scale;	u32 trackNum, j, size, max_rate, rate, ts, mtype, msub_type, timescale, sr, nb_ch, count;	u64 time_slice, dur;	u8 bps;	GF_ESD *esd;	char sType[5], szDur[50];	trackNum = gf_isom_get_track_by_id(file, trackID);	if (!trackNum) {		fprintf(stdout, "No track with ID %d found\n", trackID);		return;	}	timescale = gf_isom_get_media_timescale(file, trackNum);	fprintf(stdout, "Track # %d Info - TrackID %d - TimeScale %d - Duration %s\n", trackNum, trackID, timescale, format_duration(gf_isom_get_media_duration(file, trackNum), timescale, szDur));	if (gf_isom_is_track_in_root_od(file, trackNum) ) fprintf(stdout, "Track is present in Root OD\n");	gf_isom_get_media_language(file, trackNum, sType);	fprintf(stdout, "Media Info: Language \"%s\" - ", GetLanguage(sType) );	mtype = gf_isom_get_media_type(file, trackNum);	fprintf(stdout, "Type \"%s:", gf_4cc_to_str(mtype));	msub_type = gf_isom_get_mpeg4_subtype(file, trackNum, 1);	if (!msub_type) msub_type = gf_isom_get_media_subtype(file, trackNum, 1);	fprintf(stdout, "%s\" - %d samples\n", gf_4cc_to_str(msub_type), gf_isom_get_sample_count(file, trackNum));		if (!gf_isom_is_self_contained(file, trackNum, 1)) {		const char *url, *urn;		gf_isom_get_data_reference(file, trackNum, 1, &url, &urn);		fprintf(stdout, "Media Data Location: %s\n", url ? url : urn);	}	if (full_dump) {		const char *handler_name;		gf_isom_get_handler_name(file, trackNum, &handler_name);		fprintf(stdout, "Handler name: %s\n", handler_name);	}	gf_isom_get_audio_info(file, trackNum, 1, &sr, &nb_ch, &bps);		msub_type = gf_isom_get_media_subtype(file, trackNum, 1);	if ((msub_type==GF_ISOM_SUBTYPE_MPEG4) || (msub_type==GF_ISOM_SUBTYPE_MPEG4_CRYP) || (msub_type==GF_ISOM_SUBTYPE_AVC_H264))  {		esd = gf_isom_get_esd(file, trackNum, 1);		if (!esd) {			fprintf(stdout, "WARNING: Broken MPEG-4 Track\n");		} else {			const char *st = gf_odf_stream_type_name(esd->decoderConfig->streamType);			if (st) {				fprintf(stdout, "MPEG-4 Config%s%s Stream - ObjectTypeIndication 0x%02x\n",							full_dump ? "\n\t" : ": ", st, esd->decoderConfig->objectTypeIndication);			} else {				fprintf(stdout, "MPEG-4 Config%sStream Type 0x%02x - ObjectTypeIndication 0x%02x\n",							full_dump ? "\n\t" : ": ", esd->decoderConfig->streamType, esd->decoderConfig->objectTypeIndication);			}			if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) {				u32 w, h;				w = h = 0;				if (esd->decoderConfig->objectTypeIndication==0x20) {					GF_M4VDecSpecInfo dsi;					gf_m4v_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi);					if (full_dump) fprintf(stdout, "\t");					w = dsi.width;					h = dsi.height;					if (w && h) {						fprintf(stdout, "MPEG-4 Visual Size %d x %d - %s\n", dsi.width, dsi.height, gf_m4v_get_profile_name(dsi.VideoPL));						if (dsi.par_den && dsi.par_num) {							u32 tw, th;							gf_isom_get_track_layout_info(file, trackNum, &tw, &th, NULL, NULL, NULL);							fprintf(stdout, "Pixel Aspect Ratio %d:%d - Indicated track size %d x %d\n", dsi.par_num, dsi.par_den, tw, th);						}					}				} else if (esd->decoderConfig->objectTypeIndication==0x21) {					GF_AVCConfig *avccfg;					GF_AVCConfigSlot *slc;					s32 par_n, par_d;					gf_isom_get_visual_info(file, trackNum, 1, &w, &h);					if (full_dump) fprintf(stdout, "\t");					fprintf(stdout, "AVC/H264 Video - Visual Size %d x %d - ", w, h);					avccfg = gf_isom_avc_config_get(file, trackNum, 1);					if (!avccfg) {						fprintf(stdout, "\n\n\tNon-compliant AVC track: SPS/PPS not found in sample description\n");					} else {						fprintf(stdout, "Profile %s @ Level %g\n", gf_avc_get_profile_name(avccfg->AVCProfileIndication), ((Double)avccfg->AVCLevelIndication)/10.0 );						fprintf(stdout, "NAL Unit length bits: %d\n", 8*avccfg->nal_unit_size);#ifndef GPAC_READ_ONLY						slc = gf_list_get(avccfg->sequenceParameterSets, 0);						gf_avc_get_sps_info(slc->data, slc->size, NULL, NULL, &par_n, &par_d);						if ((par_n>0) && (par_d>0)) {							u32 tw, th;							gf_isom_get_track_layout_info(file, trackNum, &tw, &th, NULL, NULL, NULL);							fprintf(stdout, "Pixel Aspect Ratio %d:%d - Indicated track size %d x %d\n", par_n, par_d, tw, th);						}#endif						gf_odf_avc_cfg_del(avccfg);					}				} 				/*OGG media*/				else if (esd->decoderConfig->objectTypeIndication==GPAC_OGG_MEDIA_OTI) {					char *szName;					gf_isom_get_visual_info(file, trackNum, 1, &w, &h);					if (full_dump) fprintf(stdout, "\t");					if (!strnicmp(&esd->decoderConfig->decoderSpecificInfo->data[1], "theora", 6)) szName = "Theora";					else szName = "Unknown";					fprintf(stdout, "Ogg/%s video / GPAC Mux  - Visual Size %d x %d\n", szName, w, h);				}				if (!w || !h) {					gf_isom_get_visual_info(file, trackNum, 1, &w, &h);					if (full_dump) fprintf(stdout, "\t");					fprintf(stdout, "Visual Size %d x %d\n", w, h);				}			} else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) {				GF_M4ADecSpecInfo a_cfg;				GF_Err e;				u32 oti, is_mp2 = 0;				switch (esd->decoderConfig->objectTypeIndication) {				case 0x66:				case 0x67:				case 0x68:					is_mp2 = 1;				case 0x40:					e = gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg);					if (full_dump) fprintf(stdout, "\t");					if (e) fprintf(stdout, "Corrupted AAC Config\n");					else {						fprintf(stdout, "MPEG-%d Audio %s - %d Channel(s) - SampleRate %d", is_mp2 ? 2 : 4, gf_m4a_object_type_name(a_cfg.base_object_type), a_cfg.nb_chan, a_cfg.base_sr);						if (a_cfg.has_sbr) fprintf(stdout, " - SBR SampleRate %d", a_cfg.sbr_sr);						fprintf(stdout, "\n");					}					break;				case 0x69:				case 0x6B:					if (msub_type == GF_ISOM_SUBTYPE_MPEG4_CRYP) {						fprintf(stdout, "MPEG-1/2 Audio - %d Channels - SampleRate %d\n", nb_ch, sr);					} else {						GF_ISOSample *samp = gf_isom_get_sample(file, trackNum, 1, &oti);						oti = GF_4CC((u8)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]);						if (full_dump) fprintf(stdout, "\t");						fprintf(stdout, "%s Audio - %d Channel(s) - SampleRate %d - Layer %d\n",							gf_mp3_version_name(oti),							gf_mp3_num_channels(oti), 							gf_mp3_sampling_rate(oti), 							gf_mp3_layer(oti)						);						gf_isom_sample_del(&samp);					}					break;				/*OGG media*/				case GPAC_OGG_MEDIA_OTI:				{					char *szName;					if (full_dump) fprintf(stdout, "\t");					if (!strnicmp(&esd->decoderConfig->decoderSpecificInfo->data[1], "vorbis", 6)) szName = "Vorbis";					else if (!strnicmp(&esd->decoderConfig->decoderSpecificInfo->data[0], "Speex", 5)) szName = "Speex";					else if (!strnicmp(&esd->decoderConfig->decoderSpecificInfo->data[0], "Flac", 4)) szName = "Flac";					else szName = "Unknown";					fprintf(stdout, "Ogg/%s audio / GPAC Mux - Sample Rate %d - %d channel(s)\n", szName, sr, nb_ch);				}					break;				case 0xA0: fprintf(stdout, "EVRC Audio - Sample Rate 8000 - 1 channel\n"); break;				case 0xA1: fprintf(stdout, "SMV Audio - Sample Rate 8000 - 1 channel\n"); break;				case 0xE1: fprintf(stdout, "QCELP Audio - Sample Rate 8000 - 1 channel\n"); break;				/*packetVideo hack for EVRC...*/				case 0xD1: 					if (esd->decoderConfig->decoderSpecificInfo && (esd->decoderConfig->decoderSpecificInfo->dataLength==8)					&& !strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "pvmm", 4)) {						if (full_dump) fprintf(stdout, "\t");						fprintf(stdout, "EVRC Audio (PacketVideo Mux) - Sample Rate 8000 - 1 channel\n"); 					}					break;				}			}			else if (esd->decoderConfig->streamType==GF_STREAM_SCENE) {				if (esd->decoderConfig->objectTypeIndication<=6) {					GF_BIFSConfig *b_cfg = gf_odf_get_bifs_config(esd->decoderConfig->decoderSpecificInfo, esd->decoderConfig->objectTypeIndication);					fprintf(stdout, "BIFS Scene description - %s stream\n", b_cfg->elementaryMasks ? "Animation" : "Command"); 					if (full_dump && !b_cfg->elementaryMasks) {						fprintf(stdout, "\tWidth %d Height %d Pixel Metrics %s\n", b_cfg->pixelWidth, b_cfg->pixelHeight, b_cfg->pixelMetrics ? "yes" : "no"); 					}					gf_odf_desc_del((GF_Descriptor *)b_cfg);				} else if (esd->decoderConfig->objectTypeIndication==0x09) {					GF_LASERConfig l_cfg;					gf_odf_get_laser_config(esd->decoderConfig->decoderSpecificInfo, &l_cfg);					fprintf(stdout, "LASER Stream - %s\n", l_cfg.newSceneIndicator ? "Full Scene" : "Scene Segment"); 				}			}			/*sync is only valid if we open all tracks to take care of default MP4 sync..*/			if (!full_dump) {				if (!esd->OCRESID || (esd->OCRESID == esd->ESID))					fprintf(stdout, "Self-synchronized\n");				else					fprintf(stdout, "Synchronized on stream %d\n", esd->OCRESID);			} else {				fprintf(stdout, "\tDecoding Buffer size %d - Average bitrate %d kbps - Max Bitrate %d kbps\n", esd->decoderConfig->bufferSizeDB, esd->decoderConfig->avgBitrate/1024, esd->decoderConfig->maxBitrate/1024);				if (esd->dependsOnESID)					fprintf(stdout, "\tDepends on stream %d for decoding\n", esd->dependsOnESID);				else					fprintf(stdout, "\tNo stream dependencies for decoding\n");				fprintf(stdout, "\tStreamPriority %d\n", esd->streamPriority);				if (esd->URLString) fprintf(stdout, "\tRemote Data Source %s\n", esd->URLString);			}			gf_odf_desc_del((GF_Descriptor *) esd);			/*ISMACryp*/			if (msub_type == GF_ISOM_SUBTYPE_MPEG4_CRYP) {				const char *scheme_URI, *KMS_URI;				u32 scheme_type, version;				u32 IV_size;				Bool use_sel_enc;				if (gf_isom_is_ismacryp_media(file, trackNum, 1)) {					gf_isom_get_ismacryp_info(file, trackNum, 1, NULL, &scheme_type, &version, &scheme_URI, &KMS_URI, &use_sel_enc, &IV_size, NULL);					fprintf(stdout, "\n*Encrypted stream - ISMA scheme %s (version %d)\n", gf_4cc_to_str(scheme_type), version);					if (scheme_URI) fprintf(stdout, "scheme location: %s\n", scheme_URI);					if (KMS_URI) {						if (!strnicmp(KMS_URI, "(key)", 5)) fprintf(stdout, "KMS location: key in file\n");						else fprintf(stdout, "KMS location: %s\n", KMS_URI);					}					fprintf(stdout, "Selective Encryption: %s\n", use_sel_enc ? "Yes" : "No");					if (IV_size) fprintf(stdout, "Initialization Vector size: %d bits\n", IV_size*8);				} else if (gf_isom_is_omadrm_media(file, trackNum, 1)) {					const char *textHdrs;					u32 enc_type, hdr_len;					u64 orig_len;					fprintf(stdout, "\n*Encrypted stream - OMA DRM\n");					gf_isom_get_omadrm_info(file, trackNum, 1, NULL, NULL, NULL, &scheme_URI, &KMS_URI, &textHdrs, &hdr_len, &orig_len, &enc_type, &use_sel_enc, &IV_size, NULL);					fprintf(stdout, "Rights Issuer: %s\n", KMS_URI);					fprintf(stdout, "Content ID: %s\n", scheme_URI);					if (textHdrs) {						u32 i, offset;						const char *start = textHdrs;						fprintf(stdout, "OMA Textual Headers:\n");						i=offset=0;						while (i<hdr_len) {							if (start[i]==0) {								fprintf(stdout, "\t%s\n", start+offset);								offset=i+1;							}							i++;						}						fprintf(stdout, "\t%s\n", start+offset);					}					if (orig_len) fprintf(stdout, "Original media size "LLD"\n", LLD_CAST orig_len);					fprintf(stdout, "Encryption algorithm %s\n", (enc_type==1) ? "AEA 128 CBC" : (enc_type ? "AEA 128 CTR" : "None"));					fprintf(stdout, "Selective Encryption: %s\n", use_sel_enc ? "Yes" : "No");					if (IV_size) fprintf(stdout, "Initialization Vector size: %d bits\n", IV_size*8);				} else {					fprintf(stdout, "\n*Encrypted stream - unknown scheme %s\n", gf_4cc_to_str(gf_isom_is_media_encrypted(file, trackNum, 1) ));				}			}		}	} else if (msub_type == GF_ISOM_SUBTYPE_3GP_H263) {		u32 w, h;		gf_isom_get_visual_info(file, trackNum, 1, &w, &h);		fprintf(stdout, "\t3GPP H263 stream - Resolution %d x %d\n", w, h);	} else if (msub_type == GF_4CC('m','j','p','2')) {		u32 w, h;		gf_isom_get_visual_info(file, trackNum, 1, &w, &h);		fprintf(stdout, "\tMotionJPEG2000 stream - Resolution %d x %d\n", w, h);	} else if ((msub_type == GF_ISOM_SUBTYPE_3GP_AMR) || (msub_type == GF_ISOM_SUBTYPE_3GP_AMR_WB)) {		fprintf(stdout, "\t3GPP AMR%s stream - Sample Rate %d - %d channel(s) %d bits per samples\n", (msub_type == GF_ISOM_SUBTYPE_3GP_AMR_WB) ? " Wide Band" : "", sr, nb_ch, (u32) bps);	} else if (msub_type == GF_ISOM_SUBTYPE_3GP_EVRC) {		fprintf(stdout, "\t3GPP EVRC stream - Sample Rate %d - %d channel(s) %d bits per samples\n", sr, nb_ch, (u32) bps);	} else if (msub_type == GF_ISOM_SUBTYPE_3GP_QCELP) {		fprintf(stdout, "\t3GPP QCELP stream - Sample Rate %d - %d channel(s) %d bits per samples\n", sr, nb_ch, (u32) bps);	} else if (msub_type == GF_ISOM_SUBTYPE_3GP_SMV) {		fprintf(stdout, "\t3GPP SMV stream - Sample Rate %d - %d channel(s) %d bits per samples\n", sr, nb_ch, (u32) bps);	} else if (mtype==GF_ISOM_MEDIA_HINT) {		u32 refTrack;		s32 i, refCount = gf_isom_get_reference_count(file, trackNum, GF_ISOM_REF_HINT);		if (refCount) {			fprintf(stdout, "Streaming Hint Track for track%s ", (refCount>1) ? "s" :"");			for (i=0; i<refCount; i++) {				gf_isom_get_reference(file, trackNum, GF_ISOM_REF_HINT, i+1, &refTrack);				if (i) fprintf(stdout, " - ");				fprintf(stdout, "ID %d", gf_isom_get_track_id(file, refTrack));			}			fprintf(stdout, "\n");		} else {			fprintf(stdout, "Streaming Hint Track (no refs)\n");		}		refCount = gf_isom_get_payt_count(file, trackNum);		for (i=0;i<refCount;i++) {			const char *name = gf_isom_get_payt_info(file, trackNum, i+1, &refTrack);			fprintf(stdout, "\tPayload ID %d: type %s\n", refTrack, name);		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -