Reputation: 809
I've got hundred movies from two video sources. One is MP4 with 25 fps
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MAH00607.MP4':
Metadata:
major_brand : MSNV
minor_version : 22675568
compatible_brands: MSNVmp42isom
creation_time : 2017-06-14T20:20:24.000000Z
Duration: 00:00:12.48, start: 0.000000, bitrate: 2795 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/iec61966-2-4), 1280x720 [SAR 1:1 DAR 16:9], 2664 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-06-14T20:20:24.000000Z
handler_name : Video Media Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
creation_time : 2017-06-14T20:20:24.000000Z
handler_name : Sound Media Handler
Second is AVI 29.81 fps
[avi @ 0x561e6733c640] non-interleaved AVI
Input #0, avi, from 'V-0018.AVI':
Duration: 00:00:11.04, start: 0.000000, bitrate: 4571 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 4515 kb/s, 28.18 fps, 28.18 tbr, 28.18 tbn, 28.18 tbc
Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 8000 Hz, 1 channels, u8, 64 kb/s
Before concating movies I convert them using this script. I result final, concated movie has incorrect time and after AVI movies (which are first in sequence) finish - movie freezes. I'll tried FFmpeg - Concat videos with different time base and Mulvya suggestion to recode avi files without success.
Can you propose other solution?
Upvotes: 5
Views: 5819
Reputation: 1263
For concat'ing videos there are a few properties that have to be equal. So before executing the concat, you better "normalize" or "format" all you inputs to share these properties:
You should be able to do this by just specifying all those parameters on your "normalizing" ffmpeg commandline. If you do not explictly specify one parameter, ffmpeg will attempt to copy the parameter from the input stream which would end up in again different formats for you.
A good start might be something like that:
ffmpeg -i %SOURCEFILE% -map 0:0 -map 0:1 -ac 2 -c:a aac -ar 48000 -vf format=yuv420p,scale=1280x720,yadif -video_track_timescale 60000 -c:v libx264 "%OUTPUT%.mp4"
Above is not tested, but it gives you a rough idea about how the cmd has got to look like. -codec copy is by the way something you cannot use at all given that you receive totally unknown files on input.
After all your inputs appear to share all the above parameters, you should be able to proceed with concat.
Upvotes: 14
Reputation: 21
The problem is the timebase. Ffmpeg adds an offset to the streams in the second, but otherwise doesn't change their timestamps even though it should.
I have never been able to get any timebase-related options to do anything. What did work for me: copy to mkv, which has 1/1000 timebase for video streams (ffmpeg reports this as '1k tbn'). This makes all timestamps consistent. Then concat.
For normal purposes, webm and mkv are basically the same thing, but mkv accepts H.264 while webm currently doesn't.
Note that timestamps with any slight jitter from rounding can lead to dropped or duplicated frames with poorly-designed fps-changing filters.
I'm pasting this answer to both questions, don't know if that's allowed.
Upvotes: 2
Reputation: 1970
First, you have different video framerates and both movies should be converted to equal framerate, for example, 25fps. Then you can join the movies.
When I was converting a lot of movies for myself, I used MediaCoder, a GUI-powered tool which can be used to convert multiple formats. This app have an easy interface, so you shouldn't face any troubles with it.
So you can consider it as a good solution with GUI and result preview.
Upvotes: 1