📄 main.c
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) Jean Le Feuvre 2000-2005 * All rights reserved * * This file is part of GPAC / mp4box application * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */#include <gpac/scene_manager.h>#include <gpac/media_tools.h>/*RTP packetizer flags*/#include <gpac/ietf.h>#include <gpac/ismacryp.h>#define BUFFSIZE 8192/*in fileimport.c*/#ifndef GPAC_READ_ONLYvoid convert_file_info(char *inName, u32 trackID);GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double force_fps, u32 frames_per_sample);GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, char *inName, Double InterleavingTime, Double chunk_start, const char *tmpdir, char *outfile);GF_Err cat_isomedia_file(GF_ISOFile *mp4, char *fileName, u32 import_flags, Double force_fps, u32 frames_per_sample, char *tmp_dir);GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *logs);GF_Err EncodeFileChunk(char *chunkFile, char *bifs, char *inputContext, char *outputContext, const char *tmpdir);GF_ISOFile *package_file(char *file_name, char *fcc, const char *tmpdir);GF_Err dump_cover_art(GF_ISOFile *file, char *inName);u32 id3_get_genre_tag(const char *name);#endif/*in filedump.c*/#ifndef GPAC_READ_ONLYGF_Err dump_file_text(char *file, char *inName, u32 dump_mode, Bool do_log);void dump_scene_stats(char *file, char *inName, u32 stat_level);#endifvoid PrintNode(const char *name, u32 graph_type);void PrintBuiltInNodes(u32 graph_type);void dump_file_mp4(GF_ISOFile *file, char *inName);void dump_file_rtp(GF_ISOFile *file, char *inName);void dump_file_ts(GF_ISOFile *file, char *inName);void dump_file_ismacryp(GF_ISOFile *file, char *inName);void dump_timed_text_track(GF_ISOFile *file, u32 trackID, char *inName, Bool is_convert, u32 dump_type);void DumpSDP(GF_ISOFile *file, char *inName);void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump);void DumpMovieInfo(GF_ISOFile *file);void PrintLanguages();const char *GetLanguageCode(char *lang);void dump_mpeg2_ts(char *mpeg2ts_in, char *pes_out_name);Bool quiet = 0;/*some global vars for swf import :(*/u32 swf_flags = 0;Float swf_flatten_angle = 0;s32 laser_resolution = 0;typedef struct { u32 code; const char *name; const char *comment; } itunes_tag;static const itunes_tag itags[] = { {GF_ISOM_ITUNE_ALBUM_ARTIST, "album_artist", "usage: album_artist=album artist"}, {GF_ISOM_ITUNE_ALBUM, "album", "usage: album=name" }, {GF_ISOM_ITUNE_TRACKNUMBER, "tracknum", "usage: track=x/N"}, {GF_ISOM_ITUNE_TRACK, "track", "usage: track=name"}, {GF_ISOM_ITUNE_ARTIST, "artist", "usage: artist=name"}, {GF_ISOM_ITUNE_COMMENT, "comment", "usage: comment=any comment"}, {GF_ISOM_ITUNE_COMPILATION, "compilation", "usage: compilation=yes,no"}, {GF_ISOM_ITUNE_COMPOSER, "composer", "usage: composer=name"}, {GF_ISOM_ITUNE_CREATED, "created", ""}, {GF_ISOM_ITUNE_DISK, "disk", "usage: disk=x/N"}, {GF_ISOM_ITUNE_TOOL, "tool", "usage: tool=name"}, {GF_ISOM_ITUNE_GENRE, "genre", "usage: genre=name"}, {GF_ISOM_ITUNE_NAME, "name", "usage: name=name"}, {GF_ISOM_ITUNE_TEMPO, "tempo", "usage: tempo=integer"}, {GF_ISOM_ITUNE_WRITER, "writer", "usage: writer=name"}, {GF_ISOM_ITUNE_GROUP, "group", "usage: group=name"}, {GF_ISOM_ITUNE_COVER_ART, "cover", "usage: covber=file.jpg,file.png"}, {GF_ISOM_ITUNE_ENCODER, "encoder", "usage: encoder=name"}, {GF_ISOM_ITUNE_GAPELESS, "gapeless", "usage: artist=yes,no"},};u32 nb_itunes_tags = sizeof(itags) / sizeof(itunes_tag);void PrintVersion(){ fprintf(stdout, "MP4Box - GPAC version " GPAC_VERSION "\n"#ifdef GPAC_FIXED_POINT "GPAC compiled in fixed-point version\n"#endif#ifdef GPAC_READ_ONLY "GPAC compiled in read-only version\n"#endif "GPAC Copyright: (c) Jean Le Feuvre 2000-2005\n\t\t(c) ENST 2005-200X\n");}void PrintGeneralUsage(){ fprintf(stdout, "General Options:\n" " -inter time_in_ms interleaves file data (track chunks of time_in_ms)\n" " * Note 1: Interleaving is 0.5s by default\n" " * Note 2: Performs drift checking accross tracks\n" " * Note 3: a value of 0 disables interleaving\n" " -old-inter time same as -inter but doesn't perform drift checking\n" " -tight: performs tight interleaving (sample based) of the file\n" " * Note: reduces disk seek but increases file size\n" " -flat stores file with all media data first, non-interleaved\n" " -frag time_in_ms fragments file (track fragments of time_in_ms)\n" " * Note: Always disables interleaving\n" " -out filename specifies output file name\n" " * Note: By default input (MP4,3GP) file is overwritten\n" " -tmp dirname specifies directory for temporary file creation\n" " * Note: Default temp dir is OS-dependent\n" " -no-sys removes all MPEG-4 Systems info except IOD (profiles)\n" " * Note: Set by default whith '-add' and '-cat'\n" " -no-iod removes InitialObjkectDescriptor from file\n" " -isma rewrites the file as an ISMA 1.0 AV file\n" " -ismax same as \'-isma\' and removes all clock references\n" " -3gp rewrites as 3GPP(2) file (no more MPEG-4 Systems Info)\n" " * Note 1: some tracks may be removed in the process\n" " * Note 2: always on for *.3gp *.3g2 *.3gpp\n" " -ipod rewrites the file for iPod\n" " -brand ABCD[:v] sets major brand of file, with optional version\n" " -ab ABCD adds given brand to file's alternate brand list\n" " -rb ABCD removes given brand from file's alternate brand list\n" " -cprt string adds copyright string to movie\n" " -chap file adds chapter information contained in file\n" " -rem trackID: removes track from file\n" " -new: forces creation of a new destination file\n" " -rem trackID: removes track from file\n" " -lang [tkID=]LAN: sets track language. LAN is the ISO 639-2 code (eng, und)\n" " -delay tkID=TIME: sets track start delay in ms.\n" " -par tkID=PAR: sets visual track pixel aspect ratio (PAR=N:D or \"none\")\n" " -name tkID=NAME: sets track handler name\n" " * NAME can indicate a UTF-8 file (\"file://file name\"\n" " -itags tag1[:tag2]: sets iTunes tags to file - more info: MP4Box -tag-list.\n" " -split time_sec splits in files of time_sec max duration\n" " * Note: this removes all MPEG-4 Systems media\n" " -split-size size splits in files of max filesize kB.\n" " * Note: this removes all MPEG-4 Systems media\n" " -split-chunk S:E extracts a new file from Start to End (in seconds)\n" " * Note: this removes all MPEG-4 Systems media\n" "\n");}void PrintFormats(){ fprintf(stdout, "Suppported raw formats and file extensions:\n" " NHNT .media .nhnt .info\n" " NHML .nhml (opt: .media .info)\n" " MPEG-1-2 Video .m1v .m2v\n" " MPEG-4 Video .cmp .m4v\n" " H263 Video .263 .h263\n" " AVC/H264 Video .h264 .h26L .264 .26L\n" " JPEG Images .jpg .jpeg\n" " PNG Images .png\n" " MPEG 1-2 Audio .mp3, .m1a, .m2a\n" " ADTS-AAC Audio .aac\n" " AMR(WB) Audio .amr .awb\n" " EVRC Audio .evc\n" " SMV Audio .smv\n" "\n" "Supported containers and file extensions:\n" " AVI .avi\n" " MPEG-2 PS .mpg .mpeg .vob .vcd .svcd\n" " MPEG-2 TS .ts .m2t\n" " QCP .qcp\n" " OGG .ogg\n" " ISO-Media files no extension checking\n" "\n" "Supported text formats:\n" " SRT Subtitles .srt\n" " SUB Subtitles .sub\n" " GPAC Timed Text .ttxt\n" " QuickTime TeXML Text .xml (cf QT documentation)\n" "\n" "Supported Scene formats:\n" " MPEG-4 XMT-A .xmt .xmta .xmt.gz .xmta.gz\n" " MPEG-4 BT .bt .bt.gz\n" " VRML .wrl .wrl.gz\n" " X3D-XML .x3d .x3d.gz\n" " X3D-VRML .x3dv .x3dv.gz\n" " MacroMedia Flash .swf (very limitted import support only)\n" "\n" );}void PrintImportUsage(){ fprintf(stdout, "Importing Options\n" "\nFile importing syntax:\n" " \"#video\" \"#audio\": base import for most AV files\n" " \"#trackID=ID\": track import for IsoMedia and other files\n" " \"#pid=ID\": stream import from MPEG-2 TS\n" " \":dur=D\": imports only the first D seconds\n" " \":lang=LAN\": sets imported media language code\n" " \":delay=delay_ms\": sets imported media initial delay in ms\n" " \":par=PAR\": sets visual pixel aspect ratio (PAR=Num:Den)\n" " \":name=NAME\": sets track handler name\n" " \":fps=VAL\": same as -fps option\n" " \":agg=VAL\": same as -agg option\n" " \":par=VAL\": same as -par option\n" " \":dref\": same as -dref option\n" " \":nodrop\": same as -nodrop option\n" " \":packed\": same as -packed option\n" " \":sbr\": same as -sbr option\n" " \":sbrx\": same as -sbrx option\n" " \":mpeg4\": same as -mpeg4 option\n" " \":font=name\": specifies font name for text import (default \"Serif\")\n" " \":size=s\": specifies font size for text import (default 18)\n" "\n" " -add file: add file tracks to (new) output file\n" " -cat file: concatenates file samples to (new) output file\n" " * Note: creates tracks if needed\n" " -keep-sys: keeps all MPEG-4 Systems info when using '-add' / 'cat'\n" " -keep-all: keeps all existing tracks when using '-add'\n" " * Note: only used when adding IsoMedia files\n" "\n" "All the following options can be specified as default or for each track.\n" "When specified by track the syntax is \":opt\" or \":opt=val\".\n\n" " -dref: keeps media data in original file\n" " -no-drop: forces constant FPS when importing AVI video\n" " -packed: * forces packed bitstream when importing raw ASP\n" " -sbr: backward compatible signaling of AAC-SBR\n" " -sbrx: non-backward compatible signaling of AAC-SBR\n" " * Note: SBR AAC cannot be detected at import time\n" " -fps FPS: forces frame rate for video and SUB subtitles import\n" " * For raw H263 import, default FPS is 15\n" " * For all other imports, default FPS is 25\n" " -- THIS IS IGNORED FOR IsoMedia IMPORT --\n" " -mpeg4: forces MPEG-4 sample descriptions when possible (3GPP2)\n" " -agg N: aggregates N audio frames in 1 sample (3GP media only)\n" " * Note: Maximum value is 15 - Disabled by default\n" "\n" );}void PrintEncodeUsage(){ fprintf(stdout, "MPEG-4 Scene Encoding Options\n" " -mp4: specify input file is for encoding.\n" " -def: encode DEF names\n" " -sync time_in_ms: forces BIFS sync sample generation every time_in_ms\n" " * Note: cannot be used with -shadow\n" " -shadow time_ms: forces BIFS sync shadow sample generation every time_ms.\n" " * Note: cannot be used with -sync\n" " -log: generates scene codec log file if available\n" " -ms file: specifies file for track importing\n" "\nChunk Processing\n" " -ctx-in file: specifies initial context (MP4/BT/XMT)\n" " * Note: input file must be a commands-only file\n" " -ctx-out file: specifies storage of updated context (MP4/BT/XMT)\n" "\n" "LASeR Encoding options\n" " -auto_quant res: resolution is given as if using -resolution\n" " but coord-bits and scale-bits are infered\n" " -resolution res: resolution factor (-8 to 7, default 0)\n" " all coords are multiplied by 2^res before truncation\n" " -coord-bits bits: bits used for encoding truncated coordinates\n" " (0 to 31, default 12)\n" " -scale-bits bits: extra bits used for encoding truncated scales\n" " (0 to 4, default 0)\n" );}void PrintEncryptUsage(){ fprintf(stdout, "ISMA Encryption/Decryption Options\n" " -crypt drm_file: crypts a specific track using ISMA AES CTR 128\n" " -decrypt [drm_file] decrypts a specific track using ISMA AES CTR 128\n" " * Note: drm_file can be omitted if keys are in file\n" " -set-kms kms_uri changes KMS location for all tracks or a given one.\n" " * to adress a track, use \'tkID=kms_uri\'\n" "\n" "DRM file syntax for GPAC ISMACryp:\n" " File is XML and shall start with xml header\n" " File root is an \"ISMACryp\" element\n" " File is a list of \"ISMACrypTrack\" elements\n" "\n" "ISMACrypTrack attributes are\n" " TrackID: ID of track to en/decrypt\n" " key: AES-128 key formatted (hex string \'0x\'+32 chars)\n" " salt: CTR IV salt key (64 bits) (hex string \'0x\'+16 chars)\n" "\nEncryption only attributes:\n" " Scheme_URI: URI of scheme used\n" " KMS_URI: URI of key management system\n" " * Note: \'self\' writes key and salt in the file\n" " selectiveType: selective encryption type - understood values are:\n" " \"None\": all samples encrypted (default)\n" " \"RAP\": only encrypts random access units\n" " \"Non-RAP\": only encrypts non-random access units\n" " \"Rand\": random selection is performed\n" " \"X\": Encrypts every first sample out of X (uint)\n" " \"RandX\": Encrypts one random sample out of X (uint)\n" "\n" " ipmpType: IPMP Signaling Type: None, IPMP, IPMPX\n" " ipmpDescriptorID: IPMP_Descriptor ID to use if IPMP(X) is used\n" " * If not set MP4Box will generate one for you\n" "\n" );}void PrintHintUsage(){ fprintf(stdout, "Hinting Options\n" " -hint: hints the file for RTP/RTSP\n" " -mtu size: specifies RTP MTU (max size) in bytes. Default size is 1450\n" " * Note: this includes the RTP header (12 bytes)\n" " -copy: copies media data to hint track rather than reference\n" " * Note: speeds up server but takes much more space\n" " -multi [maxptime]: enables frame concatenation in RTP packets if possible\n" " maxptime: max packet duration in ms (optional, default 100ms)\n" " -rate ck_rate: specifies rtp rate in Hz when no default for payload\n" " * Note: default value is 90000 (MPEG rtp rates)\n" " -mpeg4: forces MPEG-4 generic payload whenever possible\n" " -latm: forces MPG4-LATM transport for AAC streams\n" " -static: enables static RTP payload IDs whenever possible\n" " * By default, dynamic payloads are always used\n" "\n" "MPEG-4 Generic Payload Options\n" " -ocr: forces all streams to be synchronized\n" " * Most RTSP servers only support synchronized streams\n" " -rap: signals random access points in RTP packets\n" " -ts: signals AU Time Stamps in RTP packets\n" " -size: signals AU size in RTP packets\n" " -idx: signals AU sequence numbers in RTP packets\n" " -iod: prevents systems tracks embedding in IOD\n" " * Note: shouldn't be used with -isma option\n" "\n" " -add-sdp string: adds sdp string to (hint) track (\"-add-sdp tkID:string\")\n" " or movie. This will take care of SDP lines ordering\n" " * WARNING: You cannot add anything to SDP, cf rfc2327.\n" " -unhint: removes all hinting information.\n" "\n");}void PrintExtractUsage(){ fprintf(stdout, "Extracting Options\n" " -raw TrackID: extracts track in raw format when supported\n" " -raws TrackID: extract each track sample to a file\n" " * Note: \"TrackID:N\" extracts Nth sample\n" " -nhnt TrackID: extracts track in nhnt format\n" " -nhml TrackID: extracts track in nhml format (XML nhnt).\n" " * Note: \"-nhml +TrackID\" for full dump\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -