[FFmpeg-user] Convert to .MP4 using ffmpeg preserving KLV metadata

Mar Andrés López mar.andres.l at gmv.com
Thu Jan 7 14:48:44 EET 2021


Dear All,


I have the following video klv.mpeg, composed by two streams, a video stream and a klv data stream. As you can see:


[mpegts @ 00000146ceeaaec0] start time for stream 1 is not set in estimate_timings_from_pts
Input #0, mpegts, from 'klv.mpeg':
  Duration: 00:01:30.80, start: 0.500000, bitrate: 1347 kb/s
  Program 1
    Stream #0:0[0x3e8]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt470bg, progressive), 640x480 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr, 90k tbn, 60 tbc
    Side data:
      cpb: bitrate max/min/avg: 1000000/0/0 buffer size: 1835008 vbv_delay: N/A
    Stream #0:1[0x90]: Data: klv (KLVA / 0x41564C4B)


I am trying to preserve the klv data stream when converting it to mp4 but it seems imposible.


  1.  The first thing I am trying is to try to copy the data codec with the following command:

ffmpeg -i klv.mpeg -map 0:v -vcodec h264 -map 0:a? -acodec aac -map 0:d? -codec copy output.mp4


But it results in the following error:


[mp4 @ 000001ff0d8c8fc0] Could not find tag for codec klv in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

  2.  The second thing that I am trying is to convert just the video and audio with the same command as above without the data stream.


ffmpeg -i klv.mpeg -map 0:v -vcodec h264 -map 0:a? -acodec aac output.mp4


Then i extract just the klv with the following command:


ffmpeg -i klv.mpeg -map 0:d -codec copy -f data output.klv


After that I try to join the output.mp4 and the output.klv with:


ffmpeg -i output.mp4 -i output.klv -map 0:v -map 0:a? -map 1:d? final.mp4


But the error is:


[mov,mp4,m4a,3gp,3g2,mj2 @ 00000288d7b2c040] Format mov,mp4,m4a,3gp,3g2,mj2 detected only with low score of 1, misdetection possible!
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000288d7b2c040] moov atom not found
prueba.mp4: Invalid data found when processing input


I tried to use the -movflags faststart as I have read also but with no successfull result.


Is there anyway to do this?


A lot of thanks in advance

P Please consider the environment before printing this e-mail.


More information about the ffmpeg-user mailing list