avconv - concat .mp4 without quality loss and huge file size
Asked Answered
B

1

0

I am testing out concating mp4 files together and have come across one way to do it that is working but is creating huge file sizes.

my original videos are mp4 and I started out trying to convert them to mpeg after following other guides but found that mpeg would not convert as my file is 1fps and mpeg does not support that.

media@v2:~/mp4_test$ avconv -i video1.mp4 video1.mpeg
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
  Metadata:
    major_brand     : f4v
    minor_version   : 0
    compatible_brands: isommp42m4v
    creation_time   : 2014-12-02 13:00:03
  Duration: 00:59:56.90, start: 0.000000, bitrate: 120 kb/s
    Stream #0.0(eng): Video: h264 (Main), yuv420p, 800x600, 120 kb/s, 1 fps, 90k tbn
    Metadata:
      creation_time   : 2014-12-02 13:00:03
[mpeg1video @ 0x10c53a0] MPEG1/2 does not support 5/1 fps
Output #0, mpeg, to 'video1.mpeg':
  Metadata:
    major_brand     : f4v
    minor_version   : 0
    compatible_brands: isommp42m4v
    creation_time   : 2014-12-02 13:00:03
    Stream #0.0(eng): Video: mpeg1video, yuv420p, 800x600, q=2-31, 200 kb/s, 90k tbn, 5 tbc
    Metadata:
      creation_time   : 2014-12-02 13:00:03
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg1video)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I read a suggestion to add -r 23.967 for the framerate but that still does not work.


I then found that I could convert the files to .avi and concat them successfully.

convert to avi

avconv -i video1.mp4 -r 23.967 -qscale 1 video1.avi

avconv -i video2.mp4 -r 23.967 -qscale 1 video2.avi

then concat

avconv -i concat:video1.avi\|video2.avi -c copy video.mp4

Unfortunately this new file is over 1gb when the original is about 50mb. I have tried adjusting the qscale but I just lose too much quality and still can't get the file size down.

is there a good suggestion on what file type I should be converting to first before I can concat them? I don't mind the file size being a bit bigger, but preferably not too much.

Thanks

Bromeosin answered 4/12, 2014 at 5:44 Comment(0)
C
2

If you don't mind changing the format of the file you can turn them into a single Matroska file by using mkvmerge tool.

The string would be quite simple:

mkvmerge -o output.mkv file1.mp4 + file2.mp4
Compression answered 22/4, 2015 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.