[FFmpeg-devel] [PATCH]Allow easy png streamcopying
Carl Eugen Hoyos
cehoyos at ag.or.at
Thu Apr 23 09:25:44 CEST 2015
Hi!
Stream-copying png is currently too difficult.
An alternative is to remove the extension from the apng muxer.
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index 4b31309..9090f92 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -23,6 +23,7 @@
#include "avformat.h"
#include "internal.h"
+#include "rawenc.h"
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/intreadwrite.h"
@@ -81,11 +82,14 @@ static int apng_write_header(AVFormatContext *format_context)
if (format_context->nb_streams != 1 ||
format_context->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
- format_context->streams[0]->codec->codec_id != AV_CODEC_ID_APNG) {
+ format_context->streams[0]->codec->codec_id != AV_CODEC_ID_APNG &&
+ format_context->streams[0]->codec->codec_id != AV_CODEC_ID_PNG) {
av_log(format_context, AV_LOG_ERROR,
- "APNG muxer supports only a single video APNG stream.\n");
+ "APNG muxer supports only a single video (A)PNG stream.\n");
return AVERROR(EINVAL);
}
+ if (format_context->streams[0]->codec->codec_id == AV_CODEC_ID_PNG)
+ return 0;
if (apng->last_delay.num > USHRT_MAX || apng->last_delay.den > USHRT_MAX) {
av_reduce(&apng->last_delay.num, &apng->last_delay.den,
@@ -201,6 +205,9 @@ static int apng_write_packet(AVFormatContext *format_context, AVPacket *packet)
{
APNGMuxContext *apng = format_context->priv_data;
+ if (format_context->streams[0]->codec->codec_id == AV_CODEC_ID_PNG)
+ return ff_raw_write_packet(format_context, packet);
+
if (!apng->prev_packet) {
apng->prev_packet = av_malloc(sizeof(*apng->prev_packet));
if (!apng->prev_packet)
@@ -220,6 +227,9 @@ static int apng_write_trailer(AVFormatContext *format_context)
AVIOContext *io_context = format_context->pb;
uint8_t buf[8];
+ if (format_context->streams[0]->codec->codec_id == AV_CODEC_ID_PNG)
+ return 0;
+
if (apng->prev_packet) {
flush_packet(format_context, NULL);
av_freep(&apng->prev_packet);
More information about the ffmpeg-devel
mailing list