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
a2c0b830
Commit
a2c0b830
authored
Nov 02, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: add -dump_attachment option.
parent
4dbc6cee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
19 deletions
+87
-19
avconv.c
avconv.c
+69
-19
avconv.texi
doc/avconv.texi
+18
-0
No files found.
avconv.c
View file @
a2c0b830
...
...
@@ -275,6 +275,8 @@ typedef struct OptionsContext {
SpecifierOpt
*
ts_scale
;
int
nb_ts_scale
;
SpecifierOpt
*
dump_attachment
;
int
nb_dump_attachment
;
/* output options */
StreamMap
*
stream_maps
;
...
...
@@ -2843,6 +2845,60 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
}
}
static
void
assert_file_overwrite
(
const
char
*
filename
)
{
if
(
!
file_overwrite
&&
(
strchr
(
filename
,
':'
)
==
NULL
||
filename
[
1
]
==
':'
||
av_strstart
(
filename
,
"file:"
,
NULL
)))
{
if
(
avio_check
(
filename
,
0
)
==
0
)
{
if
(
!
using_stdin
)
{
fprintf
(
stderr
,
"File '%s' already exists. Overwrite ? [y/N] "
,
filename
);
fflush
(
stderr
);
if
(
!
read_yesno
())
{
fprintf
(
stderr
,
"Not overwriting - exiting
\n
"
);
exit_program
(
1
);
}
}
else
{
fprintf
(
stderr
,
"File '%s' already exists. Exiting.
\n
"
,
filename
);
exit_program
(
1
);
}
}
}
}
static
void
dump_attachment
(
AVStream
*
st
,
const
char
*
filename
)
{
int
ret
;
AVIOContext
*
out
=
NULL
;
AVDictionaryEntry
*
e
;
if
(
!
st
->
codec
->
extradata_size
)
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"No extradata to dump in stream #%d:%d.
\n
"
,
nb_input_files
-
1
,
st
->
index
);
return
;
}
if
(
!*
filename
&&
(
e
=
av_dict_get
(
st
->
metadata
,
"filename"
,
NULL
,
0
)))
filename
=
e
->
value
;
if
(
!*
filename
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"No filename specified and no 'filename' tag"
"in stream #%d:%d.
\n
"
,
nb_input_files
-
1
,
st
->
index
);
exit_program
(
1
);
}
assert_file_overwrite
(
filename
);
if
((
ret
=
avio_open
(
&
out
,
filename
,
AVIO_FLAG_WRITE
))
<
0
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Could not open file %s for writing.
\n
"
,
filename
);
exit_program
(
1
);
}
avio_write
(
out
,
st
->
codec
->
extradata
,
st
->
codec
->
extradata_size
);
avio_flush
(
out
);
avio_close
(
out
);
}
static
int
opt_input_file
(
OptionsContext
*
o
,
const
char
*
opt
,
const
char
*
filename
)
{
AVFormatContext
*
ic
;
...
...
@@ -2943,6 +2999,17 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena
input_files
[
nb_input_files
-
1
].
nb_streams
=
ic
->
nb_streams
;
input_files
[
nb_input_files
-
1
].
rate_emu
=
o
->
rate_emu
;
for
(
i
=
0
;
i
<
o
->
nb_dump_attachment
;
i
++
)
{
int
j
;
for
(
j
=
0
;
j
<
ic
->
nb_streams
;
j
++
)
{
AVStream
*
st
=
ic
->
streams
[
j
];
if
(
check_stream_specifier
(
ic
,
st
,
o
->
dump_attachment
[
i
].
specifier
)
==
1
)
dump_attachment
(
st
,
o
->
dump_attachment
[
i
].
u
.
str
);
}
}
for
(
i
=
0
;
i
<
orig_nb_streams
;
i
++
)
av_dict_free
(
&
opts
[
i
]);
av_freep
(
&
opts
);
...
...
@@ -3602,25 +3669,7 @@ static void opt_output_file(void *optctx, const char *filename)
if
(
!
(
oc
->
oformat
->
flags
&
AVFMT_NOFILE
))
{
/* test if it already exists to avoid loosing precious files */
if
(
!
file_overwrite
&&
(
strchr
(
filename
,
':'
)
==
NULL
||
filename
[
1
]
==
':'
||
av_strstart
(
filename
,
"file:"
,
NULL
)))
{
if
(
avio_check
(
filename
,
0
)
==
0
)
{
if
(
!
using_stdin
)
{
fprintf
(
stderr
,
"File '%s' already exists. Overwrite ? [y/N] "
,
filename
);
fflush
(
stderr
);
if
(
!
read_yesno
())
{
fprintf
(
stderr
,
"Not overwriting - exiting
\n
"
);
exit_program
(
1
);
}
}
else
{
fprintf
(
stderr
,
"File '%s' already exists. Exiting.
\n
"
,
filename
);
exit_program
(
1
);
}
}
}
assert_file_overwrite
(
filename
);
/* open the file */
if
((
err
=
avio_open
(
&
oc
->
pb
,
filename
,
AVIO_FLAG_WRITE
))
<
0
)
{
...
...
@@ -4086,6 +4135,7 @@ static const OptionDef options[] = {
#endif
{
"stats"
,
OPT_BOOL
,
{
&
print_stats
},
"print progress report during encoding"
,
},
{
"attach"
,
HAS_ARG
|
OPT_FUNC2
,
{(
void
*
)
opt_attach
},
"add an attachment to the output file"
,
"filename"
},
{
"dump_attachment"
,
HAS_ARG
|
OPT_STRING
|
OPT_SPEC
,
{.
off
=
OFFSET
(
dump_attachment
)},
"extract an attachment into a file"
,
"filename"
},
/* video options */
{
"vframes"
,
HAS_ARG
|
OPT_VIDEO
|
OPT_FUNC2
,
{(
void
*
)
opt_video_frames
},
"set the number of video frames to record"
,
"number"
},
...
...
doc/avconv.texi
View file @
a2c0b830
...
...
@@ -207,6 +207,24 @@ avconv -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-true
@end example
(assuming that the attachment stream will be third in the output file).
@item -dump
_
attachment[:@var
{
stream
_
specifier
}
] @var
{
filename
}
(@emph
{
input,per-stream
}
)
Extract the matching attachment stream into a file named @var
{
filename
}
. If
@var
{
filename
}
is empty, then the value of the @code
{
filename
}
metadata tag
will be used.
E.g. to extract the first attachment to a file named 'out.ttf':
@example
avconv -dump
_
attachment:t:0 out.ttf INPUT
@end example
To extract all attachments to files determined by the @code
{
filename
}
tag:
@example
avconv -dump
_
attachment:t "" INPUT
@end example
Technical note -- attachments are implemented as codec extradata, so this
option can actually be used to extract extradata from any stream, not just
attachments.
@end table
@section Video Options
...
...
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