[FFmpeg-user] Leave everything unchanged except video encoding?

Tamás Németh nt1277 at gmail.com
Wed Aug 16 17:58:32 EEST 2017


Dear all,

I have some video files about which ffprobe says the following:

##############################################
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isom
    creation_time   : 2017-05-16T10:05:12.000000Z
  Duration: 00:12:38.85, start: 0.000000, bitrate: 4823 kb/s
    Stream #0:0(und): Data: none (mp4s / 0x7334706D) (default)
    Metadata:
      creation_time   : 2017-05-16T10:05:12.000000Z
    Stream #0:1(und): Data: none (mp4s / 0x7334706D) (default)
    Metadata:
      creation_time   : 2017-05-16T10:05:12.000000Z
    Stream #0:2(und): Video: mpeg4 (Simple Profile) (mp4v /
0x7634706D), yuv420p, 352x288 [SAR 29:26 DAR 319:234], 4724 kb/s, 25
fps, 25 tbr, 90k tbn, 25k tbc (default)
    Metadata:
      creation_time   : 2017-05-16T10:05:12.000000Z
    Stream #0:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 95 kb/s (default)
    Metadata:
      creation_time   : 2017-05-16T10:05:12.000000Z
Unsupported codec with id 0 for input stream 0
Unsupported codec with id 0 for input stream 1
##############################################

As you can see, these are quite unusual files. All I want to do is
to recode the video stream with H.264 (libx264) in order to make
the files tenth the size of the original, but leave EVERYTING ELSE
(i.e. the first two unsupported streams, the otherwise muted audio
stream and all the metadata) ABSOLUTELY UNCHANGED.

I tried the following command:
ffmpeg -i video.mp4 -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map_metadata
g -map_metadata s -copy_unknown -c:v libx264 -c:a copy video1.mp4
But this gave me the following error message:

##############################################
[mp4 @ 0x56458d876380] Could not find tag for codec none in stream #0,
codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters
?): Invalid argument
Error initializing output stream 0:2 --
Conversion failed!
##############################################

But even when I omit `-map 0:0 -map 0:1` in order not to
include these unsupported streams, the metadata still
slightly differs in the target file from the original:
##############################################
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2017-05-16T10:05:12.000000Z
    encoder         : Lavf57.71.100
  Duration: 00:12:38.88, start: 0.000000, bitrate: 523 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
352x288 [SAR 29:26 DAR 319:234], 421 kb/s, 25 fps, 25 tbr, 12800 tbn,
50 tbc (default)
    Metadata:
      creation_time   : 2017-05-16T10:05:12.000000Z
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 95 kb/s (default)
    Metadata:
      creation_time   : 2017-05-16T10:05:12.000000Z
      handler_name    : SoundHandler
##############################################

Is it possible with ffmpeg to keep every attribute
of this kind of original file except video encoding?
If yes, what commandline options shoud I use?

Thank you in advance,

Tamás Németh
IT sysadmin
Waterworks of Sopron, Hungary


More information about the ffmpeg-user mailing list