Converting video formats and copying tags with ffmpeg

后端 未结 3 710
抹茶落季
抹茶落季 2020-12-10 03:43

I\'ve been trying to convert some videos I took on my camera to a compressed format in order to save some storage space. I figured out how to use ffmpeg to convert the video

相关标签:
3条回答
  • 2020-12-10 04:17

    Have a look at the documentation on dumping and loading metadata:

    FFmpeg is able to dump metadata from media files into a simple UTF-8-encoded INI-like text file and then load it back using the metadata muxer/demuxer.

    The process might look something like this:

    # First extract metadata
    ffmpeg -i original.mov -f ffmetadata metadata.txt
    # Next, transcode, including extracted metadata
    ffmpeg -i original.mov -f ffmetadata -i metadata.txt compressed.mp4
    

    I don't have a metadata-ful video to test with right now, but something like that should work.

    0 讨论(0)
  • 2020-12-10 04:28

    Use "-map_metadata 0:g" to copy all global metadata.

    0 means Input #0. g means global metadata.

    Here's my ffprobe result. enjoy!

    input.mp4

    [FORMAT]
    filename=input.mp4
    nb_streams=2
    nb_programs=0
    format_name=mov,mp4,m4a,3gp,3g2,mj2
    format_long_name=QuickTime / MOV
    start_time=0.000000
    duration=60.560500
    size=190252680
    bit_rate=25132246
    probe_score=100
    TAG:major_brand=mp42
    TAG:minor_version=1
    TAG:compatible_brands=mp42avc1
    TAG:creation_time=2016-05-14 10:01:17
    [/FORMAT]
    

    output.mp4

    [FORMAT]
    filename=output.mp4
    nb_streams=2
    nb_programs=0
    format_name=mov,mp4,m4a,3gp,3g2,mj2
    format_long_name=QuickTime / MOV
    start_time=0.000000
    duration=60.632000
    size=38636429
    bit_rate=5097826
    probe_score=100
    TAG:major_brand=isom
    TAG:minor_version=512
    TAG:compatible_brands=isomiso2avc1mp41
    TAG:creation_time=2016-05-14 01:01:17
    TAG:encoder=Lavf57.36.100
    [/FORMAT]
    
    0 讨论(0)
  • 2020-12-10 04:28

    To write all metadata (global, video, audio) to a file use

    ffmpeg -i in.mp4 -c copy -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -f ffmetadata in.txt
    

    To add all metadata from a file use

    ffmpeg -i in.mp4 -f ffmetadata -i in.txt -c copy -map_metadata 1 out.mp4
    
    0 讨论(0)
提交回复
热议问题