bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.41k stars 1.57k forks source link

Editing Metadata for existing videos #817

Open odemiral opened 6 years ago

odemiral commented 6 years ago

Hi, apologies if this has been asked before but I couldn't find any info about this, as the title suggests, I'm trying to edit metadata for existing videos (MKV container, H264) I was under the impression that I can use FFmpegFrameRecorder object to open and edit metadata of any videos, yet this doesn't seem to work for me.

Here's the sample code:

FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("absolute-path-to-video", 0, 0, 0); recorder.setVideoMetadata("ARTIST", "ARTIST_TEST");

I was wondering if someone can give me some insights of why this doesn't working.

Thanks in advance!

saudet commented 6 years ago

No, that's not supported, but we could add that feature pretty easily. Contributions are welcome!

odemiral commented 6 years ago

I could give a hand with that, I’m guessing we can edit metadata by getting AVFormatContext and editing its AVDictionary variable that holds metadata data?

My question is do you think it would be possible to edit metadata without encoding the whole video using FFMPEG?

saudet commented 6 years ago

Yes, it should work by copying the whole stream: https://github.com/bytedeco/javacv/blob/master/samples/PacketRecorderTest.java But there's apparently a problem with that right now, see issue #818. It would be great if you could take a look at this with @alicanalbayrak.

ruke commented 6 years ago

record must start and stop after setVideoMetaData

Tengyyy commented 1 year ago

Any update on this issue? Is it possible to copy streams without re-encoding?

saudet commented 1 year ago

AFAIK, there was never any need to reencode.