Changes in FFV1 codec settings

Since FFmpeg 0.10 release FFV1 codec supports alpha channel which is getting
enabled when using PIX_FMT_RGB32 pixel format. This leads to incompatibility of
videos rendered in Blender with almost all external players (especially in OSX).

Seems that PIX_FMT_BGR0 is recommended to be used to make videos compatible with
older players which doesn't support alpha channel in FFV1.

Also added an option to switch to RGBA rendering if FFV1 codec is used and if RGBA
rendering is used FFV1 will be using PIX_FMT_RGB32 format which supports alpha channel.
This commit is contained in:
Sergey Sharybin 2012-02-24 09:49:44 +00:00
parent 1fbd91b8a1
commit dd0f151ba9
3 changed files with 20 additions and 3 deletions

@ -75,6 +75,7 @@ void filepath_ffmpeg(char* string, struct RenderData* rd);
extern void ffmpeg_set_preset(struct RenderData *rd, int preset); extern void ffmpeg_set_preset(struct RenderData *rd, int preset);
extern void ffmpeg_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf); extern void ffmpeg_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf);
extern void ffmpeg_verify_codec_settings(struct RenderData *rd); extern void ffmpeg_verify_codec_settings(struct RenderData *rd);
extern int ffmpeg_alpha_channel_supported(struct RenderData *rd);
extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index);
extern int ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); extern int ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str);

@ -506,12 +506,21 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
} }
// Keep lossless encodes in the RGB domain. // Keep lossless encodes in the RGB domain.
if (codec_id == CODEC_ID_HUFFYUV || codec_id == CODEC_ID_FFV1) { if (codec_id == CODEC_ID_HUFFYUV) {
/* HUFFYUV was PIX_FMT_YUV422P before */ /* HUFFYUV was PIX_FMT_YUV422P before */
c->pix_fmt = PIX_FMT_RGB32; c->pix_fmt = PIX_FMT_RGB32;
} }
if ( codec_id == CODEC_ID_QTRLE ) { if (codec_id == CODEC_ID_FFV1) {
if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
c->pix_fmt = PIX_FMT_RGB32;
}
else {
c->pix_fmt = PIX_FMT_BGR0;
}
}
if (codec_id == CODEC_ID_QTRLE ) {
if (rd->im_format.planes == R_IMF_PLANES_RGBA) { if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
c->pix_fmt = PIX_FMT_ARGB; c->pix_fmt = PIX_FMT_ARGB;
} }
@ -1422,4 +1431,11 @@ void ffmpeg_verify_codec_settings(RenderData *rd)
ffmpeg_set_expert_options(rd); ffmpeg_set_expert_options(rd);
} }
int ffmpeg_alpha_channel_supported(RenderData *rd)
{
int codec = rd->ffcodecdata.codec;
return ELEM(codec, CODEC_ID_QTRLE, CODEC_ID_FFV1);
}
#endif #endif

@ -722,7 +722,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P
Scene *scene = ptr->id.data; Scene *scene = ptr->id.data;
RenderData *rd = &scene->r; RenderData *rd = &scene->r;
if (rd->ffcodecdata.codec == CODEC_ID_QTRLE) if (ffmpeg_alpha_channel_supported(rd))
chan_flag |= IMA_CHAN_FLAG_ALPHA; chan_flag |= IMA_CHAN_FLAG_ALPHA;
} }
#endif #endif