I have been trying to write a script to merge multiple .mp4
videos using ffmpeg. As part of this process, while trying to alter the size found that it alters the timebase. However, for ffmpeg - concat demux
all streams should be same or else after merge only the first part of the video plays well and stops abruptly.
I have tried both terminal way and also using fluent-ffmpeg
. But unfortunately both gives same result.
- Original video Ex, org_video_1280x720.mp4
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 812 kb/s, 25 fps, 25 tbr, 30k tbn, 60k tbc (default)
- after scaling down to 640x360 via terminal
ffmpeg -i org_video_1280x720.mp4 -strict -2 -vf "scale=640:360" new_video_640x360.mp4
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360, 256 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
- The fluent-ffmpeg way of sizing
ffmpeg(`/path/to/org_video_1280x720.mp4`).size(`640x360`). autopad().output(`/path/to/new_video_640x360.mp4`)
.on('error', function(err, stdout, stderr) {
console.log('Error: ' + err.message);
console.log('STD Err: ' + stderr);
})
.on('end', function() {
console.log('Split & Resizing Completed!');
}).run();
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360, 253 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Notice the tbn & tbc
changes after resizing; Actually I have to merge this with other video only by changing the resolution (as they were with these 25 fps, 25 tbr, 30k tbn, 60k tbc
stream values); However as it alters the time_base
, I was unable to do it. Hope, I am missing something in the process, as I am bit new to audio/video process. Looking for some tips/guidance to get this done!