0

I need to merge two different video files and I am using LosslessCut for the task. Yet it says that the files need to have the same codecs, dimension, framerate.

Source is mkv V_MPEG4/ISO/AVC with Vorbis, destination is avi xvid with ac3.

  • Full parameters of both files using ffmpeg encoding
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 6.20 MiB
Duration                                 : 46 s 280 ms
Overall bit rate                         : 1 124 kb/s
Writing application                      : Lavf58.45.100

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings                          : BVOP2
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (MPEG)
Muxing mode                              : Packed bitstream
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 46 s 280 ms
Bit rate                                 : 921 kb/s
Width                                    : 576 pixels
Height                                   : 432 pixels
Display aspect ratio                     : 3:2
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.148
Stream size                              : 5.08 MiB (82%)
Writing library                          : XviD 64

Audio
ID                                       : 1
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : 2000
Duration                                 : 46 s 254 ms
Bit rate mode                            : Constant
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 28.711 FPS (1536 SPF)
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 1.06 MiB (17%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 35  ms (0.87 video frame)
Interleave, preload duration             : 347  ms
Service kind                             : Complete Main
  • Parameters of the file that I want to recode/encode (in order to have parameters shown above):
Format                                   : Matroska
Format version                           : Version 4
File size                                : 2.36 MiB
Duration                                 : 27 s 999 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 706 kb/s
Writing application                      : Lavf58.45.100
Writing library                          : Lavf58.45.100
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 27 s 933 ms
Bit rate                                 : 564 kb/s
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 30.303 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.045
Stream size                              : 1.88 MiB (80%)
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : Vorbis
Format settings, Floor                   : 1
Codec ID                                 : A_VORBIS
Duration                                 : 27 s 837 ms
Bit rate mode                            : Variable
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Delay relative to video                  : -52 ms
Stream size                              : 435 KiB (18%)
Writing application                      : Lavc58.91.100
Writing library                          : libVorbis (Reducing Environment) (20200704 (Reducing Environment))
Default                                  : Yes
Forced                                   : No

How can I please extract all the data from the destination file and input it as a parameter to a FFmpeg source file encode command? I was looking up if there is a script for this, but can not find.

2
  • There are 3 files involved here: the two different video files you need to "merge", and the output that you want to be a certain format, but you only showed info about 2 files.
    – llogan
    Mar 18 at 22:35
  • @llogan thx, for the feedback, when i was talking about source and destination i meant that i want source file to have parameters of the destination file... or at least all possible parameters.
    – 16851556
    Mar 23 at 21:18
0

You have to do it manually.

ffmpeg -i input.mkv -c:v libxvid -vf scale=-2:432 -r 25 -profile:v 0 -level 5 -vtag XVID -mpeg_quant 1 -b:v 921k -bf 2 -c:a ac3 -ac 2 -ar 44100 output.avi
0

I have not found any good solution yet, but there is an Linux bash script attempt to automate the task of finding differences in video fragments to be merged and suggest commands to fix the differences.

0

This is close: "scale one video to match another without pre-defining the dimensions", put two videos side-by-side and have the 2nd video scale to match the 1st:

ffmpeg -i vid1.mp4 -i vid2.mp4 -filter_complex "[1:v][0:v]scale2ref=oh*mdar:h=in_h:[v1][v0];[v0][v1]hstack[vo]" -map "[vo]" ./output-video.mp4

source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.