📄 main.c
字号:
" -single TrackID: extracts track to a new mp4 file\n" " -avi TrackID: extracts visual track to an avi file\n" " -qcp TrackID: same as \'-raw\' but defaults to QCP file for EVRC/SMV\n" " -aviraw TK: extracts AVI track in raw format\n" " $TK can be one of \"video\" \"audio\" \"audioN\"\n" " -saf: remux file to SAF multiplex\n" " * Note: can be used when encoding scene descriptions\n" "\n");}void PrintDumpUsage(){ fprintf(stdout, "Dumping Options\n" " -std: dumps to stdout instead of file\n" " -info [trackID] prints movie info / track info if trackID specified\n" " * Note: for non IsoMedia files, gets import options\n" " -bt: scene to bt format - removes unknown MPEG4 nodes\n" " -xmt: scene to XMT-A format - removes unknown MPEG4 nodes\n" " -wrl: scene VRML format - removes unknown VRML nodes\n" " -x3d: scene to X3D/XML format - removes unknown X3D nodes\n" " -x3dv: scene to X3D/VRML format - removes unknown X3D nodes\n" " -lsr: scene to LASeR format\n" " -diso: scene IsoMedia file boxes in XML output\n" " -drtp: rtp hint samples structure to XML output\n" " -dts: prints sample timing to text output\n" " -sdp: dumps SDP description of hinted file\n" " -dcr: ISMACryp samples structure to XML output\n" "\n"#ifndef GPAC_READ_ONLY " -ttxt: Converts input subtitle to GPAC TTXT format\n"#endif " -ttxt TrackID: Dumps Text track to GPAC TTXT format\n"#ifndef GPAC_READ_ONLY " -srt: Converts input subtitle to SRT format\n"#endif " -srt TrackID: Dumps Text track to SRT format\n" "\n" " -stat: generates node/field statistics for scene\n" " -stats: generates node/field statistics per MPEG-4 Access Unit\n" " -statx: generates node/field statistics for scene after each AU\n" "\n" " -hash: generates SHA-1 Hash of the input file\n" "\n");}void PrintMetaUsage(){ fprintf(stdout, "Meta handling Options\n" " -set-meta args: sets given meta type - syntax: \"ABCD[:tk=ID]\"\n" " * ABCD: four char meta type (NULL or 0 to remove meta)\n" " * [:tk=ID]: if not set use root (file) meta\n" " if ID is 0 use moov meta\n" " if ID is not 0 use track meta\n" " -add-item args: adds resource to meta\n" " * syntax: file_path + options (\':\' separated):\n" " tk=ID: meta adressing (file, moov, track)\n" " name=str: item name\n" " mime=mtype: item mime type\n" " encoding=enctype: item content-encoding type\n" " * file_path \"this\" or \"self\": item is the file itself\n" " -rem-item args: removes resource from meta - syntax: item_ID[:tk=ID]\n" " -set-primary args: sets item as primary for meta - syntax: item_ID[:tk=ID]\n" " -set-xml args: sets meta XML data\n" " * syntax: xml_file_path[:tk=ID][:binary]\n" " -rem-xml [tk=ID]: removes meta XML data\n" " -dump-xml args: dumps meta XML to file - syntax file_path[:tk=ID]\n" " -dump-item args: dumps item to file - syntax item_ID[:tk=ID][:path=fileName]\n" " -package: packages input XML file into an ISO container\n" " * all media referenced except hyperlinks are added to file\n" "\n");}void PrintSWFUsage(){ fprintf(stdout, "SWF Importer Options\n" "\n" "MP4Box can import simple Macromedia Flash files (\".SWF\")\n" "You can specify a SWF input file with \'-bt\', \'xmt\' and \'-mp4\' options\n" "\n" " -global: all SWF defines are placed in first scene replace\n" " * Note: By default SWF defines are sent when needed\n" " -ctrl: uses a dedicated stream for movie control\n" " * Note: Forces \'-global\'\n" " -no-text: removes all SWF text\n" " -no-font: removes all embedded SWF Fonts (terminal fonts used)\n" " -no-line: removes all lines from SWF shapes\n" " -no-grad: removes all gradients from swf shapes\n" " -quad: uses quadratic bezier curves instead of cubic ones\n" " -xlp: support for lines transparency and scalability\n" " -flatten ang: complementary angle below which 2 lines are merged\n" " * Note: angle \'0\' means no flattening\n" "\n" );}void PrintUsage(){ fprintf (stdout, "MP4Box [option] input [option]\n"#ifndef GPAC_READ_ONLY " -h general: general options help\n" " -h hint: hinting options help\n" " -h import: import options help\n" " -h encode: encode options help\n" " -h meta: meta handling options help\n"#else "READ-ONLY VERSION\n"#endif " -h extract: extraction options help\n" " -h dump: dump options help\n" " -h swf: Flash (SWF) options help\n" " -h crypt: ISMA E&A options help\n" " -h format: supported formats help\n" "\n" " -nodes: lists supported MPEG4 nodes\n" " -node NodeName: gets MPEG4 node syntax and QP info\n" " -xnodes: lists supported X3D nodes\n" " -xnode NodeName: gets X3D node syntax\n" " -snodes: lists supported SVG nodes\n" " -snode NodeName: gets SVG node syntax\n" " -languages: lists supported ISO 639 languages\n" "\n" "-quiet: quiet mode\n" " -v: verbose mode\n" " -version: gets build version\n" );}void scene_coding_log(void *cbk, u32 log_level, u32 log_tool, const char *fmt, va_list vlist){ FILE *logs = cbk; if (log_tool != GF_LOG_CODING) return; vfprintf(logs, fmt, vlist); fflush(logs);}#ifndef GPAC_READ_ONLY/* MP4 File Hinting*/void SetupClockReferences(GF_ISOFile *file){ u32 i, count, ocr_id; count = gf_isom_get_track_count(file); if (count==1) return; ocr_id = 0; for (i=0; i<count; i++) { if (!gf_isom_is_track_in_root_od(file, i+1)) continue; ocr_id = gf_isom_get_track_id(file, i+1); break; } /*doesn't look like MP4*/ if (!ocr_id) return; for (i=0; i<count; i++) { GF_ESD *esd = gf_isom_get_esd(file, i+1, 1); if (esd) { esd->OCRESID = ocr_id; gf_isom_change_mpeg4_description(file, i+1, 1, esd); gf_odf_desc_del((GF_Descriptor *) esd); } }}/*base RTP payload type used (you can specify your own types if needed)*/#define BASE_PAYT 96GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 base_flags, Bool copy_data, Bool interleave, Bool regular_iod){ GF_ESD *esd; GF_InitialObjectDescriptor *iod; u32 i, val, res, streamType; u32 sl_mode, prev_ocr, single_ocr, nb_done, tot_bw, bw, flags, spec_type; GF_Err e; char szPayload[30]; GF_RTPHinter *hinter; Bool copy, has_iod, single_av; u8 init_payt = BASE_PAYT; u32 iod_mode, mtype; u32 media_group = 0; u8 media_prio = 0; tot_bw = 0; prev_ocr = 0; single_ocr = 1; has_iod = 1; iod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file); if (!iod) has_iod = 0; else { if (!gf_list_count(iod->ESDescriptors)) has_iod = 0; gf_odf_desc_del((GF_Descriptor *) iod); } spec_type = gf_isom_guess_specification(file); single_av = gf_isom_is_single_av(file); /*first make sure we use a systems track as base OCR*/ for (i=0; i<gf_isom_get_track_count(file); i++) { res = gf_isom_get_media_type(file, i+1); if ((res==GF_ISOM_MEDIA_SCENE) || (res==GF_ISOM_MEDIA_OD)) { if (gf_isom_is_track_in_root_od(file, i+1)) { gf_isom_set_default_sync_track(file, i+1); break; } } } nb_done = 0; for (i=0; i<gf_isom_get_track_count(file); i++) { sl_mode = base_flags; copy = copy_data; /*skip emty tracks (mainly MPEG-4 interaction streams...*/ if (!gf_isom_get_sample_count(file, i+1)) continue; mtype = gf_isom_get_media_type(file, i+1); switch (mtype) { case GF_ISOM_MEDIA_VISUAL: if (single_av) { media_group = 2; media_prio = 2; } break; case GF_ISOM_MEDIA_AUDIO: if (single_av) { media_group = 2; media_prio = 1; } break; case GF_ISOM_MEDIA_HINT: continue; default: /*no hinting of systems track on isma*/ if (spec_type==GF_4CC('I','S','M','A')) continue; } mtype = gf_isom_get_media_subtype(file, i+1, 1); if ((mtype==GF_ISOM_SUBTYPE_MPEG4) || (mtype==GF_ISOM_SUBTYPE_MPEG4_CRYP) ) mtype = gf_isom_get_mpeg4_subtype(file, i+1, 1); if (!single_av) { /*one media per group only (we should prompt user for group selection)*/ media_group ++; media_prio = 1; } streamType = 0; esd = gf_isom_get_esd(file, i+1, 1); if (esd) { streamType = esd->decoderConfig->streamType; if (!prev_ocr) { prev_ocr = esd->OCRESID; if (!esd->OCRESID) prev_ocr = esd->ESID; } else if (esd->OCRESID && prev_ocr != esd->OCRESID) { single_ocr = 0; } /*OD MUST BE WITHOUT REFERENCES*/ if (streamType==1) copy = 1; } gf_odf_desc_del((GF_Descriptor *) esd); if (!regular_iod && gf_isom_is_track_in_root_od(file, i+1)) { /*single AU - check if base64 would fit in ESD (consider 33% overhead of base64), otherwise stream*/ if (gf_isom_get_sample_count(file, i+1)==1) { GF_ISOSample *samp = gf_isom_get_sample(file, i+1, 1, &val); if (streamType) { res = gf_hinter_can_embbed_data(samp->data, samp->dataLength, streamType); } else { /*not a system track, we shall hint it*/ res = 0; } if (samp) gf_isom_sample_del(&samp); if (res) continue; } } if (interleave) sl_mode |= GP_RTP_PCK_USE_INTERLEAVING; hinter = gf_hinter_track_new(file, i+1, MTUSize, max_ptime, rtp_rate, sl_mode, init_payt, copy, media_group, media_prio, &e); if (!hinter) { if (e) { fprintf(stdout, "Cannot create hinter (%s)\n", gf_error_to_string(e)); if (!nb_done) return e; } continue; } bw = gf_hinter_track_get_bandwidth(hinter); tot_bw += bw; flags = gf_hinter_track_get_flags(hinter); gf_hinter_track_get_payload_name(hinter, szPayload); fprintf(stdout, "Hinting track ID %d - Type \"%s:%s\" (%s) - BW %d kbps\n", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw); if (flags & GP_RTP_PCK_AUTO_CAROUSEL) fprintf(stdout, "\tMPEG-4 Systems stream carousel enabled\n");/* if (flags & GP_RTP_PCK_FORCE_MPEG4) fprintf(stdout, "\tMPEG4 transport forced\n"); if (flags & GP_RTP_PCK_USE_MULTI) fprintf(stdout, "\tRTP aggregation enabled\n");*/ e = gf_hinter_track_process(hinter); if (!e) e = gf_hinter_track_finalize(hinter, has_iod); gf_hinter_track_del(hinter); if (e) { fprintf(stdout, "Error while hinting (%s)\n", gf_error_to_string(e)); if (!nb_done) return e; } init_payt++; nb_done ++; } if (has_iod) { iod_mode = GF_SDP_IOD_ISMA; if (regular_iod) iod_mode = GF_SDP_IOD_REGULAR; } else { iod_mode = GF_SDP_IOD_NONE; } gf_hinter_finalize(file, iod_mode, tot_bw); if (!single_ocr) fprintf(stdout, "Warning: at least 2 timelines found in the file\nThis may not be supported by servers/players\n\n"); return GF_OK;}static void check_media_profile(GF_ISOFile *file, u32 track){ u8 PL; GF_M4ADecSpecInfo dsi; GF_ESD *esd = gf_isom_get_esd(file, track, 1); if (!esd) return; switch (esd->decoderConfig->streamType) { case 0x04: PL = gf_isom_get_pl_indication(file, GF_ISOM_PL_VISUAL); if (esd->decoderConfig->objectTypeIndication==0x20) { GF_M4VDecSpecInfo dsi; gf_m4v_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi); if (dsi.VideoPL > PL) gf_isom_set_pl_indication(file, GF_ISOM_PL_VISUAL, dsi.VideoPL); } else if (esd->decoderConfig->objectTypeIndication==0x21) { gf_isom_set_pl_indication(file, GF_ISOM_PL_VISUAL, 0x15); } else if (!PL) { gf_isom_set_pl_indication(file, GF_ISOM_PL_VISUAL, 0xFE); } break; case 0x05: PL = gf_isom_get_pl_indication(file, GF_ISOM_PL_AUDIO); switch (esd->decoderConfig->objectTypeIndication) { case 0x66: case 0x67: case 0x68: case 0x40: gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi); if (dsi.audioPL > PL) gf_isom_set_pl_indication(file, GF_ISOM_PL_AUDIO, dsi.audioPL); break; default: if (!PL) gf_isom_set_pl_indication(file, GF_ISOM_PL_AUDIO, 0xFE); } break; } gf_odf_desc_del((GF_Descriptor *) esd);}void remove_systems_tracks(GF_ISOFile *file){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -