[Libav-user] DV50 to M2V Artefacts (Color Ranges)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] DV50 to M2V Artefacts (Color Ranges)

Gavin Smith



I am decoding the first frame of a DV video (PAL) and then encoding it repeatedly back again into M2V wrapped in MpegTS (ignoring audio).  I notice that the encoded frame has some interesting artefacts which I had originally put down to difference in color primaries, but I'm not so sure anymore.

The original clip is available online:
http://www.gvgdevelopers.com/K2DevGuide/Clips2/PAL_SD_DV50_colorbar.mxf


I've captured some images from my application:
Decoded: http://imgur.com/a/V083K
Encoded: http://imgur.com/a/zgj4I


From the above images, we can see that the dumped decoded frame looks okay.  The error occurs once it goes into the encoder.

A few questions:

1. The color characteristics of the DV's AVCodecContext and AVFrame are not explicitly set; they are all 'not specified'.  I fear I may be using the wrong color ranges. Is the 'not specified' in the data structures expected?  Is that common for the other decoders too? Is this considered a bug?  I've tried explicitly setting these properties in the AVFrame to the M2V encoder, but I may be using incorrect values. Nonetheless, I suspect the source clip is BT.601 625.

2. Using previous experience, do you know what the discrepancy in colors may be a symptom of?  It's quite interesting how the yellow bar shadows all the way down to the bottom of the encoded image but not in the decoded image.

3. The AVFrame of the decoded material indicates that the top_field_first = 0 and the field_order is BB.  I would expect top_field_first to be '1' and the field_order to be TT for PAL.  I do know that DV video is a bit quirky though. Any further explanation would be much appreciated.

4. Out of interest, can I use SWScale to convert the color primaries/ranges?


On a side note, the output/encoded image is being streamed to VLC to make observation easier (but I don't think this has any bearing on the output).

Thanks.

Gavin.
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: DV50 to M2V Artefacts (Color Ranges)

Carl Eugen Hoyos-2
2017-05-18 22:45 GMT+02:00 Gavin Smith <[hidden email]>:

> I am decoding the first frame of a DV video (PAL) and then encoding it
> repeatedly back again into M2V wrapped in MpegTS (ignoring audio).
> I notice that the encoded frame has some interesting artefacts which I
> had originally put down to difference in color primaries, but I'm not so
> sure anymore.
>
> The original clip is available online:
> http://www.gvgdevelopers.com/K2DevGuide/Clips2/PAL_SD_DV50_colorbar.mxf

Sample is (very!) useful, please also provide the command line
that allows you to reproduce the issue together with the
complete, uncut console output.

If the issue is reproducible without using network (ie with an
output file), please use files instead of a network as this will
make reproduce the issue infinitely simpler,

And please simplify the command line as much as possible
(but with setting a small quantizer).

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: DV50 to M2V Artefacts (Color Ranges)

Gavin Smith
Hi Carl,

Thanks for your assistance! Just to ensure we are on the same page, I had (naively?) assumed that everyone in this mailing list was using the libav* filters via the C API. Apologies if that is not the case.

Nonetheless, do you suggest I attempt to reproduce the problem using the command line?


Best Regards,

Gavin.



From: Carl Eugen Hoyos <[hidden email]>
To: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <[hidden email]>
Sent: Friday, 19 May 2017, 0:42
Subject: Re: [Libav-user] DV50 to M2V Artefacts (Color Ranges)

2017-05-18 22:45 GMT+02:00 Gavin Smith <[hidden email]>:

> I am decoding the first frame of a DV video (PAL) and then encoding it
> repeatedly back again into M2V wrapped in MpegTS (ignoring audio).
> I notice that the encoded frame has some interesting artefacts which I
> had originally put down to difference in color primaries, but I'm not so
> sure anymore.
>
> The original clip is available online:
> http://www.gvgdevelopers.com/K2DevGuide/Clips2/PAL_SD_DV50_colorbar.mxf

Sample is (very!) useful, please also provide the command line
that allows you to reproduce the issue together with the
complete, uncut console output.

If the issue is reproducible without using network (ie with an
output file), please use files instead of a network as this will
make reproduce the issue infinitely simpler,

And please simplify the command line as much as possible
(but with setting a small quantizer).

Carl Eugen

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user



_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: DV50 to M2V Artefacts (Color Ranges)

Gavin Smith

Carl, I think you have given me something to go on.

I tried both:
ffmpeg -i file.mxf -vcodec libx264 -b:v 1200k ./output.ts
ffmpeg -i file.mxf -vcodec mpeg2ideo -b:v 1200k ./output.ts


...and the transcoded clip was fine. I didn't need to lower the default quantizer.  I'll try write a sample application to try uncover my problem.


Gavin.


From: Gavin Smith <[hidden email]>
To: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <[hidden email]>
Sent: Friday, 19 May 2017, 9:33
Subject: Re: [Libav-user] DV50 to M2V Artefacts (Color Ranges)

Hi Carl,

Thanks for your assistance! Just to ensure we are on the same page, I had (naively?) assumed that everyone in this mailing list was using the libav* filters via the C API. Apologies if that is not the case.

Nonetheless, do you suggest I attempt to reproduce the problem using the command line?


Best Regards,

Gavin.



From: Carl Eugen Hoyos <[hidden email]>
To: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <[hidden email]>
Sent: Friday, 19 May 2017, 0:42
Subject: Re: [Libav-user] DV50 to M2V Artefacts (Color Ranges)

2017-05-18 22:45 GMT+02:00 Gavin Smith <[hidden email]>:

> I am decoding the first frame of a DV video (PAL) and then encoding it
> repeatedly back again into M2V wrapped in MpegTS (ignoring audio).
> I notice that the encoded frame has some interesting artefacts which I
> had originally put down to difference in color primaries, but I'm not so
> sure anymore.
>
> The original clip is available online:
> http://www.gvgdevelopers.com/K2DevGuide/Clips2/PAL_SD_DV50_colorbar.mxf

Sample is (very!) useful, please also provide the command line
that allows you to reproduce the issue together with the
complete, uncut console output.

If the issue is reproducible without using network (ie with an
output file), please use files instead of a network as this will
make reproduce the issue infinitely simpler,

And please simplify the command line as much as possible
(but with setting a small quantizer).

Carl Eugen

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user



_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: DV50 to M2V Artefacts (Color Ranges)

Gavin Smith
I was being very silly.  The input pix_fmt to the encoder was 'YUV422P'; however, I was setting it to 'YUV420P' :/  I think I was distracting myself with the color ranges/primaries configuration.

After setting it to the correct pix_fmt, the quality was very poor, so I altered the qmin/qmax to 2.  Voila!



A few of my questions remain:

1. The color characteristics of the DV's AVCodecContext and AVFrame are not explicitly set; they are all 'not specified'.  I tried a MPEG clip from the same set of test clips and the same result. Is that common for the other decoders too? Is this considered a bug?  If they're not set, should I explicitly set the values?

2. DV video is bottom field.  How does FFmpeg handle this?  On decoding can I transition all the lines down by 1 line to change the order?  Is there a function to perform this operation?

3. Out of interest, can I use SWScale to convert the color primaries/ranges?

Gavin.



From: Gavin Smith <[hidden email]>
To: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <[hidden email]>
Sent: Friday, 19 May 2017, 11:24
Subject: Re: [Libav-user] DV50 to M2V Artefacts (Color Ranges)


Carl, I think you have given me something to go on.

I tried both:
ffmpeg -i file.mxf -vcodec libx264 -b:v 1200k ./output.ts
ffmpeg -i file.mxf -vcodec mpeg2ideo -b:v 1200k ./output.ts


...and the transcoded clip was fine. I didn't need to lower the default quantizer.  I'll try write a sample application to try uncover my problem.


Gavin.




_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user