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

58
 
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 |   20 ++++++++++++++------
12
 1 file changed, 14 insertions(+), 6 deletions(-)
13
14
Index: ffmpeg-6.1.1/libavformat/matroskaenc.c
15
===================================================================
16
--- ffmpeg-6.1.1.orig/libavformat/matroskaenc.c
17
+++ ffmpeg-6.1.1/libavformat/matroskaenc.c
18
@@ -3538,16 +3538,25 @@ static int mkv_query_codec(enum AVCodecI
19
     return 0;
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
+
28
 const FFOutputFormat ff_matroska_muxer = {
29
     .p.name            = "matroska",
30
     .p.long_name       = NULL_IF_CONFIG_SMALL("Matroska"),
31
     .p.mime_type       = "video/x-matroska",
32
     .p.extensions      = "mkv",
33
     .priv_data_size    = sizeof(MatroskaMuxContext),
34
-    .p.audio_codec     = CONFIG_LIBVORBIS_ENCODER ?
35
-                         AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3,
36
-    .p.video_codec     = CONFIG_LIBX264_ENCODER ?
37
-                         AV_CODEC_ID_H264 : AV_CODEC_ID_MPEG4,
38
+    .p.audio_codec     = PREFAUDIO,
39
+    .p.video_codec     = 
40
+   CONFIG_LIBVPX_VP9_ENCODER ? AV_CODEC_ID_VP9 : \
41
+   CONFIG_LIBX264_ENCODER ? AV_CODEC_ID_H264 : \
42
+   CONFIG_LIBVPX_VP8_ENCODER ? AV_CODEC_ID_VP8 : \
43
+   CONFIG_MPEG4_ENCODER ? AV_CODEC_ID_MPEG4 : \
44
+   AV_CODEC_ID_THEORA,
45
     .init              = mkv_init,
46
     .deinit            = mkv_deinit,
47
     .write_header      = mkv_write_header,
48
@@ -3615,8 +3624,7 @@ const FFOutputFormat ff_matroska_audio_m
49
     .p.mime_type       = "audio/x-matroska",
50
     .p.extensions      = "mka",
51
     .priv_data_size    = sizeof(MatroskaMuxContext),
52
-    .p.audio_codec     = CONFIG_LIBVORBIS_ENCODER ?
53
-                         AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3,
54
+    .p.audio_codec     = PREFAUDIO,
55
     .p.video_codec     = AV_CODEC_ID_NONE,
56
     .init              = mkv_init,
57
     .deinit            = mkv_deinit,
58