summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-15 00:20:50 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-15 00:20:50 +0000
commit6bc31aecea7dccc9bcdfa4cd05fb7d7a94e80e10 (patch)
treed667b66ef16e65ef9b3ca1ca3cc032545443bdc0
parentafd9de3d713557cfc582ee21efe10f2054e962a2 (diff)
downloadmpv-6bc31aecea7dccc9bcdfa4cd05fb7d7a94e80e10.tar.bz2
mpv-6bc31aecea7dccc9bcdfa4cd05fb7d7a94e80e10.tar.xz
-endpos option, patch by Fredrik Kuivinen <freku045@student.liu.se>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4160 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--cfg-mencoder.h2
-rw-r--r--mencoder.c60
2 files changed, 62 insertions, 0 deletions
diff --git a/cfg-mencoder.h b/cfg-mencoder.h
index 98a31b9a4d..e8d03de58a 100644
--- a/cfg-mencoder.h
+++ b/cfg-mencoder.h
@@ -89,6 +89,8 @@ static config_t mplayer_opts[]={
/* name, pointer, type, flags, min, max */
{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, /* this must be the first!!! */
+ {"endpos", parse_end_at, CONF_TYPE_FUNC_PARAM, 0, 0, 0, NULL},
+
{"ofps", &force_ofps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0, NULL},
{"o", &out_filename, CONF_TYPE_STRING, 0, 0, 0, NULL},
diff --git a/mencoder.c b/mencoder.c
index d01af2f442..d4391b4cd0 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -180,6 +180,8 @@ static int cfg_include(struct config *conf, char *filename){
return m_config_parse_config_file(mconfig, filename);
}
+static int parse_end_at(struct config *conf, const char* param);
+
#include "get_path.c"
#include "cfg-mplayer-def.h"
@@ -305,6 +307,10 @@ int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
static int eof=0;
static int interrupted=0;
+enum end_at_type_t {END_AT_NONE, END_AT_TIME, END_AT_SIZE};
+static enum end_at_type_t end_at_type = END_AT_NONE;
+static int end_at;
+
static void exit_sighandler(int x){
eof=1;
interrupted=1;
@@ -1057,6 +1063,10 @@ while(!eof){
int in_size;
int skip_flag=0; // 1=skip -1=duplicate
+ if((end_at_type == END_AT_SIZE && end_at <= ftell(muxer_f)) ||
+ (end_at_type == END_AT_TIME && end_at < sh_video->timer))
+ break;
+
if(play_n_frames>=0){
--play_n_frames;
if(play_n_frames<0) break;
@@ -1357,3 +1367,53 @@ if(stream) free_stream(stream); // kill cache thread
return interrupted;
}
+
+static int parse_end_at(struct config *conf, const char* param)
+{
+ int i;
+
+ end_at_type = END_AT_NONE;
+
+ /* End at size parsing */
+ {
+ char unit[4];
+
+ end_at_type = END_AT_SIZE;
+
+ if(sscanf(param, "%d%3s", &end_at, unit) == 2) {
+ if(!strcasecmp(unit, "b"))
+ ;
+ else if(!strcasecmp(unit, "kb"))
+ end_at *= 1024;
+ else if(!strcasecmp(unit, "mb"))
+ end_at *= 1024*1024;
+ else
+ end_at_type = END_AT_NONE;
+ }
+ else
+ end_at_type = END_AT_NONE;
+ }
+
+ /* End at time parsing. This has to be last because of
+ * sscanf("%f", ...) below */
+ if(end_at_type == END_AT_NONE)
+ {
+ int a,b; float d;
+
+ end_at_type = END_AT_TIME;
+
+ if (sscanf(param, "%d:%d:%f", &a, &b, &d) == 3)
+ end_at = 3600*a + 60*b + d;
+ else if (sscanf(param, "%d:%f", &a, &d) == 2)
+ end_at = 60*a + d;
+ else if (sscanf(param, "%f", &d) == 1)
+ end_at = d;
+ else
+ end_at_type = END_AT_NONE;
+ }
+
+ if(end_at_type == END_AT_NONE)
+ return ERR_FUNC_ERR;
+
+ return 1;
+}