VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. Hi there,

    I have the situation, that I like to concatenate two video files (mp4), however, they are in a slightly different resolution.

    Video 1 is 640x480 29.97fps, Video 2 is 480x360 24.87 fps.

    The full ouput of ffmpeg info for each file is below. I have a couple of tools available (ffmpeg, mkvtoolnix, Handbrake) but, to be honest, I don’t really know how to do this job.

    Appending the two files via mkvtoolnix obviously resulted in that the Video 2 file was not displayed properly (greenish artifacts), likely because of the resultion/fps mismatch when combining both files without any modifications.

    I would think that the only way is probably (re-)encoding Video 1 to the smaller resolution of Video 2 and then concateninating both. Is there any “automated” way I can do this with the tools I mentioned? Something like: “adjust resolution, fps and all other parameters according to the target file of video 2” and then re-encode?

    I am new to all of this and have limited knowledge of video conversion, so any help would be highly appreciated!

    Code:
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.25.101
      Duration: 00:26:30.99, start: 0.000000, bitrate: 833 kb/s
      Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], 696 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn (default)
        Metadata:
          handler_name    : VideoHandler
          vendor_id       : [0][0][0][0]
      Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
          vendor_id       : [0][0][0][0]
    Code:
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video2.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: isommp42
        creation_time   : 2017-02-19T18:08:03.000000Z
      Duration: 00:23:04.91, start: 0.000000, bitrate: 519 kb/s
      Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 480x360 [SAR 1:1 DAR 4:3], 421 kb/s, 24.87 fps, 24.87 tbr, 14350 tbn (default)
        Metadata:
          handler_name    : VideoHandler
          vendor_id       : [0][0][0][0]
      Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)
        Metadata:
          creation_time   : 2017-02-19T18:08:06.000000Z
          handler_name    : IsoMedia File Produced by Google, 5-11-2011
          vendor_id       : [0][0][0][0]
    Quote Quote  
  2. Easier might be to create a playlist for players that accept them. Otherwise one has to be reencoded to match the other (resolution, fps and any other differences you might not have noticed. I'd use AviSynth if I had to do the job, myself.

    Maybe someone will come up with a batch file you can use.
    Quote Quote  
  3. Use ffmpeg to mux them into a transport stream (Filename.TS). Transport streams are allowed to change codecs, frame sizes, etc. at any time. Most players can handle the switch.
    Quote Quote  
  4. Originally Posted by manono View Post
    Easier might be to create a playlist for players that accept them. Otherwise one has to be reencoded to match the other (resolution, fps and any other differences you might not have noticed. I'd use AviSynth if I had to do the job, myself.

    Maybe someone will come up with a batch file you can use.
    Thanks, I have no experience with AviSynth, unfotunately.I was hoping to do the reencoding (to match the slighly lower resolution file) in ffmpeg...
    Quote Quote  
  5. Originally Posted by jagabo View Post
    Use ffmpeg to mux them into a transport stream (Filename.TS).
    Thanks @jagabo, do you mind giving me the ffmpeg command to the the muxing of both files? At the very end, the combined video file should be for the Kodi mediacenter. Can I (or does it make sense) do ultimately convert the "muxed" .TS into a container like .mkv? Appreciate your help!
    Quote Quote  
  6. You need two things: a text file with the list of files to be concatenated, and the ffmpeg command line:

    list.txt
    Code:
    file 'filename1.mp4"
    file 'filename2.mp4"
    ffmpeg command line:

    Code:
    ffmpeg -f concat -safe 0 -i list.txt -c copy -hide_banner -y ffmpeg_append.ts
    Quote Quote  
  7. Thank you @jagabo! Somehow I am struggling with the input parameter, even if I specify absolute paths for both inputs.

    Both files are in the 'sources' dir and I am in that working directory (I am on macOS):

    Code:
    jabba@MacBook sources % ls
    file1.mp4		file2.mp4		list.txt
    jabba@MacBook sources % ffmpeg -f concat -safe 0 -i list.txt -c copy -hide_banner -y ffmpeg_append.ts
    [concat @ 0x126e04a60] Impossible to open 'file1.mp4"'
    list.txt: No such file or directory
    With absolute path:
    Code:
    jabba@MacBook sources % ffmpeg -f concat -safe 0 -i /Users/jabba/Downloads/sources/file1.mp4 -i /Users/jabba/Downloads/sources/file2.mp4 c copy -hide_banner -y ffmpeg_append.ts
    [concat @ 0x121e04d90] Line 4: unknown keyword 'ftypisom'
    /Users/jabba/Downloads/sources/file1.mp4: Invalid data found when processing input
    Any idea what I am doing wrong? A problem maybe with (missing) quotes? Thanks a ton!
    Quote Quote  
  8. Try using the full paths in the list.txt file.

    Oops, I just noticed a typo in my earlier post. The list.txt file should have single quotes around each filename.

    Code:
    file 'file1.mp4'
    file 'file2.mp4'
    Quote Quote  
  9. The single quotes did the trick Thanks for your help jagabo!
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!