1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
/*
* external_codec.c
*
* Copyright (C) Marzio Malanchini - August 2003
*
* This file is part of transcode, a video stream processing tool
*
* transcode is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* transcode 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include "transcode.h"
#include "external_codec.h"
#include <stdlib.h>
#define MPEG2ENC_MP2ENC_PROG "mplex"
#define MPEG_MPEG_PROG "tcmplex"
#define AVI_AVI_PROG "avimerge"
static char *p_supported_modules[] = {
"null",
"mpeg2enc",
"mp2enc",
"mpeg",
"divx5",
"ffmpeg",
"xvid",
NULL
};
void f_help_codec (char *p_module)
{
int s_cont;
fprintf(stderr, "[%s] Supported Modules\n",p_module);
fprintf(stderr, "[%s] --------------------\n",p_module);
for(s_cont=0;p_supported_modules[s_cont]!=NULL;s_cont++)
{
if (s_cont%2)
fprintf(stderr, "\t%s\n",p_supported_modules[s_cont]);
else
fprintf(stderr, "[%s] %s",p_module,p_supported_modules[s_cont]);
}
if ((s_cont-1)%2)
fprintf(stderr, "[%s] --------------------\n",p_module);
else
fprintf(stderr, "\n[%s] --------------------\n",p_module);
}
char *f_supported_system(pvm_config_codec *p_v_codec,pvm_config_codec *p_a_codec)
{
static char *p_buffer="mpeg1audio";
if ((!strcasecmp(p_v_codec->p_codec, "mpeg2enc"))&&(!strcasecmp(p_a_codec->p_codec, "mp2enc")))
return((char *)"mpeg2enc-mp2enc");
else if ((!strcasecmp(p_v_codec->p_codec, "mpeg"))&&(!strcasecmp(p_a_codec->p_codec, "mpeg")))
return((char *)"mpeg-mpeg");
else if ((!strcasecmp(p_v_codec->p_codec, "ffmpeg"))&&(!strcasecmp(p_a_codec->p_codec, "ffmpeg"))&&((!strcasecmp(p_v_codec->p_par1, "mpeg1video"))))
{
p_a_codec->p_par1=p_buffer; /*this isn't defined but useful to known the type of the output stram*/
return((char *)"mpeg-mpeg");
}
else
return((char *)"avi-avi");
return(NULL);
}
int f_supported_export_module(char *p_codec)
{
int s_cont;
for(s_cont=0;p_supported_modules[s_cont]!=NULL;s_cont++)
{
if (!strcasecmp(p_codec,p_supported_modules[s_cont]))
{
return(1);
}
}
return(0);
}
int f_multiplexer(char *p_codec,char *p_merge_cmd,char *p_video_filename,char *p_audio_filename,char *p_dest_file,int s_verbose)
{
char s_buffer[2*MAX_BUF];
if(!strcasecmp(p_codec,"mpeg2enc-mp2enc"))
{
memset(s_buffer,'\0',sizeof(s_buffer));
if (p_merge_cmd!=NULL)
tc_snprintf(s_buffer,sizeof(s_buffer),"%s %s -o %s %s %s",MPEG2ENC_MP2ENC_PROG,p_merge_cmd,p_dest_file,p_video_filename,p_audio_filename);
else
tc_snprintf(s_buffer,sizeof(s_buffer),"%s -o %s %s %s",MPEG2ENC_MP2ENC_PROG,p_dest_file,p_video_filename,p_audio_filename);
if(s_verbose & TC_DEBUG)
fprintf(stderr,"(%s) multiplex cmd: %s\n",__FILE__,s_buffer);
(int)system(s_buffer);
return(0);
}
else if(!strcasecmp(p_codec,"mpeg-mpeg"))
{
memset(s_buffer,'\0',sizeof(s_buffer));
if (p_merge_cmd!=NULL)
tc_snprintf(s_buffer,sizeof(s_buffer),"%s %s -o %s -i %s -p %s",MPEG_MPEG_PROG,p_merge_cmd,p_dest_file,p_video_filename,p_audio_filename);
else
tc_snprintf(s_buffer,sizeof(s_buffer),"%s -o %s -i %s -p %s",MPEG_MPEG_PROG,p_dest_file,p_video_filename,p_audio_filename);
if(s_verbose & TC_DEBUG)
fprintf(stderr,"(%s) multiplex cmd: %s\n",__FILE__,s_buffer);
(int)system(s_buffer);
return(0);
}
else if(!strcasecmp(p_codec,"avi-avi"))
{
memset(s_buffer,'\0',sizeof(s_buffer));
if (p_merge_cmd!=NULL)
tc_snprintf(s_buffer,sizeof(s_buffer),"%s %s -o %s -i %s -p %s",AVI_AVI_PROG,p_merge_cmd,p_dest_file,p_video_filename,p_audio_filename);
else
tc_snprintf(s_buffer,sizeof(s_buffer),"%s -o %s -i %s -p %s",AVI_AVI_PROG,p_dest_file,p_video_filename,p_audio_filename);
if(s_verbose & TC_DEBUG)
fprintf(stderr,"(%s) multiplex cmd: %s\n",__FILE__,s_buffer);
(int)system(s_buffer);
return(0);
}
else
return(1);
}
char *f_external_suffix(char *p_codec,char *p_param)
{
static char *p_suffix[]={".m1v\0",".m2v\0",".mpa\0",".mpeg\0","\0",NULL};
char s_var;
if (p_param!=NULL)
{
if(!strcasecmp(p_codec,"mp2enc"))
{
return(p_suffix[2]);
}
else if((!strcasecmp(p_codec,"mpeg2enc-mp2enc"))||(!strcasecmp(p_codec,"mpeg-mpeg")))
{
return(p_suffix[3]);
}
else if((!strcasecmp(p_codec,"ffmpeg"))&&((!strcasecmp(p_param,"mpeg1video"))))
{
return(p_suffix[0]);
}
else if((!strcasecmp(p_codec,"ffmpeg"))&&((!strcasecmp(p_param,"mpeg1audio"))))
{
return(p_suffix[4]);
}
else if(!strcasecmp(p_codec,"mpeg2enc"))
{
s_var=p_param[0];
if (p_param==NULL) /*det the suffix*/
return(p_suffix[0]);
else if (strchr("1234568", tolower(s_var))==NULL)
return(p_suffix[0]);
else if (strchr("34568",tolower(s_var))!=NULL)
return(p_suffix[1]);
else
return(p_suffix[0]);
}
else if(!strcasecmp(p_codec,"mpeg"))
{
s_var=p_param[0];
if (p_param==NULL) /*det the suffix*/
return(p_suffix[0]);
else if (strchr("1bvs2d", tolower(s_var))==NULL)
return(p_suffix[0]);
else if (strchr("1bv",tolower(s_var))!=NULL)
return(p_suffix[0]);
else
return(p_suffix[1]);
}
}
else
{
if(!strcasecmp(p_codec,"mp2enc"))
{
return(p_suffix[2]);
}
else if(!strcasecmp(p_codec,"mpeg")) /*valid only for audio (no param)*/
{
return(p_suffix[2]);
}
else if((!strcasecmp(p_codec,"mpeg2enc-mp2enc"))||(!strcasecmp(p_codec,"mpeg-mpeg")))
{
return(p_suffix[3]);
}
else
return(p_suffix[4]);
}
return(p_suffix[4]);
}
|