[FFmpeg-devel] [PATCH]Try not to choose hearing- (or visual-) impaired audio streams

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Mar 28 11:46:30 CET 2013


Hi!

Several samples on trac contain hearing-impaired and other audio tracks, 
ffmpeg currently incorrectly chooses the hearing-impaired track if both are 
stereo.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index a134274..d300ef4 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1601,12 +1601,18 @@ static int open_output_file(OptionsContext *o, const char *filename)
 
         /* audio: most channels */
         if (!o->audio_disable && oc->oformat->audio_codec != AV_CODEC_ID_NONE) {
-            int channels = 0, idx = -1;
+            int channels = 0, idx = -1, impaired = 0;
             for (i = 0; i < nb_input_streams; i++) {
                 ist = input_streams[i];
                 if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+                    (impaired & AV_DISPOSITION_HEARING_IMPAIRED &&
+                    !(ist->st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) ||
+                    impaired & AV_DISPOSITION_VISUAL_IMPAIRED &&
+                    !(ist->st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) ||
-                    ist->st->codec->channels > channels) {
+                    ist->st->codec->channels > channels)) {
                     channels = ist->st->codec->channels;
+                    impaired = ist->st->disposition &
+                               (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED);
                     idx = i;
                 }
             }


More information about the ffmpeg-devel mailing list