File ffmpeg-codec-choice.diff of Package A_tw-ffmpeg-3

57
 
1
From: Jan Engelhardt <jengelh@inai.de>
2
3
Edit the default codec selection such that
4
5
    ffmpeg -i youtube.blah.webm foobar.mkv
6
7
without any further arguments can produce a result even on a
8
reduced codec selection list.
9
10
---
11
 libavformat/matroskaenc.c |   19 +++++++++++++------
12
 1 file changed, 13 insertions(+), 6 deletions(-)
13
14
Index: ffmpeg-3.3.1/libavformat/matroskaenc.c
15
===================================================================
16
--- ffmpeg-3.3.1.orig/libavformat/matroskaenc.c 2017-04-13 03:55:55.000000000 +0200
17
+++ ffmpeg-3.3.1/libavformat/matroskaenc.c  2017-05-31 13:39:12.379935754 +0200
18
@@ -2653,16 +2653,24 @@ static const AVClass matroska_class = {
19
     .version    = LIBAVUTIL_VERSION_INT,
20
 };
21
 
22
+#define PREFAUDIO \
23
+   CONFIG_LIBOPUS_ENCODER ? AV_CODEC_ID_OPUS : \
24
+   CONFIG_AAC_ENCODER ? AV_CODEC_ID_AAC : \
25
+   CONFIG_VORBIS_ENCODER ? AV_CODEC_ID_VORBIS : \
26
+   AV_CODEC_ID_AC3
27
 AVOutputFormat ff_matroska_muxer = {
28
     .name              = "matroska",
29
     .long_name         = NULL_IF_CONFIG_SMALL("Matroska"),
30
     .mime_type         = "video/x-matroska",
31
     .extensions        = "mkv",
32
     .priv_data_size    = sizeof(MatroskaMuxContext),
33
-    .audio_codec       = CONFIG_LIBVORBIS_ENCODER ?
34
-                         AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3,
35
-    .video_codec       = CONFIG_LIBX264_ENCODER ?
36
-                         AV_CODEC_ID_H264 : AV_CODEC_ID_MPEG4,
37
+    .audio_codec       = PREFAUDIO,
38
+    .video_codec       =
39
+   CONFIG_LIBVPX_VP9_ENCODER ? AV_CODEC_ID_VP9 : \
40
+   CONFIG_LIBX264_ENCODER ? AV_CODEC_ID_H264 : \
41
+   CONFIG_LIBVPX_VP8_ENCODER ? AV_CODEC_ID_VP8 : \
42
+   CONFIG_MPEG4_ENCODER ? AV_CODEC_ID_MPEG4 : \
43
+   AV_CODEC_ID_THEORA,
44
     .init              = mkv_init,
45
     .write_header      = mkv_write_header,
46
     .write_packet      = mkv_write_flush_packet,
47
@@ -2721,8 +2729,7 @@ AVOutputFormat ff_matroska_audio_muxer =
48
     .mime_type         = "audio/x-matroska",
49
     .extensions        = "mka",
50
     .priv_data_size    = sizeof(MatroskaMuxContext),
51
-    .audio_codec       = CONFIG_LIBVORBIS_ENCODER ?
52
-                         AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3,
53
+    .audio_codec       = PREFAUDIO,
54
     .video_codec       = AV_CODEC_ID_NONE,
55
     .init              = mkv_init,
56
     .write_header      = mkv_write_header,
57