[Libav-user] Set encoded video metadata [avformat]

Edson Menegatti edson at ckl.io
Thu Apr 30 14:53:36 CEST 2015


Hello everyone,

I'm using JavaCV, a wrapper for FFmpeg libraries, to encode camera frame
into a video in Android. I'm using the FFmpegFrameRecorder (
https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java)
class to perform the encoding process. The methods of interest are
startUnsafe() and record(IplImage image).

This works perfectly but I ran into an issue when trying to set the video
stream metadata. The goal would be to replicate the following command line:

    ffmpeg -i input.mp4 -metadata:s:v:0 rotate="90" output.mp4

But this code snippet fails to do so:

    if ((video_st = avformat_new_stream(oc, video_codec)) != null) {
             video_c = video_st.codec();
            video_c.codec_id(oformat.video_codec());
            video_c.codec_type(AVMEDIA_TYPE_VIDEO);
            ...
            AVDictionary avDictionary = new AVDictionary(null);
            av_dict_set(avDictionary, "rotate", "90", 0);
            video_st.metadata(avDictionaty);
            ....
    }
    avformat_write_header(oc, (PointerPointer) null);

This still encodes the video correctly, but the added metadata never
appears on ffprobe. Have anyone already experienced something like this?
Any idea on what could be the issue?

PS: the ffprobe output can be seen in this GitHub issue (
https://github.com/bytedeco/javacv/issues/132)

Thanks,
Edson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150430/973eaac0/attachment.html>


More information about the Libav-user mailing list