[FFmpeg-devel] [PATCH 3/4] avformat/movenc: set XDCAM codec tag correctly

Dave Rice dave at dericed.com
Wed Jun 11 18:22:12 CEST 2014


On Oct 11, 2013, at 7:56 PM, Michael Niedermayer <michaelni at gmx.at> wrote:

> On Mon, Oct 07, 2013 at 04:24:39PM -0400, Timothy Gu wrote:
>> On Monday, October 7, 2013, Michael Niedermayer wrote:
>> 
>>> Signed-off-by: Michael Niedermayer <michaelni at gmx.at <javascript:;>>
>>> ---
>>> libavformat/movenc.c |   63
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 63 insertions(+)
>>> 
>>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>>> index f3058bd..cc8800b 100644
>>> --- a/libavformat/movenc.c
>>> +++ b/libavformat/movenc.c
>>> @@ -897,6 +897,66 @@ static AVRational find_fps(AVFormatContext *s,
>>> AVStream *st)
>>>     return rate;
>>> }
>>> 
>>> +static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack
>>> *track)
>>> +{
>>> +    int tag = MKTAG('m', '2', 'v', '1'); //fallback tag
>>> +    int interlaced = track->enc->field_order != AV_FIELD_UNKNOWN
>>> +                  && track->enc->field_order != AV_FIELD_PROGRESSIVE;
>>> +    AVStream *st = track->st;
>>> +    int rate = av_q2d(find_fps(s, st));
>>> +
>>> +    if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) {
>>> +        if (track->enc->width == 1280 && track->enc->height == 720) {
>>> +            if (!interlaced) {
>> 
>> 
>> 
>>> +                if      (rate == 24) tag = MKTAG('x','d','v','4');
>>> +                else if (rate == 25) tag = MKTAG('x','d','v','5');
>>> +                else if (rate == 30) tag = MKTAG('x','d','v','1');
>>> +                else if (rate == 50) tag = MKTAG('x','d','v','a');
>>> +                else if (rate == 60) tag = MKTAG('x','d','v','9');
>>> +            }
>>> +        } else if (track->enc->width == 1440 && track->enc->height ==
>>> 1080) {
>>> +            if (!interlaced) {
>>> +                if      (rate == 24) tag = MKTAG('x','d','v','6');
>>> +                else if (rate == 25) tag = MKTAG('x','d','v','7');
>>> +                else if (rate == 30) tag = MKTAG('x','d','v','8');
>>> +            } else {
>>> +                if      (rate == 25) tag = MKTAG('x','d','v','3');
>>> +                else if (rate == 30) tag = MKTAG('x','d','v','2');
>>> +            }
>>> +        } else if (track->enc->width == 1920 && track->enc->height ==
>>> 1080) {
>>> +            if (!interlaced) {
>>> +                if      (rate == 24) tag = MKTAG('x','d','v','d');
>>> +                else if (rate == 25) tag = MKTAG('x','d','v','e');
>>> +                else if (rate == 30) tag = MKTAG('x','d','v','f');
>>> +            } else {
>>> +                if      (rate == 25) tag = MKTAG('x','d','v','c');
>>> +                else if (rate == 30) tag = MKTAG('x','d','v','b');
>>> +            }
>>> +        }
>>> +    } else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) {
>>> +        if (track->enc->width == 1280 && track->enc->height == 720) {
>>> +            if (!interlaced) {
>>> +                if      (rate == 24) tag = MKTAG('x','d','5','4');
>>> +                else if (rate == 25) tag = MKTAG('x','d','5','5');
>>> +                else if (rate == 30) tag = MKTAG('x','d','5','1');
>>> +                else if (rate == 50) tag = MKTAG('x','d','5','a');
>>> +                else if (rate == 60) tag = MKTAG('x','d','5','9');
>>> +            }
>>> +        } else if (track->enc->width == 1920 && track->enc->height ==
>>> 1080) {
>>> +            if (!interlaced) {
>>> +                if      (rate == 24) tag = MKTAG('x','d','5','d');
>>> +                else if (rate == 25) tag = MKTAG('x','d','5','e');
>>> +                else if (rate == 30) tag = MKTAG('x','d','5','f');
>>> +            } else {
>>> +                if      (rate == 25) tag = MKTAG('x','d','5','c');
>>> +                else if (rate == 30) tag = MKTAG('x','d','5','b');
>>> +            }
>>> +        }
>>> +    }
>> 
>> 
>> Feel free to ignore: shouldn't switch case be simpler here?
> 
> feel free to change it to switch/case, iam happy with either
> 
> applied
> 
> [...]

Late comments, but this patch sets an xdcam fourcc based on the output having a fix of codec, frame rate, frame size and pixel format, but data rate should also be considered.
For instance:
ffmpeg -f lavfi -i mandelbrot=s=1920x1080 -t 1 -c:v mpeg2video notxdcam.mov

produces a file with the xdcam fourcc of xdve. Normally xdve implies a date rate of 35 Mb/sec, but the output using a default mpeg2video data rate at 5,667 kb/s. This may lead to some compatibility issues.
Dave Rice



More information about the ffmpeg-devel mailing list