3

I am trying to fix the metadata of some old videos, so i would like to copy all streams audio video and subtitle and merge the metadata from a txt file.

I first dump the metadata with:

avconv -i out.mp4 -f ffmetadata metadata.txt

And then try to copy with the metadata:

avconv -i MOV_0732.mp4 -f ffmetadata -i metadata.txt -c:v copy -c:a copy -c:s copy -map 0 out.mp4

But the final metadata is untouched, if i move the metadata arguments to the end avconv does not start:

[buffer @ 0x2128d40] w:1280 h:720 pixfmt:yuv420p
[mpeg4 @ 0x2124660] Invalid pixel aspect ratio 65536/65536, limit is 255/255
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 1947-03-24 14:12:20
    Stream #0.0(eng): Video: mpeg4, yuv420p, 1280x720 [PAR 65536:65536 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 90k tbc
    Metadata:
      creation_time   : 1947-03-24 14:12:20
    Stream #0.1(eng): Audio: [0][0][0][0] / 0x0000, 48000 Hz, mono, s16, 200 kb/s
    Metadata:
      creation_time   : 1947-03-24 14:12:20
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
  Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Eliah Kagan
  • 119,640

1 Answers1

4

After reading the documentation and lots of searches i finally got the answer I wanted, the final command is:

avconv -i IN.mp4 -i METADATA.txt -map_metadata 1 -codec copy -map 0 OUT.mp4

This means:

  • use the inputs: IN.mp4 and METADATA.txt
  • map the metadata from input 1 (METADATA.txt)
  • copy all codecs (no transcoding)
  • map all streams from input 0 (IN.mp4)
  • write to OUT.mp4
Eliah Kagan
  • 119,640