A problem with appending two video cuts

Started by Artificial Intelligence, October 06, 2017, 02:32:58 AM

Previous topic - Next topic

Artificial Intelligence

I am having trouble editing an mp4 video file. I want to cut portions of the video and then combine them together losing as little quality as possible and in a most optimum way. Some of the cuts are at Intra frames and others are not. When I cut at Intra frames using "Copy" for video and audio output, I have no problem appending one video fragment to another. The output plays fine. But when I cut outside an Intra frame, and reencode the video fragment, then the problem arises. After I append such video fragment with a fragment that was not reencoded and which was cut at an Intra frame, the output video does not play correctly, instead showing a lot of distortion.

Could you please help me locate the problem and find a workaround?

For instance, I have trouble appending these two fragments:

Video fragment 1:
General
Complete name                            : F:\To Cut 2\p1.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 2.11 MiB
Duration                                 : 5 s 920 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 985 kb/s
Writing application                      : Lavf56.36.100

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, RefFrames               : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 5 s 920 ms
Bit rate                                 : 3 000 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.130
Stream size                              : 2.03 MiB (97%)
Writing library                          : x264 core 146 r2538 121396c
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x133 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : mp4a-40-2
Duration                                 : 5 s 852 ms
Bit rate mode                            : Variable
Bit rate                                 : 96.0 kb/s
Maximum bit rate                         : 128 kb/s
Channel(s)                               : 2 channels
Channel(s)_Original                      : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 68.7 KiB (3%)
Language                                 : unk
Default                                  : Yes
Alternate group                          : 1


Video fragment 2:
General
Complete name                            : F:\To Cut 2\p2.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 14.6 MiB
Duration                                 : 47 s 880 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 562 kb/s
Writing application                      : Lavf56.36.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 5 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 5 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 47 s 880 ms
Bit rate                                 : 2 459 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.107
Stream size                              : 14.0 MiB (96%)

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : mp4a-40-2
Duration                                 : 47 s 810 ms
Bit rate mode                            : Variable
Bit rate                                 : 96.0 kb/s
Maximum bit rate                         : 128 kb/s
Channel(s)                               : 2 channels
Channel(s)_Original                      : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 561 KiB (4%)
Language                                 : unk
Default                                  : Yes
Alternate group                          : 1


I am using Avidemux 2.6.11 on Windows 7 (x64).
Thank you!

Jan Gruuthuse

#1
You can't use [Copy] mode, re-encoding is required for the edited video: content of used videos is encoded differently:
Video fragment 1:
QuoteFormat profile                           : High@L3.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 4 frames
Video fragment 2:
QuoteFormat profile                           : High@L4
Format settings                          : CABAC / 5 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 5 frames

Copy mode only works when video parts are encoded the same way/from same source.

eumagga0x2a

Apart from that: version 2.6.11 is terribly outdated, even the latest release 2.7.0 is getting old. I'd recommend to use the latest nightly.

Artificial Intelligence

Thanks for the help, guys! I changed one setting and now it works flawlessly. For the reencoded fragments I set "Maximum Reference Frames" to "5" (was "3" by default). And now I can join the fragments in the "Copy" mode.

It is probably the time to upgrade the program as well. Feeling kind of reluctant about that.