Fixes Ticket3727
Unified · Split
| @@ -432,6 +432,9 @@ static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track) · 431 unmodified lines | ||
| 432 | 432 | return 0; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | + if (track->multichannel_as_mono) | |
| 436 | + return 0; | |
| 437 | + | |
| 435 | 438 | avio_wb32(pb, 0); // Size |
| 436 | 439 | ffio_wfourcc(pb, "chan"); // Type |
| 437 | 440 | avio_w8(pb, 0); // Version |
| @@ -4120,6 +4123,31 @@ static int mov_write_header(AVFormatContext *s) · 3682 unmodified lines | ||
| 4120 | 4123 | } |
| 4121 | 4124 | } |
| 4122 | 4125 | |
| 4126 | + for (i = 0; i < s->nb_streams; i++) { | |
| 4127 | + int j; | |
| 4128 | + AVStream *st= s->streams[i]; | |
| 4129 | + MOVTrack *track= &mov->tracks[i]; | |
| 4130 | + | |
| 4131 | + if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || | |
| 4132 | + track->enc->channel_layout != AV_CH_LAYOUT_MONO) | |
| 4133 | + continue; | |
| 4134 | + | |
| 4135 | + for (j = 0; j < s->nb_streams; j++) { | |
| 4136 | + AVStream *stj= s->streams[j]; | |
| 4137 | + MOVTrack *trackj= &mov->tracks[j]; | |
| 4138 | + if (j == i) | |
| 4139 | + continue; | |
| 4140 | + | |
| 4141 | + if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO || | |
| 4142 | + trackj->enc->channel_layout != AV_CH_LAYOUT_MONO || | |
| 4143 | + trackj->language != track->language || | |
| 4144 | + trackj->tag != track->tag | |
| 4145 | + ) | |
| 4146 | + continue; | |
| 4147 | + track->multichannel_as_mono++; | |
| 4148 | + } | |
| 4149 | + } | |
| 4150 | + | |
| 4123 | 4151 | enable_tracks(s); |
| 4124 | 4152 | |
| 4125 | 4153 | |
| @@ -100,6 +100,7 @@ typedef struct MOVTrack { · 99 unmodified lines | ||
| 100 | 100 | int tag; ///< stsd fourcc |
| 101 | 101 | AVStream *st; |
| 102 | 102 | AVCodecContext *enc; |
| 103 | + int multichannel_as_mono; | |
| 103 | 104 | |
| 104 | 105 | int vos_len; |
| 105 | 106 | uint8_t *vos_data; |