Mercurial > mplayer.hg
changeset 7145:3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
based on patch by "Andriy N. Gritsenko" <andrej@lucky.net>
author | arpi |
---|---|
date | Thu, 29 Aug 2002 20:50:49 +0000 |
parents | 4f912998013e |
children | c3f4a1c124ed |
files | cfg-mencoder.h cfgparser.c libmpdemux/aviwrite.c libmpdemux/aviwrite.h mencoder.c |
diffstat | 5 files changed, 98 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-mencoder.h Thu Aug 29 20:21:59 2002 +0000 +++ b/cfg-mencoder.h Thu Aug 29 20:50:49 2002 +0000 @@ -93,6 +93,26 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; +struct config info_conf[]={ + {"name", &info_name, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"artist", &info_artist, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"genre", &info_genre, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"subject", &info_subject, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"copyright", &info_copyright, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"srcform", &info_sourceform, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"comment", &info_comment, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"help", "\nAvailable INFO fields:\n" + " name - title of the subject of the file\n" + " artist - artist or author of the original subject of the file\n" + " genre - original work category\n" + " subject - contents of the file\n" + " copyright - copyright information for the file\n" + " srcform - original form of the material that was digitized\n" + " comment - general comments about the file or the subject of the file\n" + "\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, + {NULL, NULL, 0, 0, 0, 0, NULL} +}; + static config_t mencoder_opts[]={ /* name, pointer, type, flags, min, max */ {"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, /* this must be the first!!! */ @@ -130,6 +150,9 @@ {"vobsuboutindex", &vobsub_out_index, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL}, {"vobsuboutid", &vobsub_out_id, CONF_TYPE_STRING, 0, 0, 0, NULL}, + // info header strings + {"info", info_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, + #ifdef HAVE_DIVX4ENCORE {"divx4opts", divx4opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, #endif
--- a/cfgparser.c Thu Aug 29 20:21:59 2002 +0000 +++ b/cfgparser.c Thu Aug 29 20:50:49 2002 +0000 @@ -707,7 +707,7 @@ /* clear out */ subopt[0] = subparam[0] = 0; - sscanf_ret = sscanf(token, "%[^=]=%s", subopt, subparam); + sscanf_ret = sscanf(token, "%[^=]=%[^:]", subopt, subparam); mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "token: '%s', i=%d, subopt='%s', subparam='%s' (ret: %d)\n", token, i, subopt, subparam, sscanf_ret); switch(sscanf_ret)
--- a/libmpdemux/aviwrite.c Thu Aug 29 20:21:59 2002 +0000 +++ b/libmpdemux/aviwrite.c Thu Aug 29 20:50:49 2002 +0000 @@ -18,6 +18,14 @@ #include "aviwrite.h" #include "aviheader.h" +extern char *info_name; +extern char *info_artist; +extern char *info_genre; +extern char *info_subject; +extern char *info_copyright; +extern char *info_sourceform; +extern char *info_comment; + aviwrite_stream_t* aviwrite_new_stream(aviwrite_t *muxer,int type){ aviwrite_stream_t* s; if(muxer->avih.dwStreams>=AVIWRITE_MAX_STREAMS){ @@ -135,6 +143,8 @@ unsigned int riff[3]; int i; unsigned int hdrsize; + aviwrite_info_t info[16]; + // RIFF header: #ifdef WORDS_BIGENDIAN /* FIXME: updating the header on big-endian causes the video @@ -221,6 +231,56 @@ } } +// ============= INFO =============== +// always include software info +info[0].id=mmioFOURCC('I','S','F','T'); // Software: +info[0].text="MEncoder " VERSION; +// include any optional strings +i=1; +if(info_name!=NULL){ + info[i].id=mmioFOURCC('I','N','A','M'); // Name: + info[i++].text=info_name; +} +if(info_artist!=NULL){ + info[i].id=mmioFOURCC('I','A','R','T'); // Artist: + info[i++].text=info_artist; +} +if(info_genre!=NULL){ + info[i].id=mmioFOURCC('I','G','N','R'); // Genre: + info[i++].text=info_genre; +} +if(info_subject!=NULL){ + info[i].id=mmioFOURCC('I','S','B','J'); // Subject: + info[i++].text=info_subject; +} +if(info_copyright!=NULL){ + info[i].id=mmioFOURCC('I','C','O','P'); // Copyright: + info[i++].text=info_copyright; +} +if(info_sourceform!=NULL){ + info[i].id=mmioFOURCC('I','S','R','F'); // Source Form: + info[i++].text=info_sourceform; +} +if(info_comment!=NULL){ + info[i].id=mmioFOURCC('I','C','M','T'); // Comment: + info[i++].text=info_comment; +} +info[i].id=0; + + hdrsize=0; + // calc info size: + for(i=0;info[i].id!=0;i++) if(info[i].text){ + size_t sz=strlen(info[i].text)+1; + hdrsize+=sz+8+sz%2; + } + // write infos: + if (hdrsize!=0){ + write_avi_list(f,mmioFOURCC('I','N','F','O'),hdrsize); + for(i=0;info[i].id!=0;i++) if(info[i].text){ + write_avi_chunk(f,info[i].id,strlen(info[i].text)+1,info[i].text); + } + } + // JUNK: write_avi_chunk(f,ckidAVIPADDING,2048-(ftell(f)&2047)-8,NULL); /* junk */ // 'movi' header:
--- a/libmpdemux/aviwrite.h Thu Aug 29 20:21:59 2002 +0000 +++ b/libmpdemux/aviwrite.h Thu Aug 29 20:50:49 2002 +0000 @@ -26,6 +26,11 @@ } aviwrite_stream_t; typedef struct { + unsigned int id; + char *text; +} aviwrite_info_t; + +typedef struct { // encoding: MainAVIHeader avih; unsigned int movi_start;
--- a/mencoder.c Thu Aug 29 20:21:59 2002 +0000 +++ b/mencoder.c Thu Aug 29 20:50:49 2002 +0000 @@ -164,6 +164,15 @@ float sub_last_pts = -303; #endif +// infos are empty by default +char *info_name=NULL; +char *info_artist=NULL; +char *info_genre=NULL; +char *info_subject=NULL; +char *info_copyright=NULL; +char *info_sourceform=NULL; +char *info_comment=NULL; + //char *out_audio_codec=NULL; // override audio codec