* qatar/master:
movenc: change AV_LOG_INFO to AV_LOG_WARNING for some warnings
avconv: remove a write-only variable
avconv: remove pointless parameter from new_*_stream().
avconv: cosmetics, move code
avconv: cosmetics -- move copy_chapters().
avconv: cosmetics -- move parse_forced_key_frames().
lavc: add audio flag to the 'b' option, deprecate 'ab'.
avconv: rename sameq to same_quant
doc/avconv: add forgotten end of chapter.
Changelog: document avconv incompatibilities with ffmpeg.
avconv: replace -vcodec/-acodec/-scodec with a better system.
avconv: remove presets.
svq3: propagate codec memory allocation failure in context init
Conflicts:
Changelog
avconv.c
libavcodec/options.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -8,6 +8,39 @@ version next: |
8 | 8 |
- BWF muxer |
9 | 9 |
- Flash Screen Video 2 decoder |
10 | 10 |
- lavfi input device added |
11 |
+- added avconv, which is almost the same for now, except |
|
12 |
+for a few incompatible changes in the options, which will hopefully make them |
|
13 |
+easier to use. The changes are: |
|
14 |
+ * -newvideo/-newaudio/-newsubtitle are gone, because they were redundant and |
|
15 |
+ worked in a nonstandard way. -map is sufficient to add streams to output |
|
16 |
+ files. |
|
17 |
+ * -map now has slightly different and more powerful syntax. |
|
18 |
+ + it's possible to specify stream type. E.g. -map 0:a:2 means 'third |
|
19 |
+ audio stream'. |
|
20 |
+ + omitting the stream index now maps all the streams of the given |
|
21 |
+ type, not just the first. E.g. -map 0:s maps all the subtitle streams. |
|
22 |
+ + colons (':') are used to separate file index/stream type/stream |
|
23 |
+ index. Comma (',') is used to separate the sync stream. This is done |
|
24 |
+ for consistency with other options. |
|
25 |
+ + since -map can now match multiple streams, negative mappings were |
|
26 |
+ introduced. Negative mappings disable some streams from an already |
|
27 |
+ defined map. E.g. '-map 0 -map -0:a:1' means 'map everything except |
|
28 |
+ for the second audio stream'. |
|
29 |
+ * -vcodec/-acodec/-scodec are replaced by -c (or -codec), which |
|
30 |
+ allows to precisely specify target stream(s) consistently with other |
|
31 |
+ options. E.g. '-c:v libx264' sets the codec for all video streams, |
|
32 |
+ '-c:a:0 libvorbis' sets the codec for the first audio stream and '-c |
|
33 |
+ copy' copies all the streams. |
|
34 |
+ * It is now possible to precisely specify which stream should an AVOption |
|
35 |
+ apply to. See the manual for detailed explanation. |
|
36 |
+ * -map_chapters now takes only an input file index and applies to the next |
|
37 |
+ output file. This is consistent with how all the other options work. |
|
38 |
+ * -map_metadata now takes only an input metadata specifier and applies to |
|
39 |
+ the next output file. Output metadata specifier is now part of the option |
|
40 |
+ name, similarly to the AVOptions/map/codec feature above. |
|
41 |
+ * Presets in avconv are disabled, because only libx264 used them and |
|
42 |
+ presets for libx264 can now be specified using a private option |
|
43 |
+ '-preset <presetname>'. |
|
11 | 44 |
|
12 | 45 |
|
13 | 46 |
version 0.8: |
... | ... |
@@ -122,6 +122,8 @@ static int nb_output_files = 0; |
122 | 122 |
static StreamMap *stream_maps = NULL; |
123 | 123 |
static int nb_stream_maps; |
124 | 124 |
|
125 |
+static AVDictionary *codec_names; |
|
126 |
+ |
|
125 | 127 |
/* first item specifies output metadata, second is input */ |
126 | 128 |
static MetadataMap (*meta_data_maps)[2] = NULL; |
127 | 129 |
static int nb_meta_data_maps; |
... | ... |
@@ -149,10 +151,9 @@ static uint16_t *inter_matrix = NULL; |
149 | 149 |
static const char *video_rc_override_string=NULL; |
150 | 150 |
static int video_disable = 0; |
151 | 151 |
static int video_discard = 0; |
152 |
-static char *video_codec_name = NULL; |
|
153 | 152 |
static unsigned int video_codec_tag = 0; |
154 | 153 |
static char *video_language = NULL; |
155 |
-static int same_quality = 0; |
|
154 |
+static int same_quant = 0; |
|
156 | 155 |
static int do_deinterlace = 0; |
157 | 156 |
static int top_field_first = -1; |
158 | 157 |
static int me_threshold = 0; |
... | ... |
@@ -168,17 +169,14 @@ static int audio_sample_rate = 0; |
168 | 168 |
static float audio_qscale = QSCALE_NONE; |
169 | 169 |
static int audio_disable = 0; |
170 | 170 |
static int audio_channels = 0; |
171 |
-static char *audio_codec_name = NULL; |
|
172 | 171 |
static unsigned int audio_codec_tag = 0; |
173 | 172 |
static char *audio_language = NULL; |
174 | 173 |
|
175 | 174 |
static int subtitle_disable = 0; |
176 |
-static char *subtitle_codec_name = NULL; |
|
177 | 175 |
static char *subtitle_language = NULL; |
178 | 176 |
static unsigned int subtitle_codec_tag = 0; |
179 | 177 |
|
180 | 178 |
static int data_disable = 0; |
181 |
-static char *data_codec_name = NULL; |
|
182 | 179 |
static unsigned int data_codec_tag = 0; |
183 | 180 |
|
184 | 181 |
static float mux_preload= 0.5; |
... | ... |
@@ -195,10 +193,6 @@ static int do_pkt_dump = 0; |
195 | 195 |
static int do_psnr = 0; |
196 | 196 |
static int do_pass = 0; |
197 | 197 |
static const char *pass_logfilename_prefix; |
198 |
-static int audio_stream_copy = 0; |
|
199 |
-static int video_stream_copy = 0; |
|
200 |
-static int subtitle_stream_copy = 0; |
|
201 |
-static int data_stream_copy = 0; |
|
202 | 198 |
static int video_sync_method= -1; |
203 | 199 |
static int audio_sync_method= 0; |
204 | 200 |
static float audio_drift_threshold= 0.1; |
... | ... |
@@ -548,11 +542,6 @@ static int exit_program(int ret) |
548 | 548 |
av_freep(&input_streams); |
549 | 549 |
av_freep(&input_files); |
550 | 550 |
|
551 |
- av_free(video_codec_name); |
|
552 |
- av_free(audio_codec_name); |
|
553 |
- av_free(subtitle_codec_name); |
|
554 |
- av_free(data_codec_name); |
|
555 |
- |
|
556 | 551 |
uninit_opts(); |
557 | 552 |
av_free(audio_buf); |
558 | 553 |
av_free(audio_out); |
... | ... |
@@ -689,88 +678,6 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) |
689 | 689 |
} |
690 | 690 |
} |
691 | 691 |
|
692 |
-static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCodec *codec) |
|
693 |
-{ |
|
694 |
- OutputStream *ost; |
|
695 |
- AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); |
|
696 |
- int idx = oc->nb_streams - 1; |
|
697 |
- |
|
698 |
- if (!st) { |
|
699 |
- av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n"); |
|
700 |
- exit_program(1); |
|
701 |
- } |
|
702 |
- |
|
703 |
- output_streams_for_file[file_idx] = |
|
704 |
- grow_array(output_streams_for_file[file_idx], |
|
705 |
- sizeof(*output_streams_for_file[file_idx]), |
|
706 |
- &nb_output_streams_for_file[file_idx], |
|
707 |
- oc->nb_streams); |
|
708 |
- ost = output_streams_for_file[file_idx][idx] = |
|
709 |
- av_mallocz(sizeof(OutputStream)); |
|
710 |
- if (!ost) { |
|
711 |
- fprintf(stderr, "Could not alloc output stream\n"); |
|
712 |
- exit_program(1); |
|
713 |
- } |
|
714 |
- ost->file_index = file_idx; |
|
715 |
- ost->index = idx; |
|
716 |
- ost->st = st; |
|
717 |
- ost->enc = codec; |
|
718 |
- if (codec) { |
|
719 |
- st->codec->codec_type = codec->type; |
|
720 |
- ost->opts = filter_codec_opts(codec_opts, codec->id, oc, st); |
|
721 |
- } |
|
722 |
- |
|
723 |
- avcodec_get_context_defaults3(st->codec, codec); |
|
724 |
- |
|
725 |
- ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); |
|
726 |
- return ost; |
|
727 |
-} |
|
728 |
- |
|
729 |
-static int read_ffserver_streams(AVFormatContext *s, const char *filename) |
|
730 |
-{ |
|
731 |
- int i, err; |
|
732 |
- AVFormatContext *ic = NULL; |
|
733 |
- int nopts = 0; |
|
734 |
- |
|
735 |
- err = avformat_open_input(&ic, filename, NULL, NULL); |
|
736 |
- if (err < 0) |
|
737 |
- return err; |
|
738 |
- /* copy stream format */ |
|
739 |
- for(i=0;i<ic->nb_streams;i++) { |
|
740 |
- AVStream *st; |
|
741 |
- OutputStream *ost; |
|
742 |
- AVCodec *codec; |
|
743 |
- |
|
744 |
- codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); |
|
745 |
- ost = new_output_stream(s, nb_output_files, codec); |
|
746 |
- st = ost->st; |
|
747 |
- |
|
748 |
- // FIXME: a more elegant solution is needed |
|
749 |
- memcpy(st, ic->streams[i], sizeof(AVStream)); |
|
750 |
- st->info = av_malloc(sizeof(*st->info)); |
|
751 |
- memcpy(st->info, ic->streams[i]->info, sizeof(*st->info)); |
|
752 |
- avcodec_copy_context(st->codec, ic->streams[i]->codec); |
|
753 |
- |
|
754 |
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
|
755 |
- if (audio_stream_copy) { |
|
756 |
- st->stream_copy = 1; |
|
757 |
- } else |
|
758 |
- choose_sample_fmt(st, codec); |
|
759 |
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { |
|
760 |
- if (video_stream_copy) { |
|
761 |
- st->stream_copy = 1; |
|
762 |
- } else |
|
763 |
- choose_pixel_fmt(st, codec); |
|
764 |
- } |
|
765 |
- |
|
766 |
- if(st->codec->flags & CODEC_FLAG_BITEXACT) |
|
767 |
- nopts = 1; |
|
768 |
- } |
|
769 |
- |
|
770 |
- av_close_input_file(ic); |
|
771 |
- return 0; |
|
772 |
-} |
|
773 |
- |
|
774 | 692 |
static double |
775 | 693 |
get_sync_ipts(const OutputStream *ost) |
776 | 694 |
{ |
... | ... |
@@ -1310,7 +1217,7 @@ static void do_video_out(AVFormatContext *s, |
1310 | 1310 |
big_picture.top_field_first = top_field_first; |
1311 | 1311 |
} |
1312 | 1312 |
|
1313 |
- /* handles sameq here. This is not correct because it may |
|
1313 |
+ /* handles same_quant here. This is not correct because it may |
|
1314 | 1314 |
not be a global option */ |
1315 | 1315 |
big_picture.quality = quality; |
1316 | 1316 |
if(!me_threshold) |
... | ... |
@@ -1637,7 +1544,7 @@ static int output_packet(InputStream *ist, int ist_index, |
1637 | 1637 |
|
1638 | 1638 |
ret = avcodec_decode_video2(ist->st->codec, |
1639 | 1639 |
&picture, &got_output, &avpkt); |
1640 |
- quality = same_quality ? picture.quality : 0; |
|
1640 |
+ quality = same_quant ? picture.quality : 0; |
|
1641 | 1641 |
if (ret < 0) |
1642 | 1642 |
return ret; |
1643 | 1643 |
if (!got_output) { |
... | ... |
@@ -1764,7 +1671,7 @@ static int output_packet(InputStream *ist, int ist_index, |
1764 | 1764 |
ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio; |
1765 | 1765 |
#endif |
1766 | 1766 |
do_video_out(os, ost, ist, &picture, &frame_size, |
1767 |
- same_quality ? quality : ost->st->codec->global_quality); |
|
1767 |
+ same_quant ? quality : ost->st->codec->global_quality); |
|
1768 | 1768 |
if (vstats_filename && frame_size) |
1769 | 1769 |
do_video_stats(os, ost, frame_size); |
1770 | 1770 |
break; |
... | ... |
@@ -1958,69 +1865,6 @@ static void print_sdp(AVFormatContext **avc, int n) |
1958 | 1958 |
fflush(stdout); |
1959 | 1959 |
} |
1960 | 1960 |
|
1961 |
-static int copy_chapters(int infile, int outfile) |
|
1962 |
-{ |
|
1963 |
- AVFormatContext *is = input_files[infile].ctx; |
|
1964 |
- AVFormatContext *os = output_files[outfile]; |
|
1965 |
- int i; |
|
1966 |
- |
|
1967 |
- for (i = 0; i < is->nb_chapters; i++) { |
|
1968 |
- AVChapter *in_ch = is->chapters[i], *out_ch; |
|
1969 |
- int64_t ts_off = av_rescale_q(start_time - input_files[infile].ts_offset, |
|
1970 |
- AV_TIME_BASE_Q, in_ch->time_base); |
|
1971 |
- int64_t rt = (recording_time == INT64_MAX) ? INT64_MAX : |
|
1972 |
- av_rescale_q(recording_time, AV_TIME_BASE_Q, in_ch->time_base); |
|
1973 |
- |
|
1974 |
- |
|
1975 |
- if (in_ch->end < ts_off) |
|
1976 |
- continue; |
|
1977 |
- if (rt != INT64_MAX && in_ch->start > rt + ts_off) |
|
1978 |
- break; |
|
1979 |
- |
|
1980 |
- out_ch = av_mallocz(sizeof(AVChapter)); |
|
1981 |
- if (!out_ch) |
|
1982 |
- return AVERROR(ENOMEM); |
|
1983 |
- |
|
1984 |
- out_ch->id = in_ch->id; |
|
1985 |
- out_ch->time_base = in_ch->time_base; |
|
1986 |
- out_ch->start = FFMAX(0, in_ch->start - ts_off); |
|
1987 |
- out_ch->end = FFMIN(rt, in_ch->end - ts_off); |
|
1988 |
- |
|
1989 |
- if (metadata_chapters_autocopy) |
|
1990 |
- av_dict_copy(&out_ch->metadata, in_ch->metadata, 0); |
|
1991 |
- |
|
1992 |
- os->nb_chapters++; |
|
1993 |
- os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters); |
|
1994 |
- if (!os->chapters) |
|
1995 |
- return AVERROR(ENOMEM); |
|
1996 |
- os->chapters[os->nb_chapters - 1] = out_ch; |
|
1997 |
- } |
|
1998 |
- return 0; |
|
1999 |
-} |
|
2000 |
- |
|
2001 |
-static void parse_forced_key_frames(char *kf, OutputStream *ost, |
|
2002 |
- AVCodecContext *avctx) |
|
2003 |
-{ |
|
2004 |
- char *p; |
|
2005 |
- int n = 1, i; |
|
2006 |
- int64_t t; |
|
2007 |
- |
|
2008 |
- for (p = kf; *p; p++) |
|
2009 |
- if (*p == ',') |
|
2010 |
- n++; |
|
2011 |
- ost->forced_kf_count = n; |
|
2012 |
- ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n); |
|
2013 |
- if (!ost->forced_kf_pts) { |
|
2014 |
- av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n"); |
|
2015 |
- exit_program(1); |
|
2016 |
- } |
|
2017 |
- for (i = 0; i < n; i++) { |
|
2018 |
- p = i ? strchr(p, ',') + 1 : kf; |
|
2019 |
- t = parse_time_or_die("force_key_frames", p, 1); |
|
2020 |
- ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base); |
|
2021 |
- } |
|
2022 |
-} |
|
2023 |
- |
|
2024 | 1961 |
/* |
2025 | 1962 |
* The following code is the main loop of the file converter |
2026 | 1963 |
*/ |
... | ... |
@@ -2892,20 +2736,27 @@ static int opt_audio_channels(const char *opt, const char *arg) |
2892 | 2892 |
|
2893 | 2893 |
static int opt_codec(const char *opt, const char *arg) |
2894 | 2894 |
{ |
2895 |
- int *pstream_copy; char **pcodec_name; enum AVMediaType codec_type; |
|
2895 |
+ return av_dict_set(&codec_names, opt, arg, 0); |
|
2896 |
+} |
|
2896 | 2897 |
|
2897 |
- if (!strcmp(opt, "acodec")) { pstream_copy = &audio_stream_copy; pcodec_name = &audio_codec_name; codec_type = AVMEDIA_TYPE_AUDIO; } |
|
2898 |
- else if (!strcmp(opt, "vcodec")) { pstream_copy = &video_stream_copy; pcodec_name = &video_codec_name; codec_type = AVMEDIA_TYPE_VIDEO; } |
|
2899 |
- else if (!strcmp(opt, "scodec")) { pstream_copy = &subtitle_stream_copy; pcodec_name = &subtitle_codec_name; codec_type = AVMEDIA_TYPE_SUBTITLE; } |
|
2900 |
- else if (!strcmp(opt, "dcodec")) { pstream_copy = &data_stream_copy; pcodec_name = &data_codec_name; codec_type = AVMEDIA_TYPE_DATA; } |
|
2898 |
+static int opt_audio_codec(const char *opt, const char *arg) |
|
2899 |
+{ |
|
2900 |
+ return opt_codec("codec:a", arg); |
|
2901 |
+} |
|
2901 | 2902 |
|
2902 |
- av_freep(pcodec_name); |
|
2903 |
- if (!strcmp(arg, "copy")) { |
|
2904 |
- *pstream_copy = 1; |
|
2905 |
- } else { |
|
2906 |
- *pcodec_name = av_strdup(arg); |
|
2907 |
- } |
|
2908 |
- return 0; |
|
2903 |
+static int opt_video_codec(const char *opt, const char *arg) |
|
2904 |
+{ |
|
2905 |
+ return opt_codec("codec:v", arg); |
|
2906 |
+} |
|
2907 |
+ |
|
2908 |
+static int opt_subtitle_codec(const char *opt, const char *arg) |
|
2909 |
+{ |
|
2910 |
+ return opt_codec("codec:s", arg); |
|
2911 |
+} |
|
2912 |
+ |
|
2913 |
+static int opt_data_codec(const char *opt, const char *arg) |
|
2914 |
+{ |
|
2915 |
+ return opt_codec("codec:d", arg); |
|
2909 | 2916 |
} |
2910 | 2917 |
|
2911 | 2918 |
static int opt_codec_tag(const char *opt, const char *arg) |
... | ... |
@@ -3093,7 +2944,7 @@ static int opt_input_ts_offset(const char *opt, const char *arg) |
3093 | 3093 |
return 0; |
3094 | 3094 |
} |
3095 | 3095 |
|
3096 |
-static enum CodecID find_codec_or_die(const char *name, int type, int encoder) |
|
3096 |
+static enum CodecID find_codec_or_die(const char *name, enum AVMediaType type, int encoder) |
|
3097 | 3097 |
{ |
3098 | 3098 |
const char *codec_string = encoder ? "encoder" : "decoder"; |
3099 | 3099 |
AVCodec *codec; |
... | ... |
@@ -3104,16 +2955,47 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder) |
3104 | 3104 |
avcodec_find_encoder_by_name(name) : |
3105 | 3105 |
avcodec_find_decoder_by_name(name); |
3106 | 3106 |
if(!codec) { |
3107 |
- fprintf(stderr, "Unknown %s '%s'\n", codec_string, name); |
|
3107 |
+ av_log(NULL, AV_LOG_ERROR, "Unknown %s '%s'\n", codec_string, name); |
|
3108 | 3108 |
exit_program(1); |
3109 | 3109 |
} |
3110 | 3110 |
if(codec->type != type) { |
3111 |
- fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name); |
|
3111 |
+ av_log(NULL, AV_LOG_ERROR, "Invalid %s type '%s'\n", codec_string, name); |
|
3112 | 3112 |
exit_program(1); |
3113 | 3113 |
} |
3114 | 3114 |
return codec->id; |
3115 | 3115 |
} |
3116 | 3116 |
|
3117 |
+static AVCodec *choose_codec(AVFormatContext *s, AVStream *st, enum AVMediaType type, AVDictionary *codec_names) |
|
3118 |
+{ |
|
3119 |
+ AVDictionaryEntry *e = NULL; |
|
3120 |
+ char *codec_name = NULL; |
|
3121 |
+ int ret; |
|
3122 |
+ |
|
3123 |
+ while (e = av_dict_get(codec_names, "", e, AV_DICT_IGNORE_SUFFIX)) { |
|
3124 |
+ char *p = strchr(e->key, ':'); |
|
3125 |
+ |
|
3126 |
+ if ((ret = check_stream_specifier(s, st, p ? p + 1 : "")) > 0) |
|
3127 |
+ codec_name = e->value; |
|
3128 |
+ else if (ret < 0) |
|
3129 |
+ exit_program(1); |
|
3130 |
+ } |
|
3131 |
+ |
|
3132 |
+ if (!codec_name) { |
|
3133 |
+ if (s->oformat) { |
|
3134 |
+ st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, NULL, type); |
|
3135 |
+ return avcodec_find_encoder(st->codec->codec_id); |
|
3136 |
+ } |
|
3137 |
+ } else if (!strcmp(codec_name, "copy")) |
|
3138 |
+ st->stream_copy = 1; |
|
3139 |
+ else { |
|
3140 |
+ st->codec->codec_id = find_codec_or_die(codec_name, type, s->iformat == NULL); |
|
3141 |
+ return s->oformat ? avcodec_find_encoder_by_name(codec_name) : |
|
3142 |
+ avcodec_find_decoder_by_name(codec_name); |
|
3143 |
+ } |
|
3144 |
+ |
|
3145 |
+ return NULL; |
|
3146 |
+} |
|
3147 |
+ |
|
3117 | 3148 |
static int opt_input_file(const char *opt, const char *filename) |
3118 | 3149 |
{ |
3119 | 3150 |
AVFormatContext *ic; |
... | ... |
@@ -3163,12 +3045,6 @@ static int opt_input_file(const char *opt, const char *filename) |
3163 | 3163 |
if (frame_pix_fmt != PIX_FMT_NONE) |
3164 | 3164 |
av_dict_set(&format_opts, "pixel_format", av_get_pix_fmt_name(frame_pix_fmt), 0); |
3165 | 3165 |
|
3166 |
- ic->video_codec_id = |
|
3167 |
- find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0); |
|
3168 |
- ic->audio_codec_id = |
|
3169 |
- find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0); |
|
3170 |
- ic->subtitle_codec_id= |
|
3171 |
- find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0); |
|
3172 | 3166 |
ic->flags |= AVFMT_FLAG_NONBLOCK; |
3173 | 3167 |
|
3174 | 3168 |
/* open the input file with generic libav function */ |
... | ... |
@@ -3203,6 +3079,10 @@ static int opt_input_file(const char *opt, const char *filename) |
3203 | 3203 |
opt_programid=0; |
3204 | 3204 |
} |
3205 | 3205 |
|
3206 |
+ /* apply forced codec ids */ |
|
3207 |
+ for (i = 0; i < ic->nb_streams; i++) |
|
3208 |
+ choose_codec(ic, ic->streams[i], ic->streams[i]->codec->codec_type, codec_names); |
|
3209 |
+ |
|
3206 | 3210 |
/* Set AVCodecContext options for avformat_find_stream_info */ |
3207 | 3211 |
opts = setup_find_stream_info_opts(ic, codec_opts); |
3208 | 3212 |
orig_nb_streams = ic->nb_streams; |
... | ... |
@@ -3250,16 +3130,16 @@ static int opt_input_file(const char *opt, const char *filename) |
3250 | 3250 |
if (i < nb_ts_scale) |
3251 | 3251 |
ist->ts_scale = ts_scale[i]; |
3252 | 3252 |
|
3253 |
+ ist->dec = choose_codec(ic, st, dec->codec_type, codec_names); |
|
3254 |
+ |
|
3253 | 3255 |
switch (dec->codec_type) { |
3254 | 3256 |
case AVMEDIA_TYPE_AUDIO: |
3255 |
- ist->dec = avcodec_find_decoder_by_name(audio_codec_name); |
|
3256 | 3257 |
if(!ist->dec) |
3257 | 3258 |
ist->dec = avcodec_find_decoder(dec->codec_id); |
3258 | 3259 |
if(audio_disable) |
3259 | 3260 |
st->discard= AVDISCARD_ALL; |
3260 | 3261 |
break; |
3261 | 3262 |
case AVMEDIA_TYPE_VIDEO: |
3262 |
- ist->dec= avcodec_find_decoder_by_name(video_codec_name); |
|
3263 | 3263 |
if(!ist->dec) |
3264 | 3264 |
ist->dec = avcodec_find_decoder(dec->codec_id); |
3265 | 3265 |
rfps = ic->streams[i]->r_frame_rate.num; |
... | ... |
@@ -3287,7 +3167,6 @@ static int opt_input_file(const char *opt, const char *filename) |
3287 | 3287 |
case AVMEDIA_TYPE_DATA: |
3288 | 3288 |
break; |
3289 | 3289 |
case AVMEDIA_TYPE_SUBTITLE: |
3290 |
- ist->dec = avcodec_find_decoder_by_name(subtitle_codec_name); |
|
3291 | 3290 |
if(!ist->dec) |
3292 | 3291 |
ist->dec = avcodec_find_decoder(dec->codec_id); |
3293 | 3292 |
if(subtitle_disable) |
... | ... |
@@ -3325,35 +3204,82 @@ static int opt_input_file(const char *opt, const char *filename) |
3325 | 3325 |
for (i = 0; i < orig_nb_streams; i++) |
3326 | 3326 |
av_dict_free(&opts[i]); |
3327 | 3327 |
av_freep(&opts); |
3328 |
- av_freep(&video_codec_name); |
|
3329 |
- av_freep(&audio_codec_name); |
|
3330 |
- av_freep(&subtitle_codec_name); |
|
3328 |
+ av_dict_free(&codec_names); |
|
3331 | 3329 |
uninit_opts(); |
3332 | 3330 |
init_opts(); |
3333 | 3331 |
return 0; |
3334 | 3332 |
} |
3335 | 3333 |
|
3336 |
-static OutputStream *new_video_stream(AVFormatContext *oc, int file_idx) |
|
3334 |
+static void parse_forced_key_frames(char *kf, OutputStream *ost, |
|
3335 |
+ AVCodecContext *avctx) |
|
3336 |
+{ |
|
3337 |
+ char *p; |
|
3338 |
+ int n = 1, i; |
|
3339 |
+ int64_t t; |
|
3340 |
+ |
|
3341 |
+ for (p = kf; *p; p++) |
|
3342 |
+ if (*p == ',') |
|
3343 |
+ n++; |
|
3344 |
+ ost->forced_kf_count = n; |
|
3345 |
+ ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n); |
|
3346 |
+ if (!ost->forced_kf_pts) { |
|
3347 |
+ av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n"); |
|
3348 |
+ exit_program(1); |
|
3349 |
+ } |
|
3350 |
+ for (i = 0; i < n; i++) { |
|
3351 |
+ p = i ? strchr(p, ',') + 1 : kf; |
|
3352 |
+ t = parse_time_or_die("force_key_frames", p, 1); |
|
3353 |
+ ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base); |
|
3354 |
+ } |
|
3355 |
+} |
|
3356 |
+ |
|
3357 |
+static OutputStream *new_output_stream(AVFormatContext *oc, enum AVMediaType type) |
|
3337 | 3358 |
{ |
3338 |
- AVStream *st; |
|
3339 | 3359 |
OutputStream *ost; |
3340 |
- AVCodecContext *video_enc; |
|
3341 |
- enum CodecID codec_id = CODEC_ID_NONE; |
|
3342 |
- AVCodec *codec= NULL; |
|
3360 |
+ AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); |
|
3361 |
+ int idx = oc->nb_streams - 1; |
|
3343 | 3362 |
|
3344 |
- if(!video_stream_copy){ |
|
3345 |
- if (video_codec_name) { |
|
3346 |
- codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1); |
|
3347 |
- codec = avcodec_find_encoder_by_name(video_codec_name); |
|
3348 |
- } else { |
|
3349 |
- codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); |
|
3350 |
- codec = avcodec_find_encoder(codec_id); |
|
3351 |
- } |
|
3363 |
+ if (!st) { |
|
3364 |
+ av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n"); |
|
3365 |
+ exit_program(1); |
|
3366 |
+ } |
|
3367 |
+ |
|
3368 |
+ output_streams_for_file[nb_output_files] = |
|
3369 |
+ grow_array(output_streams_for_file[nb_output_files], |
|
3370 |
+ sizeof(*output_streams_for_file[nb_output_files]), |
|
3371 |
+ &nb_output_streams_for_file[nb_output_files], |
|
3372 |
+ oc->nb_streams); |
|
3373 |
+ ost = output_streams_for_file[nb_output_files][idx] = |
|
3374 |
+ av_mallocz(sizeof(OutputStream)); |
|
3375 |
+ if (!ost) { |
|
3376 |
+ fprintf(stderr, "Could not alloc output stream\n"); |
|
3377 |
+ exit_program(1); |
|
3378 |
+ } |
|
3379 |
+ ost->file_index = nb_output_files; |
|
3380 |
+ ost->index = idx; |
|
3381 |
+ ost->st = st; |
|
3382 |
+ st->codec->codec_type = type; |
|
3383 |
+ ost->enc = choose_codec(oc, st, type, codec_names); |
|
3384 |
+ if (ost->enc) { |
|
3385 |
+ ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st); |
|
3352 | 3386 |
} |
3353 | 3387 |
|
3354 |
- ost = new_output_stream(oc, file_idx, codec); |
|
3388 |
+ avcodec_get_context_defaults3(st->codec, ost->enc); |
|
3389 |
+ st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy |
|
3390 |
+ |
|
3391 |
+ ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); |
|
3392 |
+ return ost; |
|
3393 |
+} |
|
3394 |
+ |
|
3395 |
+static OutputStream *new_video_stream(AVFormatContext *oc) |
|
3396 |
+{ |
|
3397 |
+ AVStream *st; |
|
3398 |
+ OutputStream *ost; |
|
3399 |
+ AVCodecContext *video_enc; |
|
3400 |
+ |
|
3401 |
+ ost = new_output_stream(oc, AVMEDIA_TYPE_VIDEO); |
|
3355 | 3402 |
st = ost->st; |
3356 |
- if (!video_stream_copy) { |
|
3403 |
+ if (!st->stream_copy) { |
|
3357 | 3404 |
ost->frame_aspect_ratio = frame_aspect_ratio; |
3358 | 3405 |
frame_aspect_ratio = 0; |
3359 | 3406 |
#if CONFIG_AVFILTER |
... | ... |
@@ -3376,9 +3302,7 @@ static OutputStream *new_video_stream(AVFormatContext *oc, int file_idx) |
3376 | 3376 |
video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; |
3377 | 3377 |
} |
3378 | 3378 |
|
3379 |
- video_enc->codec_type = AVMEDIA_TYPE_VIDEO; |
|
3380 |
- if (video_stream_copy) { |
|
3381 |
- st->stream_copy = 1; |
|
3379 |
+ if (st->stream_copy) { |
|
3382 | 3380 |
video_enc->sample_aspect_ratio = |
3383 | 3381 |
st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255); |
3384 | 3382 |
} else { |
... | ... |
@@ -3387,7 +3311,6 @@ static OutputStream *new_video_stream(AVFormatContext *oc, int file_idx) |
3387 | 3387 |
|
3388 | 3388 |
if (frame_rate.num) |
3389 | 3389 |
ost->frame_rate = frame_rate; |
3390 |
- video_enc->codec_id = codec_id; |
|
3391 | 3390 |
|
3392 | 3391 |
video_enc->width = frame_width; |
3393 | 3392 |
video_enc->height = frame_height; |
... | ... |
@@ -3397,7 +3320,7 @@ static OutputStream *new_video_stream(AVFormatContext *oc, int file_idx) |
3397 | 3397 |
|
3398 | 3398 |
if (intra_only) |
3399 | 3399 |
video_enc->gop_size = 0; |
3400 |
- if (video_qscale || same_quality) { |
|
3400 |
+ if (video_qscale || same_quant) { |
|
3401 | 3401 |
video_enc->flags |= CODEC_FLAG_QSCALE; |
3402 | 3402 |
video_enc->global_quality = FF_QP2LAMBDA * video_qscale; |
3403 | 3403 |
} |
... | ... |
@@ -3459,31 +3382,18 @@ static OutputStream *new_video_stream(AVFormatContext *oc, int file_idx) |
3459 | 3459 |
|
3460 | 3460 |
/* reset some key parameters */ |
3461 | 3461 |
video_disable = 0; |
3462 |
- av_freep(&video_codec_name); |
|
3463 | 3462 |
av_freep(&forced_key_frames); |
3464 |
- video_stream_copy = 0; |
|
3465 | 3463 |
frame_pix_fmt = PIX_FMT_NONE; |
3466 | 3464 |
return ost; |
3467 | 3465 |
} |
3468 | 3466 |
|
3469 |
-static OutputStream *new_audio_stream(AVFormatContext *oc, int file_idx) |
|
3467 |
+static OutputStream *new_audio_stream(AVFormatContext *oc) |
|
3470 | 3468 |
{ |
3471 | 3469 |
AVStream *st; |
3472 | 3470 |
OutputStream *ost; |
3473 |
- AVCodec *codec= NULL; |
|
3474 | 3471 |
AVCodecContext *audio_enc; |
3475 |
- enum CodecID codec_id = CODEC_ID_NONE; |
|
3476 | 3472 |
|
3477 |
- if(!audio_stream_copy){ |
|
3478 |
- if (audio_codec_name) { |
|
3479 |
- codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1); |
|
3480 |
- codec = avcodec_find_encoder_by_name(audio_codec_name); |
|
3481 |
- } else { |
|
3482 |
- codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); |
|
3483 |
- codec = avcodec_find_encoder(codec_id); |
|
3484 |
- } |
|
3485 |
- } |
|
3486 |
- ost = new_output_stream(oc, file_idx, codec); |
|
3473 |
+ ost = new_output_stream(oc, AVMEDIA_TYPE_AUDIO); |
|
3487 | 3474 |
st = ost->st; |
3488 | 3475 |
|
3489 | 3476 |
ost->bitstream_filters = audio_bitstream_filters; |
... | ... |
@@ -3500,11 +3410,7 @@ static OutputStream *new_audio_stream(AVFormatContext *oc, int file_idx) |
3500 | 3500 |
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { |
3501 | 3501 |
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; |
3502 | 3502 |
} |
3503 |
- if (audio_stream_copy) { |
|
3504 |
- st->stream_copy = 1; |
|
3505 |
- } else { |
|
3506 |
- audio_enc->codec_id = codec_id; |
|
3507 |
- |
|
3503 |
+ if (!st->stream_copy) { |
|
3508 | 3504 |
if (audio_qscale > QSCALE_NONE) { |
3509 | 3505 |
audio_enc->flags |= CODEC_FLAG_QSCALE; |
3510 | 3506 |
audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale; |
... | ... |
@@ -3523,62 +3429,42 @@ static OutputStream *new_audio_stream(AVFormatContext *oc, int file_idx) |
3523 | 3523 |
|
3524 | 3524 |
/* reset some key parameters */ |
3525 | 3525 |
audio_disable = 0; |
3526 |
- av_freep(&audio_codec_name); |
|
3527 |
- audio_stream_copy = 0; |
|
3528 | 3526 |
|
3529 | 3527 |
return ost; |
3530 | 3528 |
} |
3531 | 3529 |
|
3532 |
-static OutputStream *new_data_stream(AVFormatContext *oc, int file_idx) |
|
3530 |
+static OutputStream *new_data_stream(AVFormatContext *oc) |
|
3533 | 3531 |
{ |
3534 | 3532 |
AVStream *st; |
3535 | 3533 |
OutputStream *ost; |
3536 | 3534 |
AVCodecContext *data_enc; |
3537 | 3535 |
|
3538 |
- ost = new_output_stream(oc, file_idx, NULL); |
|
3536 |
+ ost = new_output_stream(oc, AVMEDIA_TYPE_DATA); |
|
3539 | 3537 |
st = ost->st; |
3540 | 3538 |
data_enc = st->codec; |
3541 |
- if (!data_stream_copy) { |
|
3539 |
+ if (!st->stream_copy) { |
|
3542 | 3540 |
fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); |
3543 | 3541 |
exit_program(1); |
3544 | 3542 |
} |
3545 | 3543 |
|
3546 |
- data_enc->codec_type = AVMEDIA_TYPE_DATA; |
|
3547 |
- |
|
3548 | 3544 |
if (data_codec_tag) |
3549 | 3545 |
data_enc->codec_tag= data_codec_tag; |
3550 | 3546 |
|
3551 | 3547 |
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { |
3552 | 3548 |
data_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; |
3553 | 3549 |
} |
3554 |
- if (data_stream_copy) { |
|
3555 |
- st->stream_copy = 1; |
|
3556 |
- } |
|
3557 | 3550 |
|
3558 | 3551 |
data_disable = 0; |
3559 |
- av_freep(&data_codec_name); |
|
3560 |
- data_stream_copy = 0; |
|
3561 | 3552 |
return ost; |
3562 | 3553 |
} |
3563 | 3554 |
|
3564 |
-static OutputStream *new_subtitle_stream(AVFormatContext *oc, int file_idx) |
|
3555 |
+static OutputStream *new_subtitle_stream(AVFormatContext *oc) |
|
3565 | 3556 |
{ |
3566 | 3557 |
AVStream *st; |
3567 | 3558 |
OutputStream *ost; |
3568 |
- AVCodec *codec=NULL; |
|
3569 | 3559 |
AVCodecContext *subtitle_enc; |
3570 |
- enum CodecID codec_id = CODEC_ID_NONE; |
|
3571 | 3560 |
|
3572 |
- if(!subtitle_stream_copy){ |
|
3573 |
- if (subtitle_codec_name) { |
|
3574 |
- codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1); |
|
3575 |
- codec = avcodec_find_encoder_by_name(subtitle_codec_name); |
|
3576 |
- } else { |
|
3577 |
- codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); |
|
3578 |
- codec = avcodec_find_encoder(codec_id); |
|
3579 |
- } |
|
3580 |
- } |
|
3581 |
- ost = new_output_stream(oc, file_idx, codec); |
|
3561 |
+ ost = new_output_stream(oc, AVMEDIA_TYPE_SUBTITLE); |
|
3582 | 3562 |
st = ost->st; |
3583 | 3563 |
subtitle_enc = st->codec; |
3584 | 3564 |
|
... | ... |
@@ -3593,11 +3479,6 @@ static OutputStream *new_subtitle_stream(AVFormatContext *oc, int file_idx) |
3593 | 3593 |
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { |
3594 | 3594 |
subtitle_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; |
3595 | 3595 |
} |
3596 |
- if (subtitle_stream_copy) { |
|
3597 |
- st->stream_copy = 1; |
|
3598 |
- } else { |
|
3599 |
- subtitle_enc->codec_id = codec_id; |
|
3600 |
- } |
|
3601 | 3596 |
|
3602 | 3597 |
if (subtitle_language) { |
3603 | 3598 |
av_dict_set(&st->metadata, "language", subtitle_language, 0); |
... | ... |
@@ -3605,8 +3486,6 @@ static OutputStream *new_subtitle_stream(AVFormatContext *oc, int file_idx) |
3605 | 3605 |
} |
3606 | 3606 |
|
3607 | 3607 |
subtitle_disable = 0; |
3608 |
- av_freep(&subtitle_codec_name); |
|
3609 |
- subtitle_stream_copy = 0; |
|
3610 | 3608 |
return ost; |
3611 | 3609 |
} |
3612 | 3610 |
|
... | ... |
@@ -3632,6 +3511,80 @@ static int opt_streamid(const char *opt, const char *arg) |
3632 | 3632 |
return 0; |
3633 | 3633 |
} |
3634 | 3634 |
|
3635 |
+static int copy_chapters(int infile, int outfile) |
|
3636 |
+{ |
|
3637 |
+ AVFormatContext *is = input_files[infile].ctx; |
|
3638 |
+ AVFormatContext *os = output_files[outfile]; |
|
3639 |
+ int i; |
|
3640 |
+ |
|
3641 |
+ for (i = 0; i < is->nb_chapters; i++) { |
|
3642 |
+ AVChapter *in_ch = is->chapters[i], *out_ch; |
|
3643 |
+ int64_t ts_off = av_rescale_q(start_time - input_files[infile].ts_offset, |
|
3644 |
+ AV_TIME_BASE_Q, in_ch->time_base); |
|
3645 |
+ int64_t rt = (recording_time == INT64_MAX) ? INT64_MAX : |
|
3646 |
+ av_rescale_q(recording_time, AV_TIME_BASE_Q, in_ch->time_base); |
|
3647 |
+ |
|
3648 |
+ |
|
3649 |
+ if (in_ch->end < ts_off) |
|
3650 |
+ continue; |
|
3651 |
+ if (rt != INT64_MAX && in_ch->start > rt + ts_off) |
|
3652 |
+ break; |
|
3653 |
+ |
|
3654 |
+ out_ch = av_mallocz(sizeof(AVChapter)); |
|
3655 |
+ if (!out_ch) |
|
3656 |
+ return AVERROR(ENOMEM); |
|
3657 |
+ |
|
3658 |
+ out_ch->id = in_ch->id; |
|
3659 |
+ out_ch->time_base = in_ch->time_base; |
|
3660 |
+ out_ch->start = FFMAX(0, in_ch->start - ts_off); |
|
3661 |
+ out_ch->end = FFMIN(rt, in_ch->end - ts_off); |
|
3662 |
+ |
|
3663 |
+ if (metadata_chapters_autocopy) |
|
3664 |
+ av_dict_copy(&out_ch->metadata, in_ch->metadata, 0); |
|
3665 |
+ |
|
3666 |
+ os->nb_chapters++; |
|
3667 |
+ os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters); |
|
3668 |
+ if (!os->chapters) |
|
3669 |
+ return AVERROR(ENOMEM); |
|
3670 |
+ os->chapters[os->nb_chapters - 1] = out_ch; |
|
3671 |
+ } |
|
3672 |
+ return 0; |
|
3673 |
+} |
|
3674 |
+ |
|
3675 |
+static int read_ffserver_streams(AVFormatContext *s, const char *filename) |
|
3676 |
+{ |
|
3677 |
+ int i, err; |
|
3678 |
+ AVFormatContext *ic = NULL; |
|
3679 |
+ |
|
3680 |
+ err = avformat_open_input(&ic, filename, NULL, NULL); |
|
3681 |
+ if (err < 0) |
|
3682 |
+ return err; |
|
3683 |
+ /* copy stream format */ |
|
3684 |
+ for(i=0;i<ic->nb_streams;i++) { |
|
3685 |
+ AVStream *st; |
|
3686 |
+ OutputStream *ost; |
|
3687 |
+ AVCodec *codec; |
|
3688 |
+ |
|
3689 |
+ codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); |
|
3690 |
+ ost = new_output_stream(s, codec->type); |
|
3691 |
+ st = ost->st; |
|
3692 |
+ |
|
3693 |
+ // FIXME: a more elegant solution is needed |
|
3694 |
+ memcpy(st, ic->streams[i], sizeof(AVStream)); |
|
3695 |
+ st->info = av_malloc(sizeof(*st->info)); |
|
3696 |
+ memcpy(st->info, ic->streams[i]->info, sizeof(*st->info)); |
|
3697 |
+ avcodec_copy_context(st->codec, ic->streams[i]->codec); |
|
3698 |
+ |
|
3699 |
+ if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !st->stream_copy) |
|
3700 |
+ choose_sample_fmt(st, codec); |
|
3701 |
+ else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !st->stream_copy) |
|
3702 |
+ choose_pixel_fmt(st, codec); |
|
3703 |
+ } |
|
3704 |
+ |
|
3705 |
+ av_close_input_file(ic); |
|
3706 |
+ return 0; |
|
3707 |
+} |
|
3708 |
+ |
|
3635 | 3709 |
static int opt_output_file(const char *opt, const char *filename) |
3636 | 3710 |
{ |
3637 | 3711 |
AVFormatContext *oc; |
... | ... |
@@ -3670,7 +3623,7 @@ static int opt_output_file(const char *opt, const char *filename) |
3670 | 3670 |
/* pick the "best" stream of each type */ |
3671 | 3671 |
#define NEW_STREAM(type, index)\ |
3672 | 3672 |
if (index >= 0) {\ |
3673 |
- ost = new_ ## type ## _stream(oc, nb_output_files);\ |
|
3673 |
+ ost = new_ ## type ## _stream(oc);\ |
|
3674 | 3674 |
ost->source_index = index;\ |
3675 | 3675 |
ost->sync_ist = &input_streams[index];\ |
3676 | 3676 |
input_streams[index].discard = 0;\ |
... | ... |
@@ -3722,10 +3675,10 @@ static int opt_output_file(const char *opt, const char *filename) |
3722 | 3722 |
|
3723 | 3723 |
ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index]; |
3724 | 3724 |
switch (ist->st->codec->codec_type) { |
3725 |
- case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(oc, nb_output_files); break; |
|
3726 |
- case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(oc, nb_output_files); break; |
|
3727 |
- case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(oc, nb_output_files); break; |
|
3728 |
- case AVMEDIA_TYPE_DATA: ost = new_data_stream(oc, nb_output_files); break; |
|
3725 |
+ case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(oc); break; |
|
3726 |
+ case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(oc); break; |
|
3727 |
+ case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(oc); break; |
|
3728 |
+ case AVMEDIA_TYPE_DATA: ost = new_data_stream(oc); break; |
|
3729 | 3729 |
default: |
3730 | 3730 |
av_log(NULL, AV_LOG_ERROR, "Cannot map stream #%d.%d - unsupported type.\n", |
3731 | 3731 |
map->file_index, map->stream_index); |
... | ... |
@@ -3876,6 +3829,8 @@ static int opt_output_file(const char *opt, const char *filename) |
3876 | 3876 |
av_freep(&stream_maps); |
3877 | 3877 |
nb_stream_maps = 0; |
3878 | 3878 |
|
3879 |
+ av_dict_free(&codec_names); |
|
3880 |
+ |
|
3879 | 3881 |
av_freep(&forced_key_frames); |
3880 | 3882 |
uninit_opts(); |
3881 | 3883 |
init_opts(); |
... | ... |
@@ -4087,8 +4042,8 @@ static int opt_target(const char *opt, const char *arg) |
4087 | 4087 |
} |
4088 | 4088 |
|
4089 | 4089 |
if(!strcmp(arg, "vcd")) { |
4090 |
- opt_codec("vcodec", "mpeg1video"); |
|
4091 |
- opt_codec("acodec", "mp2"); |
|
4090 |
+ opt_codec("c:v", "mpeg1video"); |
|
4091 |
+ opt_codec("c:a", "mp2"); |
|
4092 | 4092 |
opt_format("f", "vcd"); |
4093 | 4093 |
|
4094 | 4094 |
opt_frame_size("s", norm == PAL ? "352x288" : "352x240"); |
... | ... |
@@ -4100,7 +4055,7 @@ static int opt_target(const char *opt, const char *arg) |
4100 | 4100 |
opt_default("minrate", "1150000"); |
4101 | 4101 |
opt_default("bufsize", "327680"); // 40*1024*8; |
4102 | 4102 |
|
4103 |
- opt_default("ab", "224000"); |
|
4103 |
+ opt_default("b:a", "224000"); |
|
4104 | 4104 |
audio_sample_rate = 44100; |
4105 | 4105 |
audio_channels = 2; |
4106 | 4106 |
|
... | ... |
@@ -4115,8 +4070,8 @@ static int opt_target(const char *opt, const char *arg) |
4115 | 4115 |
mux_preload= (36000+3*1200) / 90000.0; //0.44 |
4116 | 4116 |
} else if(!strcmp(arg, "svcd")) { |
4117 | 4117 |
|
4118 |
- opt_codec("vcodec", "mpeg2video"); |
|
4119 |
- opt_codec("acodec", "mp2"); |
|
4118 |
+ opt_codec("c:v", "mpeg2video"); |
|
4119 |
+ opt_codec("c:a", "mp2"); |
|
4120 | 4120 |
opt_format("f", "svcd"); |
4121 | 4121 |
|
4122 | 4122 |
opt_frame_size("s", norm == PAL ? "480x576" : "480x480"); |
... | ... |
@@ -4131,15 +4086,15 @@ static int opt_target(const char *opt, const char *arg) |
4131 | 4131 |
opt_default("flags", "+scan_offset"); |
4132 | 4132 |
|
4133 | 4133 |
|
4134 |
- opt_default("ab", "224000"); |
|
4134 |
+ opt_default("b:a", "224000"); |
|
4135 | 4135 |
audio_sample_rate = 44100; |
4136 | 4136 |
|
4137 | 4137 |
opt_default("packetsize", "2324"); |
4138 | 4138 |
|
4139 | 4139 |
} else if(!strcmp(arg, "dvd")) { |
4140 | 4140 |
|
4141 |
- opt_codec("vcodec", "mpeg2video"); |
|
4142 |
- opt_codec("acodec", "ac3"); |
|
4141 |
+ opt_codec("c:v", "mpeg2video"); |
|
4142 |
+ opt_codec("c:a", "ac3"); |
|
4143 | 4143 |
opt_format("f", "dvd"); |
4144 | 4144 |
|
4145 | 4145 |
opt_frame_size("vcodec", norm == PAL ? "720x576" : "720x480"); |
... | ... |
@@ -4155,7 +4110,7 @@ static int opt_target(const char *opt, const char *arg) |
4155 | 4155 |
opt_default("packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack. |
4156 | 4156 |
opt_default("muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8 |
4157 | 4157 |
|
4158 |
- opt_default("ab", "448000"); |
|
4158 |
+ opt_default("b:a", "448000"); |
|
4159 | 4159 |
audio_sample_rate = 48000; |
4160 | 4160 |
|
4161 | 4161 |
} else if(!strncmp(arg, "dv", 2)) { |
... | ... |
@@ -4216,44 +4171,6 @@ static int opt_bsf(const char *opt, const char *arg) |
4216 | 4216 |
return 0; |
4217 | 4217 |
} |
4218 | 4218 |
|
4219 |
-static int opt_preset(const char *opt, const char *arg) |
|
4220 |
-{ |
|
4221 |
- FILE *f=NULL; |
|
4222 |
- char filename[1000], tmp[1000], tmp2[1000], line[1000]; |
|
4223 |
- char *codec_name = *opt == 'v' ? video_codec_name : |
|
4224 |
- *opt == 'a' ? audio_codec_name : |
|
4225 |
- subtitle_codec_name; |
|
4226 |
- |
|
4227 |
- if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) { |
|
4228 |
- fprintf(stderr, "File for preset '%s' not found\n", arg); |
|
4229 |
- exit_program(1); |
|
4230 |
- } |
|
4231 |
- |
|
4232 |
- while(!feof(f)){ |
|
4233 |
- int e= fscanf(f, "%999[^\n]\n", line) - 1; |
|
4234 |
- if(line[0] == '#' && !e) |
|
4235 |
- continue; |
|
4236 |
- e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2; |
|
4237 |
- if(e){ |
|
4238 |
- fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line); |
|
4239 |
- exit_program(1); |
|
4240 |
- } |
|
4241 |
- if (!strcmp(tmp, "acodec") || |
|
4242 |
- !strcmp(tmp, "vcodec") || |
|
4243 |
- !strcmp(tmp, "scodec") || |
|
4244 |
- !strcmp(tmp, "dcodec")) { |
|
4245 |
- opt_codec(tmp, tmp2); |
|
4246 |
- }else if(opt_default(tmp, tmp2) < 0){ |
|
4247 |
- fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); |
|
4248 |
- exit_program(1); |
|
4249 |
- } |
|
4250 |
- } |
|
4251 |
- |
|
4252 |
- fclose(f); |
|
4253 |
- |
|
4254 |
- return 0; |
|
4255 |
-} |
|
4256 |
- |
|
4257 | 4219 |
static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) |
4258 | 4220 |
{ |
4259 | 4221 |
} |
... | ... |
@@ -4274,6 +4191,8 @@ static const OptionDef options[] = { |
4274 | 4274 |
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" }, |
4275 | 4275 |
{ "i", HAS_ARG, {(void*)opt_input_file}, "input file name", "filename" }, |
4276 | 4276 |
{ "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, |
4277 |
+ { "c", HAS_ARG, {(void*)opt_codec}, "codec name", "codec" }, |
|
4278 |
+ { "codec", HAS_ARG, {(void*)opt_codec}, "codec name", "codec" }, |
|
4277 | 4279 |
{ "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, |
4278 | 4280 |
{ "map_metadata", HAS_ARG | OPT_EXPERT, {(void*)opt_map_metadata}, "set metadata information of outfile from infile", |
4279 | 4281 |
"outfile[,metadata]:infile[,metadata]" }, |
... | ... |
@@ -4328,9 +4247,9 @@ static const OptionDef options[] = { |
4328 | 4328 |
{ "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" }, |
4329 | 4329 |
{ "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixed video quantizer scale (VBR)", "q" }, |
4330 | 4330 |
{ "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_override_string}, "rate control override for specific intervals", "override" }, |
4331 |
- { "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_codec}, "force video codec ('copy' to copy stream)", "codec" }, |
|
4331 |
+ { "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" }, |
|
4332 | 4332 |
{ "me_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold", "threshold" }, |
4333 |
- { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality}, |
|
4333 |
+ { "same_quant", OPT_BOOL | OPT_VIDEO, {(void*)&same_quant}, |
|
4334 | 4334 |
"use same quantizer as source (implies VBR)" }, |
4335 | 4335 |
{ "pass", HAS_ARG | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" }, |
4336 | 4336 |
{ "passlogfile", HAS_ARG | OPT_VIDEO, {(void*)&opt_passlogfile}, "select two pass log file name prefix", "prefix" }, |
... | ... |
@@ -4359,7 +4278,7 @@ static const OptionDef options[] = { |
4359 | 4359 |
{ "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" }, |
4360 | 4360 |
{ "ac", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of audio channels", "channels" }, |
4361 | 4361 |
{ "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" }, |
4362 |
- { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_codec}, "force audio codec ('copy' to copy stream)", "codec" }, |
|
4362 |
+ { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" }, |
|
4363 | 4363 |
{ "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_codec_tag}, "force audio tag/fourcc", "fourcc/tag" }, |
4364 | 4364 |
{ "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, // |
4365 | 4365 |
{ "alang", HAS_ARG | OPT_STRING | OPT_AUDIO, {(void *)&audio_language}, "set the ISO 639 language code (3 letters) of the current audio stream" , "code" }, |
... | ... |
@@ -4367,7 +4286,7 @@ static const OptionDef options[] = { |
4367 | 4367 |
|
4368 | 4368 |
/* subtitle options */ |
4369 | 4369 |
{ "sn", OPT_BOOL | OPT_SUBTITLE, {(void*)&subtitle_disable}, "disable subtitle" }, |
4370 |
- { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_codec}, "force subtitle codec ('copy' to copy stream)", "codec" }, |
|
4370 |
+ { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" }, |
|
4371 | 4371 |
{ "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language}, "set the ISO 639 language code (3 letters) of the current subtitle stream" , "code" }, |
4372 | 4372 |
{ "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_codec_tag}, "force subtitle tag/fourcc", "fourcc/tag" }, |
4373 | 4373 |
|
... | ... |
@@ -4382,12 +4301,8 @@ static const OptionDef options[] = { |
4382 | 4382 |
{ "vbsf", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" }, |
4383 | 4383 |
{ "sbsf", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" }, |
4384 | 4384 |
|
4385 |
- { "apre", HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "set the audio options to the indicated preset", "preset" }, |
|
4386 |
- { "vpre", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "set the video options to the indicated preset", "preset" }, |
|
4387 |
- { "spre", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "set the subtitle options to the indicated preset", "preset" }, |
|
4388 |
- { "fpre", HAS_ARG | OPT_EXPERT, {(void*)opt_preset}, "set options from indicated preset file", "filename" }, |
|
4389 | 4385 |
/* data codec support */ |
4390 |
- { "dcodec", HAS_ARG | OPT_DATA, {(void*)opt_codec}, "force data codec ('copy' to copy stream)", "codec" }, |
|
4386 |
+ { "dcodec", HAS_ARG | OPT_DATA, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" }, |
|
4391 | 4387 |
|
4392 | 4388 |
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" }, |
4393 | 4389 |
{ NULL, }, |
... | ... |
@@ -97,6 +97,34 @@ input file name |
97 | 97 |
@item -y |
98 | 98 |
Overwrite output files. |
99 | 99 |
|
100 |
+@item -c[:@var{stream_type}][:@var{stream_index}] @var{codec} |
|
101 |
+@item -codec[:@var{stream_type}][:@var{stream_index}] @var{codec} |
|
102 |
+Select an encoder (when used before an output file) or a decoder (when used |
|
103 |
+before an input file) for one or more streams. @var{codec} is the name of a |
|
104 |
+decoder/encoder or a special value @code{copy} (output only) to indicate that |
|
105 |
+the stream is not to be reencoded. |
|
106 |
+ |
|
107 |
+@var{stream_type} may be 'v' for video, 'a' for audio, 's' for subtitle and 'd' |
|
108 |
+for data streams. @var{stream_index} is a global zero-based stream index if |
|
109 |
+@var{stream_type} isn't given, otherwise it counts only streams of the given |
|
110 |
+type. If @var{stream_index} is omitted, this option applies to all streams of |
|
111 |
+the given type or all streams of any type if @var{stream_type} is missing as |
|
112 |
+well (note that this only makes sense when all streams are of the same type or |
|
113 |
+@var{codec} is @code{copy}). |
|
114 |
+ |
|
115 |
+For example |
|
116 |
+@example |
|
117 |
+avconv -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT |
|
118 |
+@end example |
|
119 |
+encodes all video streams with libx264 and copies all audio streams. |
|
120 |
+ |
|
121 |
+For each stream, the last matching @code{c} option is applied, so |
|
122 |
+@example |
|
123 |
+avconv -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT |
|
124 |
+@end example |
|
125 |
+will copy all the streams except the second video, which will be encoded with |
|
126 |
+libx264, and the 138th audio, which will be encoded with libvorbis. |
|
127 |
+ |
|
100 | 128 |
@item -t @var{duration} |
101 | 129 |
Restrict the transcoded/captured video sequence |
102 | 130 |
to the duration specified in seconds. |
... | ... |
@@ -159,9 +187,6 @@ avconv -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg |
159 | 159 |
@item -dframes @var{number} |
160 | 160 |
Set the number of data frames to record. |
161 | 161 |
|
162 |
-@item -scodec @var{codec} |
|
163 |
-Force subtitle codec ('copy' to copy stream). |
|
164 |
- |
|
165 | 162 |
@item -slang @var{code} |
166 | 163 |
Set the ISO 639 language code (3 letters) of the current subtitle stream. |
167 | 164 |
|
... | ... |
@@ -282,11 +307,13 @@ It is of little use elsewise. |
282 | 282 |
@item -bufsize @var{size} |
283 | 283 |
Set video buffer verifier buffer size (in bits). |
284 | 284 |
@item -vcodec @var{codec} |
285 |
-Force video codec to @var{codec}. Use the @code{copy} special value to |
|
286 |
-tell that the raw codec data must be copied as is. |
|
287 |
-@item -sameq |
|
285 |
+Set the video codec. This is an alias for @code{-codec:v}. |
|
286 |
+@item -same_quant |
|
288 | 287 |
Use same quantizer as source (implies VBR). |
289 | 288 |
|
289 |
+Note that this is NOT SAME QUALITY. Do not use this option unless you know you |
|
290 |
+need it. |
|
291 |
+ |
|
290 | 292 |
@item -pass @var{n} |
291 | 293 |
Select the pass number (1 or 2). It is used to do two-pass |
292 | 294 |
video encoding. The statistics of the video are recorded in the first |
... | ... |
@@ -296,8 +323,8 @@ at the exact requested bitrate. |
296 | 296 |
On pass 1, you may just deactivate audio and set output to null, |
297 | 297 |
examples for Windows and Unix: |
298 | 298 |
@example |
299 |
-avconv -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y NUL |
|
300 |
-avconv -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y /dev/null |
|
299 |
+avconv -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL |
|
300 |
+avconv -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null |
|
301 | 301 |
@end example |
302 | 302 |
|
303 | 303 |
@item -passlogfile @var{prefix} |
... | ... |
@@ -541,7 +568,7 @@ Show QP histogram. |
541 | 541 |
@item -vbsf @var{bitstream_filter} |
542 | 542 |
Bitstream filters available are "dump_extra", "remove_extra", "noise", "h264_mp4toannexb", "imxdump", "mjpegadump", "mjpeg2jpeg". |
543 | 543 |
@example |
544 |
-avconv -i h264.mp4 -vcodec copy -vbsf h264_mp4toannexb -an out.h264 |
|
544 |
+avconv -i h264.mp4 -c:v copy -vbsf h264_mp4toannexb -an out.h264 |
|
545 | 545 |
@end example |
546 | 546 |
@item -force_key_frames @var{time}[,@var{time}...] |
547 | 547 |
Force key frames at the specified timestamps, more precisely at the first |
... | ... |
@@ -571,8 +598,7 @@ and is mapped to the corresponding demuxer options. |
571 | 571 |
@item -an |
572 | 572 |
Disable audio recording. |
573 | 573 |
@item -acodec @var{codec} |
574 |
-Force audio codec to @var{codec}. Use the @code{copy} special value to |
|
575 |
-specify that the raw codec data must be copied as is. |
|
574 |
+Set the audio codec. This is an alias for @code{-codec:a}. |
|
576 | 575 |
@item -alang @var{code} |
577 | 576 |
Set the ISO 639 language code (3 letters) of the current audio stream. |
578 | 577 |
@end table |
... | ... |
@@ -612,7 +638,7 @@ Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp" |
612 | 612 |
|
613 | 613 |
@table @option |
614 | 614 |
@item -scodec @var{codec} |
615 |
-Force subtitle codec ('copy' to copy stream). |
|
615 |
+Set the subtitle codec. This is an alias for @code{-codec:s}. |
|
616 | 616 |
@item -slang @var{code} |
617 | 617 |
Set the ISO 639 language code (3 letters) of the current subtitle stream. |
618 | 618 |
@item -sn |
... | ... |
@@ -620,7 +646,7 @@ Disable subtitle recording. |
620 | 620 |
@item -sbsf @var{bitstream_filter} |
621 | 621 |
Bitstream filters available are "mov2textsub", "text2movsub". |
622 | 622 |
@example |
623 |
-avconv -i file.mov -an -vn -sbsf mov2textsub -scodec copy -f rawvideo sub.txt |
|
623 |
+avconv -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt |
|
624 | 624 |
@end example |
625 | 625 |
@end table |
626 | 626 |
|
... | ... |
@@ -677,7 +703,7 @@ For example, to select the stream with index 2 from input file |
677 | 677 |
index 6 from input @file{b.mov} (specified by the identifier "1:6"), |
678 | 678 |
and copy them to the output file @file{out.mov}: |
679 | 679 |
@example |
680 |
-avconv -i a.mov -i b.mov -vcodec copy -acodec copy -map 0:2 -map 1:6 out.mov |
|
680 |
+avconv -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov |
|
681 | 681 |
@end example |
682 | 682 |
|
683 | 683 |
To select all video and the third audio stream from an input file: |
... | ... |
@@ -785,40 +811,7 @@ an output mpegts file: |
785 | 785 |
avconv -i infile -streamid 0:33 -streamid 1:36 out.ts |
786 | 786 |
@end example |
787 | 787 |
@end table |
788 |
- |
|
789 |
-@section Preset files |
|
790 |
- |
|
791 |
-A preset file contains a sequence of @var{option}=@var{value} pairs, |
|
792 |
-one for each line, specifying a sequence of options which would be |
|
793 |
-awkward to specify on the command line. Lines starting with the hash |
|
794 |
-('#') character are ignored and are used to provide comments. Check |
|
795 |
-the @file{ffpresets} directory in the Libav source tree for examples. |
|
796 |
- |
|
797 |
-Preset files are specified with the @code{vpre}, @code{apre}, |
|
798 |
-@code{spre}, and @code{fpre} options. The @code{fpre} option takes the |
|
799 |
-filename of the preset instead of a preset name as input and can be |
|
800 |
-used for any kind of codec. For the @code{vpre}, @code{apre}, and |
|
801 |
-@code{spre} options, the options specified in a preset file are |
|
802 |
-applied to the currently selected codec of the same type as the preset |
|
803 |
-option. |
|
804 |
- |
|
805 |
-The argument passed to the @code{vpre}, @code{apre}, and @code{spre} |
|
806 |
-preset options identifies the preset file to use according to the |
|
807 |
-following rules: |
|
808 |
- |
|
809 |
-First avconv searches for a file named @var{arg}.ffpreset in the |
|
810 |
-directories @file{$av_DATADIR} (if set), and @file{$HOME/.avconv}, and in |
|
811 |
-the datadir defined at configuration time (usually @file{PREFIX/share/avconv}) |
|
812 |
-in that order. For example, if the argument is @code{libx264-max}, it will |
|
813 |
-search for the file @file{libx264-max.ffpreset}. |
|
814 |
- |
|
815 |
-If no such file is found, then avconv will search for a file named |
|
816 |
-@var{codec_name}-@var{arg}.ffpreset in the above-mentioned |
|
817 |
-directories, where @var{codec_name} is the name of the codec to which |
|
818 |
-the preset file options will be applied. For example, if you select |
|
819 |
-the video codec with @code{-vcodec libx264} and use @code{-vpre max}, |
|
820 |
-then it will search for the file @file{libx264-max.ffpreset}. |
|
821 |
-@c man end |
|
788 |
+@c man end OPTIONS |
|
822 | 789 |
|
823 | 790 |
@chapter Tips |
824 | 791 |
@c man begin TIPS |
... | ... |
@@ -858,11 +851,6 @@ To have a constant quality (but a variable bitrate), use the option |
858 | 858 |
'-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst |
859 | 859 |
quality). |
860 | 860 |
|
861 |
-@item |
|
862 |
-When converting video files, you can use the '-sameq' option which |
|
863 |
-uses the same quality factor in the encoder as in the decoder. |
|
864 |
-It allows almost lossless encoding. |
|
865 |
- |
|
866 | 861 |
@end itemize |
867 | 862 |
@c man end TIPS |
868 | 863 |
|
... | ... |
@@ -968,7 +956,7 @@ You can encode to several formats at the same time and define a |
968 | 968 |
mapping from input stream to output streams: |
969 | 969 |
|
970 | 970 |
@example |
971 |
-avconv -i /tmp/a.wav -map 0:a -ab 64k /tmp/a.mp2 -map 0:a -ab 128k /tmp/b.mp2 |
|
971 |
+avconv -i /tmp/a.wav -map 0:a -b 64k /tmp/a.mp2 -map 0:a -b 128k /tmp/b.mp2 |
|
972 | 972 |
@end example |
973 | 973 |
|
974 | 974 |
Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map |
... | ... |
@@ -979,7 +967,7 @@ stream, in the order of the definition of output streams. |
979 | 979 |
You can transcode decrypted VOBs: |
980 | 980 |
|
981 | 981 |
@example |
982 |
-avconv -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k snatch.avi |
|
982 |
+avconv -i snatch_1.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k snatch.avi |
|
983 | 983 |
@end example |
984 | 984 |
|
985 | 985 |
This is a typical DVD ripping example; the input is a VOB file, the |
... | ... |
@@ -1023,7 +1011,7 @@ only formats accepting a normal integer are suitable. |
1023 | 1023 |
You can put many streams of the same type in the output: |
1024 | 1024 |
|
1025 | 1025 |
@example |
1026 |
-avconv -i test1.avi -i test2.avi -map 0.3 -map 0.2 -map 0.1 -map 0.0 -vcodec copy -acodec copy -vcodec copy -acodec copy test12.nut |
|
1026 |
+avconv -i test1.avi -i test2.avi -map 0.3 -map 0.2 -map 0.1 -map 0.0 -c copy test12.nut |
|
1027 | 1027 |
@end example |
1028 | 1028 |
|
1029 | 1029 |
The resulting output file @file{test12.avi} will contain first four streams from |
... | ... |
@@ -4451,8 +4451,8 @@ static const OptionDef options[] = { |
4451 | 4451 |
{ "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_override_string}, "rate control override for specific intervals", "override" }, |
4452 | 4452 |
{ "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_codec}, "force video codec ('copy' to copy stream)", "codec" }, |
4453 | 4453 |
{ "me_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold", "threshold" }, |
4454 |
- { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality}, |
|
4455 |
- "use same quantizer as source (implies VBR)" }, |
|
4454 |
+ { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality}, "use same quantizer as source (implies VBR)" }, |
|
4455 |
+ { "same_quant", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality}, "use same quantizer as source (implies VBR)" }, |
|
4456 | 4456 |
{ "pass", HAS_ARG | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" }, |
4457 | 4457 |
{ "passlogfile", HAS_ARG | OPT_VIDEO, {(void*)&opt_passlogfile}, "select two pass log file name prefix", "prefix" }, |
4458 | 4458 |
{ "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace}, |
... | ... |
@@ -70,7 +70,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i |
70 | 70 |
#define AV_CODEC_DEFAULT_BITRATE 200*1000 |
71 | 71 |
|
72 | 72 |
static const AVOption options[]={ |
73 |
-{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, V|E}, |
|
73 |
+{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, A|V|E}, |
|
74 | 74 |
{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = 64*1000 }, INT_MIN, INT_MAX, A|E}, |
75 | 75 |
{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, |
76 | 76 |
{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"}, |
... | ... |
@@ -927,7 +927,10 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) |
927 | 927 |
|
928 | 928 |
h->b_stride = 4*s->mb_width; |
929 | 929 |
|
930 |
- ff_h264_alloc_tables(h); |
|
930 |
+ if (ff_h264_alloc_tables(h) < 0) { |
|
931 |
+ av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n"); |
|
932 |
+ return AVERROR(ENOMEM); |
|
933 |
+ } |
|
931 | 934 |
} |
932 | 935 |
|
933 | 936 |
return 0; |
... | ... |
@@ -720,7 +720,7 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) |
720 | 720 |
if (!tag) { // if no mac fcc found, try with Microsoft tags |
721 | 721 |
tag = ff_codec_get_tag(ff_codec_bmp_tags, track->enc->codec_id); |
722 | 722 |
if (tag) |
723 |
- av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, " |
|
723 |
+ av_log(s, AV_LOG_WARNING, "Using MS style video codec tag, " |
|
724 | 724 |
"the file may be unplayable!\n"); |
725 | 725 |
} |
726 | 726 |
} else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) { |
... | ... |
@@ -729,7 +729,7 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) |
729 | 729 |
int ms_tag = ff_codec_get_tag(ff_codec_wav_tags, track->enc->codec_id); |
730 | 730 |
if (ms_tag) { |
731 | 731 |
tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff)); |
732 |
- av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, " |
|
732 |
+ av_log(s, AV_LOG_WARNING, "Using MS style audio codec tag, " |
|
733 | 733 |
"the file may be unplayable!\n"); |
734 | 734 |
} |
735 | 735 |
} |
... | ... |
@@ -16,7 +16,7 @@ if [ -n "$do_vref" ]; then |
16 | 16 |
do_avconv $raw_ref -f image2 -vcodec pgmyuv -i $raw_src -an -f rawvideo |
17 | 17 |
fi |
18 | 18 |
if [ -n "$do_aref" ]; then |
19 |
-do_avconv $pcm_ref -ab 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav |
|
19 |
+do_avconv $pcm_ref -b 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav |
|
20 | 20 |
fi |
21 | 21 |
|
22 | 22 |
if [ -n "$do_mpeg" ] ; then |
... | ... |
@@ -58,7 +58,7 @@ do_video_decoding |
58 | 58 |
|
59 | 59 |
# mpeg2 encoding interlaced |
60 | 60 |
file=${outfile}mpeg2reuse.mpg |
61 |
-do_avconv $file $DEC_OPTS -me_threshold 256 -i ${target_path}/${outfile}mpeg2thread.mpg $ENC_OPTS -sameq -me_threshold 256 -mb_threshold 1024 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4 |
|
61 |
+do_avconv $file $DEC_OPTS -me_threshold 256 -i ${target_path}/${outfile}mpeg2thread.mpg $ENC_OPTS -same_quant -me_threshold 256 -mb_threshold 1024 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4 |
|
62 | 62 |
do_video_decoding |
63 | 63 |
fi |
64 | 64 |
|
... | ... |
@@ -294,7 +294,7 @@ do_audio_encoding ac3.rm "-vn -acodec ac3_fixed" |
294 | 294 |
fi |
295 | 295 |
|
296 | 296 |
if [ -n "$do_g726" ] ; then |
297 |
-do_audio_encoding g726.wav "-ab 32k -ac 1 -ar 8000 -acodec g726" |
|
297 |
+do_audio_encoding g726.wav "-b 32k -ac 1 -ar 8000 -acodec g726" |
|
298 | 298 |
do_audio_decoding |
299 | 299 |
fi |
300 | 300 |
|
... | ... |
@@ -14,7 +14,7 @@ eval do_$test=y |
14 | 14 |
do_lavf() |
15 | 15 |
{ |
16 | 16 |
file=${outfile}lavf.$1 |
17 |
- do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -ab 64k -t 1 -qscale 10 $2 |
|
17 |
+ do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -b:a 64k -t 1 -qscale 10 $2 |
|
18 | 18 |
do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3 |
19 | 19 |
} |
20 | 20 |
|
... | ... |
@@ -53,7 +53,7 @@ fi |
53 | 53 |
|
54 | 54 |
if [ -n "$do_rm" ] ; then |
55 | 55 |
file=${outfile}lavf.rm |
56 |
-do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed -ab 64k |
|
56 |
+do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed -b:a 64k |
|
57 | 57 |
# broken |
58 | 58 |
#do_avconv_crc $file -i $target_path/$file |
59 | 59 |
fi |