Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
97e87e09
Commit
97e87e09
authored
Feb 25, 2014
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf: add subfile protocol.
parent
bc6901c9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
2 deletions
+176
-2
Changelog
Changelog
+1
-0
protocols.texi
doc/protocols.texi
+24
-0
Makefile
libavformat/Makefile
+1
-0
allformats.c
libavformat/allformats.c
+1
-0
subfile.c
libavformat/subfile.c
+147
-0
version.h
libavformat/version.h
+2
-2
No files found.
Changelog
View file @
97e87e09
...
@@ -32,6 +32,7 @@ version 2.2:
...
@@ -32,6 +32,7 @@ version 2.2:
- Support DNx444
- Support DNx444
- libx265 encoder
- libx265 encoder
- dejudder filter
- dejudder filter
- subfile protocol
version 2.1:
version 2.1:
...
...
doc/protocols.texi
View file @
97e87e09
...
@@ -951,6 +951,30 @@ this binary block are used as master key, the following 14 bytes are
...
@@ -951,6 +951,30 @@ this binary block are used as master key, the following 14 bytes are
used as master salt.
used as master salt.
@end table
@end table
@section subfile
Virtually extract a segment of a file or another stream.
The underlying stream must be seekable.
Accepted options:
@table @option
@item start
Start offset of the extracted segment, in bytes.
@item end
End offset of the extracted segment, in bytes.
@end table
Examples:
Extract a chapter from a DVD VOB file (start and end sectors obtained
externally and multiplied by 2048):
@example
subfile,,start,153391104,end,268142592,,:/media/dvd/VIDEO_TS/VTS_08_1.VOB
@end example
Play an AVI file directly from a TAR archive:
subfile,,start,183241728,end,366490624,,:archive.tar
@section tcp
@section tcp
Transmission Control Protocol.
Transmission Control Protocol.
...
...
libavformat/Makefile
View file @
97e87e09
...
@@ -464,6 +464,7 @@ OBJS-$(CONFIG_RTMPTS_PROTOCOL) += rtmpproto.o rtmppkt.o
...
@@ -464,6 +464,7 @@ OBJS-$(CONFIG_RTMPTS_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTP_PROTOCOL)
+=
rtpproto.o
OBJS-$(CONFIG_RTP_PROTOCOL)
+=
rtpproto.o
OBJS-$(CONFIG_SCTP_PROTOCOL)
+=
sctp.o
OBJS-$(CONFIG_SCTP_PROTOCOL)
+=
sctp.o
OBJS-$(CONFIG_SRTP_PROTOCOL)
+=
srtpproto.o
srtp.o
OBJS-$(CONFIG_SRTP_PROTOCOL)
+=
srtpproto.o
srtp.o
OBJS-$(CONFIG_SUBFILE_PROTOCOL)
+=
subfile.o
OBJS-$(CONFIG_TCP_PROTOCOL)
+=
tcp.o
OBJS-$(CONFIG_TCP_PROTOCOL)
+=
tcp.o
OBJS-$(CONFIG_TLS_PROTOCOL)
+=
tls.o
OBJS-$(CONFIG_TLS_PROTOCOL)
+=
tls.o
OBJS-$(CONFIG_UDP_PROTOCOL)
+=
udp.o
OBJS-$(CONFIG_UDP_PROTOCOL)
+=
udp.o
...
...
libavformat/allformats.c
View file @
97e87e09
...
@@ -338,6 +338,7 @@ void av_register_all(void)
...
@@ -338,6 +338,7 @@ void av_register_all(void)
REGISTER_PROTOCOL
(
RTP
,
rtp
);
REGISTER_PROTOCOL
(
RTP
,
rtp
);
REGISTER_PROTOCOL
(
SCTP
,
sctp
);
REGISTER_PROTOCOL
(
SCTP
,
sctp
);
REGISTER_PROTOCOL
(
SRTP
,
srtp
);
REGISTER_PROTOCOL
(
SRTP
,
srtp
);
REGISTER_PROTOCOL
(
SUBFILE
,
subfile
);
REGISTER_PROTOCOL
(
TCP
,
tcp
);
REGISTER_PROTOCOL
(
TCP
,
tcp
);
REGISTER_PROTOCOL
(
TLS
,
tls
);
REGISTER_PROTOCOL
(
TLS
,
tls
);
REGISTER_PROTOCOL
(
UDP
,
udp
);
REGISTER_PROTOCOL
(
UDP
,
udp
);
...
...
libavformat/subfile.c
0 → 100644
View file @
97e87e09
/*
* Copyright (c) 2014 Nicolas George
*
* This file is part of FFmpeg.
*
* FFmpeg 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.1 of the License, or (at your option) any later version.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "url.h"
typedef
struct
SubfileContext
{
const
AVClass
*
class
;
URLContext
*
h
;
int64_t
start
;
int64_t
end
;
int64_t
pos
;
}
SubfileContext
;
#define OFFSET(field) offsetof(SubfileContext, field)
#define D AV_OPT_FLAG_DECODING_PARAM
static
const
AVOption
subfile_options
[]
=
{
{
"start"
,
"start offset"
,
OFFSET
(
start
),
AV_OPT_TYPE_INT64
,
{.
i64
=
0
},
0
,
INT64_MAX
,
D
},
{
"end"
,
"end offset"
,
OFFSET
(
end
),
AV_OPT_TYPE_INT64
,
{.
i64
=
0
},
0
,
INT64_MAX
,
D
},
{
NULL
}
};
#undef OFFSET
#undef D
static
const
AVClass
subfile_class
=
{
.
class_name
=
"subfile"
,
.
item_name
=
av_default_item_name
,
.
option
=
subfile_options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
int
slave_seek
(
URLContext
*
h
)
{
SubfileContext
*
c
=
h
->
priv_data
;
int64_t
ret
;
if
((
ret
=
ffurl_seek
(
c
->
h
,
c
->
pos
,
SEEK_SET
))
!=
c
->
pos
)
{
if
(
ret
>=
0
)
ret
=
AVERROR_BUG
;
av_log
(
h
,
AV_LOG_ERROR
,
"Impossible to seek in file: %s
\n
"
,
av_err2str
(
ret
));
return
ret
;
}
return
0
;
}
static
int
subfile_open
(
URLContext
*
h
,
const
char
*
filename
,
int
flags
,
AVDictionary
**
options
)
{
SubfileContext
*
c
=
h
->
priv_data
;
int
ret
;
if
(
c
->
end
<=
c
->
start
)
{
av_log
(
h
,
AV_LOG_ERROR
,
"end before start
\n
"
);
return
AVERROR
(
EINVAL
);
}
av_strstart
(
filename
,
"subfile:"
,
&
filename
);
ret
=
ffurl_open
(
&
c
->
h
,
filename
,
flags
,
&
h
->
interrupt_callback
,
options
);
if
(
ret
<
0
)
return
ret
;
c
->
pos
=
c
->
start
;
if
((
ret
=
slave_seek
(
h
))
<
0
)
{
ffurl_close
(
c
->
h
);
return
ret
;
}
return
0
;
}
static
int
subfile_close
(
URLContext
*
h
)
{
SubfileContext
*
c
=
h
->
priv_data
;
return
ffurl_close
(
c
->
h
);
}
static
int
subfile_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
{
SubfileContext
*
c
=
h
->
priv_data
;
int64_t
rest
=
c
->
end
-
c
->
pos
;
int
ret
;
if
(
rest
<=
0
)
return
0
;
size
=
FFMIN
(
size
,
rest
);
ret
=
ffurl_read
(
c
->
h
,
buf
,
size
);
if
(
ret
>=
0
)
c
->
pos
+=
ret
;
return
ret
;
}
static
int64_t
subfile_seek
(
URLContext
*
h
,
int64_t
pos
,
int
whence
)
{
SubfileContext
*
c
=
h
->
priv_data
;
int64_t
new_pos
=
-
1
;
int
ret
;
if
(
whence
==
AVSEEK_SIZE
)
return
c
->
end
-
c
->
start
;
switch
(
whence
)
{
case
SEEK_SET
:
new_pos
=
c
->
start
+
pos
;
break
;
case
SEEK_CUR
:
new_pos
+=
pos
;
break
;
case
SEEK_END
:
new_pos
=
c
->
end
+
c
->
pos
;
break
;
}
if
(
new_pos
<
c
->
start
)
return
AVERROR
(
EINVAL
);
c
->
pos
=
new_pos
;
if
((
ret
=
slave_seek
(
h
))
<
0
)
return
ret
;
return
c
->
pos
-
c
->
start
;
}
URLProtocol
ff_subfile_protocol
=
{
.
name
=
"subfile"
,
.
url_open2
=
subfile_open
,
.
url_read
=
subfile_read
,
.
url_seek
=
subfile_seek
,
.
url_close
=
subfile_close
,
.
priv_data_size
=
sizeof
(
SubfileContext
),
.
priv_data_class
=
&
subfile_class
,
};
libavformat/version.h
View file @
97e87e09
...
@@ -30,8 +30,8 @@
...
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 3
3
#define LIBAVFORMAT_VERSION_MINOR 3
4
#define LIBAVFORMAT_VERSION_MICRO 10
1
#define LIBAVFORMAT_VERSION_MICRO 10
0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
LIBAVFORMAT_VERSION_MINOR, \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment