+ /* The command line flac encoder defaults to placing a seekpoint
+ * every 10s. So one might add padding to allow that later
+ * but there seems to be no simple way to get the duration here.
+ * So just add the amount requested by the user. */
+ if (padding)
+ flac_write_block_padding(s->pb, padding, 1);
+
+ return 0;
+}
+
+static int flac_init(struct AVFormatContext *s)
+{
+ AVCodecParameters *par;
+ FlacMuxerContext *c = s->priv_data;
+ int i;
+
+ c->audio_stream_idx = -1;
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (c->audio_stream_idx >= 0 || st->codecpar->codec_id != AV_CODEC_ID_FLAC) {
+ av_log(s, AV_LOG_ERROR, "Invalid audio stream. Exactly one FLAC "
+ "audio stream is required.\n");
+ return AVERROR(EINVAL);
+ }
+ par = s->streams[i]->codecpar;
+ c->audio_stream_idx = i;
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
+ av_log(s, AV_LOG_WARNING, "Video stream #%d is not an attached picture. Ignoring\n", i);
+ continue;
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
+ av_log(s, AV_LOG_ERROR, "GIF image support is not implemented.\n");
+ return AVERROR_PATCHWELCOME;
+ } else if (!c->write_header) {
+ av_log(s, AV_LOG_ERROR, "Can't write attached pictures without a header.\n");
+ return AVERROR(EINVAL);
+ }
+ c->waiting_pics++;
+ } else {
+ av_log(s, AV_LOG_ERROR, "Only audio streams and pictures are allowed in FLAC.\n");
+ return AVERROR(EINVAL);
+ }
+ }
+ if (c->audio_stream_idx < 0) {
+ av_log(s, AV_LOG_ERROR, "No audio stream present.\n");
+ return AVERROR(EINVAL);
+ }
+