[Libav-user] How to corretly setting container and stream information when using an external encoder and using libavformat to pack the movie container

Paul B Mahol onemda at gmail.com
Sat Oct 26 12:07:43 EEST 2019


On 10/26/19, Ingmar Rieger <dev at irieger.net> wrote:
> Hello,
>
> I'm currently working on integrating Cineform file read and write into a
> small toy project for processing image sequences. Worked with exr
> sequences up until now but those are so storage heavy I decided to
> include a intermediate video format and with it being the only freely
> available one I decided to give cineform a go.
>
> Therefore I implemented a small file reader first using libavformat to
> open video containers and unpacking the stream while passing the frames
> to the Cineform-sdk for decompressing to have the reference decoder.

Using native cfhd decoder should be faster and better.

> Works fine so far.
>
> Now I'm trying the other way round and pack the frames with the cineform
> encoder and then create a movie container. I tried several approaches
> from several samples and ours of going through the Doxygen documentation
> and google searches etc.
>
> I'm able to write a file that works correct with my simple reader that
> will just extract package for package from the video stream and gets the
> number of frames right and the result looks fine. But there are still a
> few points I haven't managed to get to work correctly related to
> metadata of the container and the stream:
>
> 1. Set correct container and stream metadata. I copied the codec
> parameters I extracted from a read cineform example (exported from
> Blackmagic DaVinci Resolve) to begin with as I found no better solution
> for this use case yet.
>   - Bit rate is just the value from one sample and depends very much on
> the input resolution, I think the value is from a 4K sample file. Does
> this really matter? The value reported from "ffmpeg -i testout.mov" is
> completely different anyway, I assume it is calculated when calling
> "av_write_trailer"?
> 2. Correct frame rate/time base settings. Tried several examples, tried
> replicating what I extracted from them and made of the documentation
> regarding libav I found about this topic but as the link below (ffmpeg
> -i output) shows, the framerate is always wrong. Had combinations of
> parameters where I had clips with 16k fps etc.
> 3. Setting start time code of the stream/clip like in the example.
> 4. Set stream metadata like encoder information.
>
> Can somebody give me a hint how to set those data to have valid, well
> formed files?
>
> I have the basic structure of calls I do to libav extracted from my
> framework and packed it in a gist for better readability:
> https://gist.github.com/irieger/604125fba000f76095626696f34ae619
>
> Also there is the output of an "ffmpeg -i" call for each the reference
> file and the generated output in the file ffmpeg.
>
> Looking forward to some tips how to tackle this task.
>
> --
> Kind regards,
> Ingmar
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".


More information about the Libav-user mailing list