Opened 13 years ago

Closed 6 years ago

#1087 closed enhancement (fixed)

support decoding the CineForm codec

Reported by: dave rice Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: CFHD
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I found that ffmpeg can't read CineForm CFHD files.

There are some samples available here: http://samples.mplayerhq.hu/V-codecs/CFHD/
I may be able to provide more samples if needed.

ffmpeg -y -i MT_BeartoothHighway_1min_Cineform.avi anything.mp4
ffmpeg version N-34835-g4a9f466 Copyright (c) 2000-2012 the FFmpeg developers
  built on Mar  4 2012 08:53:39 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-libfreetype --cc=/usr/bin/gcc-4.2 --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass
  libavutil      51. 41.100 / 51. 41.100
  libavcodec     54.  7.100 / 54.  7.100
  libavformat    54.  2.100 / 54.  2.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 63.100 /  2. 63.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  7.100 /  0.  7.100
  libpostproc    52.  0.100 / 52.  0.100
[avi @ 0x7fb4c201ae00] decoding for stream 0 failed
[avi @ 0x7fb4c201ae00] Could not find codec parameters (Video: none (CFHD / 0x44484643), 1280x720)
Input #0, avi, from 'MT_BeartoothHighway_1min_Cineform.avi':
  Duration: 00:01:01.96, start: 0.000000, bitrate: 16472 kb/s
    Stream #0:0: Video: none (CFHD / 0x44484643), 1280x720, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
Video pixel format is unknown, stream cannot be encoded

Attachments (1)

color_709.avi (194.1 KB ) - added by shekh 9 years ago.

Download all attachments as: .zip

Change History (39)

comment:1 by Carl Eugen Hoyos, 13 years ago

Priority: normalwish
Reproduced by developer: set
Status: newopen

comment:2 by compn, 13 years ago

we need a specification or whitepaper or other info on this codec to speed up development of a decoder.

try contacting cineform , maybe they will share with us?

comment:3 by leandroprz, 12 years ago

I contacted Cineform support and they replied back:

===========
Thank you for you interest in Cineform. Please would you provide some more details of your project ?
===========

I'm no developer so I don't know what to reply.

comment:4 by compn, 12 years ago

tell them you want cineform cfhd decoding support in the ffmpeg project.
http://www.ffmpeg.org
that may answer their questions.

comment:5 by Ian Kennedy, 12 years ago

FWIW: Cineform is on it's way to becoming a SMPTE standard as "VC5"

https://kws.smpte.org/apps/group_public/project/details.php?project_id=15

comment:6 by compn, 12 years ago

someone could try again to get a response back from cineform...

comment:7 by Elon Musk, 11 years ago

Is there dll somewhere?

in reply to:  7 comment:8 by Hendrik, 11 years ago

Replying to richardpl:

Is there dll somewhere?

There is a binary decoder here, for DirectShow/VfW as well as QuickTime (Mac):
http://cineform.com/gopro-cineform-decoder

comment:9 by Ridley Combs, 10 years ago

Apparently Cineform has now been adopted as VC-5 by SMPTE; the spec documents are here: http://standards.smpte.org/search?fulltext=VC-5&smptes-status=in-force&submit=yes&content-group=smptes&x=0&y=0

comment:10 by Elon Musk, 10 years ago

I'm not subscribed and I'm not going to pay for spec documents.

comment:11 by Casey Hancock, 9 years ago

With VR coming down the pipeline, we are looking at the best way of dealing with much higher resolution files efficiently and it seems that for windows, Cineform may be the best way to go when dealing with moving between Adobe and ffmpeg. What is the proper place to try to contribute to VC-5 decoding (any maybe even encoding?) support to be added to avcodec. Also, what is needed to make this happen - I can gather documents and contact people easily enough.

Also, what is necessary to increase the priority for the ticket?

comment:12 by Elon Musk, 9 years ago

Get specification and contact developers, me for example.

comment:13 by Elon Musk, 9 years ago

I got specification.

comment:14 by Kieran Kunhya, 9 years ago

Specification is not very useful, please provide more samples.

comment:15 by Reto Kromer, 9 years ago

I can provide file examples on Monday.

comment:16 by Reto Kromer, 9 years ago

Here I up-loaded two short clips: http://avpres.net/CineForm/

comment:17 by Kieran Kunhya, 9 years ago

Thanks, can you document the expected resolution of these files?

comment:18 by Carl Eugen Hoyos, 9 years ago

bigger_res.mov: 4512x2952
lower_res.mov: 3312x2488
Or do I miss something?

comment:19 by Kieran Kunhya, 9 years ago

Asking because these files are completely different internally to other CFHD samples I have.

comment:20 by Carl Eugen Hoyos, 9 years ago

Just guessing: The new files correspond to the VC-5 specification while the files we already had are years old and use another codec (with the same fourcc)?

comment:21 by Kieran Kunhya, 9 years ago

No files in the wild comply with VC-5 at this time.

comment:22 by Carl Eugen Hoyos, 9 years ago

So VC-5 is just based on Cineform but different? What fourcc does it use?

comment:23 by Kieran Kunhya, 9 years ago

VC-5 uses some of the features from Cineform but it's a different codec.
The fourcc's are not standardised yet but I guess it will use "VC-5" or similar.

I get the feeling this is just marketing though with the intent that Cineform can say their codec is standardised but you have to buy their implementation in order to play actual files in the real-world.

in reply to:  23 ; comment:24 by Carl Eugen Hoyos, 9 years ago

Replying to kierank:

VC-5 uses some of the features from Cineform but it's a different codec.
The fourcc's are not standardised yet but I guess it will use "VC-5" or similar.

Thank you for explaining!

I get the feeling this is just marketing though with the intent that Cineform can say their codec is standardised but you have to buy their implementation in order to play actual files in the real-world.

The scandal is apparently that SMPTE allowed to be (ab)used for this marketing gag.

in reply to:  24 comment:25 by Kieran Kunhya, 9 years ago

The scandal is apparently that SMPTE allowed to be (ab)used for this marketing gag.

This is normal in SMPTE - AVC-Intra is another example.

comment:26 by Reto Kromer, 9 years ago

Sorry for stepping in that late!
Yes, it's 4512 x 2952 pixel resp. 3312 x 2488 pixel.
Yes, it's scandalous that SMPTE accepted CineForm/VC-5 as a standard without having to document the format.

comment:27 by Kieran Kunhya, 9 years ago

Interestingly these files seem to have an internal resolution of a quarter of what they are meant to be. Perhaps they are encoded as quadrants or something.

What pixel format are they (YUV, RGB, ???) - nothing looks correct so far. There appears to be 4 planes though and I don't understand how a film scanner can scan alpha.

comment:28 by Reto Kromer, 9 years ago

Yes, the sensor has 4 quadrants. Bayer is used. I'll check next week, if I can find the pixel format. The CLI MediaInfo? gives me CFHD; I'll try also a hex dump if you don't haven't yet done it.

in reply to:  27 comment:29 by Carl Eugen Hoyos, 9 years ago

Replying to kierank:

What pixel format are they (YUV, RGB, ???) - nothing looks correct so far. There appears to be 4 planes though and I don't understand how a film scanner can scan alpha.

If it is a Bayer format, please look at AV_PIX_FMT_BAYER_BGGR8 and AV_PIX_FMT_BAYER_BGGR16 and their friends. If it is CMYK, you will find a conversion routine in mjpegdec.c. But in any case, if you have a patch that produces a recognizable image with wrong colours (and resolution) please post it, others could improve it.

comment:30 by Reto Kromer, 9 years ago

It should be RGR. I’ll try to find out more on Monday.

comment:31 by Reto Kromer, 9 years ago

Last edited 9 years ago by Reto Kromer (previous) (diff)

comment:32 by Reto Kromer, 9 years ago

The packet will be decoded to a 16 bit Bayer space image. A single 16 bit ushort per pixel. Are you deriving the size based off of 4 components per pixel RGBA (4 x 16 bit)? This may be be where you are miscalculating resolution. Information from the CineForm SDK definitions:

Original to encoder

CFHD_PixelFormat = CFHD_PIXEL_FORMAT_BYR4 = FOUR_CHAR_CODE('BYR4')

«RAW» Bayer 16 bits per pixel received by the encoder should also be used as the decoded interpretation.

Compressed

CFHD_PixelFormat = CFHD_PIXEL_FORMAT_CFHD = FOUR_CHAR_CODE('CFHD')

CFHD_EncodedFormat = CFHD_ENCODED_FORMAT_BAYER

CFHD_BayerFormat (Bayer phase) will be one of the following, but can change every frame based on stabilisation

typedef enum CFHD_BayerFormat {
    CFHD_BAYER_FORMAT_UNKNOWN = -1,
    CFHD_BAYER_FORMAT_RED_GRN = 0,
    CFHD_BAYER_FORMAT_GRN_RED = 1,
    CFHD_BAYER_FORMAT_GRN_BLU = 2,
    CFHD_BAYER_FORMAT_BLU_GRN = 3,
} CFHD_BayerFormat;

Hope this helps!

by shekh, 9 years ago

Attachment: color_709.avi added

comment:33 by shekh, 9 years ago

I saved color_709.avi with vfw codec 9.0.5, option "use 709" was on.
I noticed value at offset 203F, it is either 01 (709 off) of 02 (709 on).
Hope this helps.

comment:34 by v0lt, 9 years ago

On this page there are samples that ffplay not play.
http://www.siliconimaging.com/DigitalCinema/gallery_footage.html
Not all samples are available, but something can be downloaded.

comment:35 by Carl Eugen Hoyos, 8 years ago

Keywords: CineForm removed

comment:36 by stib, 7 years ago

Anyone contacted this guy? Unless I'm reading it wrong, from this post he seems to have reverse-engineered CFHD successfully. https://medium.com/@kierank_/reverse-engineering-the-gopro-cineform-codec-7411312bfe1c

comment:37 by Hendrik, 7 years ago

Cineform is already supported in FFmpeg based on exactly that work. Also, a few months ago the SDK was also officially released.

comment:38 by Kieran Kunhya, 6 years ago

Resolution: fixed
Status: openclosed

Most samples work nowadays.

Note: See TracTickets for help on using tickets.