Avidemux Forum

Avidemux => Windows => Topic started by: Sora on June 21, 2022, 10:46:19 AM

Title: Settings set to video and audio COPY but output laggy
Post by: Sora on June 21, 2022, 10:46:19 AM
I got an original TS file and I want to cut out part of it without encoding, I set both video and audio to COPY mode and tried outputting it to mp4 and ts but in both cases, the video in the output file is kind of choppy, like the frame rate dropped a lot. The video and audio are in sync and the audio track has no problem.
I also tried re-encoding the video as x264 and save the output as mp4, the output has no problem at all. Does this mean I must re-encode the file just for cutting the input? But shouldn't copying video and audio and outputting as TS file(the same file format as the input) work?

Attached are the mediainfo of the input and outputs file.
Someone please help me thanks.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 21, 2022, 04:08:12 PM
I'm sorry, but downloading (at least, text attachments) is currently broken in this forum. Would you please provide the files via Pastebin, WeTransfer, Mega, Dropbox or Google Drive?
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 22, 2022, 03:54:04 AM
Quote from: eumagga0x2a on June 21, 2022, 04:08:12 PMI'm sorry, but downloading (at least, text attachments) is currently broken in this forum. Would you please provide the files via Pastebin, WeTransfer, Mega, Dropbox or Google Drive?
Here's the link:
https://drive.google.com/drive/folders/1ulLkiIw7pNECEXJTXd1W7i2JtjyT_9Ym?usp=sharing

There're also several things I noticed.
1) When I tried to open the output file in avidemux again, it shows a warning message "This video contains B-frames, but presentation time stamps (PTS) are either missing or monotonically increasing." This message only popped up for the output files, the original file plays smoothly and avidemux doesn't show this message for it.
2) I tried using different media players (or video decoders) to play the output files.
It seems that there're timestamps issues with the output files. Thanks.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 22, 2022, 11:47:50 AM
Could you please verify that the problem with invalid frame timestamps not detected in the source MPEG-TS file but present in the output persists with the latest Avidemux win64 nightly (https://avidemux.org/nightly/win64/) (currently from June 20) and if it does, provide the first ~300 MiB of the source file as a sample, cut with a simple tool similar to head or dd on Linux? (In a way that the cutter doesn't interfere with the content and internal structure of the file, just copies the first N bytes).

I suspect that there is some problem with timing in the source.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 22, 2022, 05:25:56 PM
Quote from: eumagga0x2a on June 22, 2022, 11:47:50 AMCould you please verify that the problem with invalid frame timestamps not detected in the source MPEG-TS file but present in the output persists with the latest Avidemux win64 nightly (https://avidemux.org/nightly/win64/) (currently from June 20) and if it does, provide the first ~300 MiB of the source file as a sample, cut with a simple tool similar to head or dd on Linux? (In a way that the cutter doesn't interfere with the content and internal structure of the file, just copies the first N bytes).

I suspect that there is some problem with timing in the source.
Yes the problem does exists in the latest Avidemux win64 nightly and I don't know if I'm doing this correctly but I just use "Get-Content original.ts -TotalCount 300MB -Encoding byte" in windows powershell to extract the first 300MB but it's taking a really long time because the file is around 7.9GB. Are there any other ways to do this? Thanks.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 22, 2022, 08:17:48 PM
I have no knowledge of PowerShell, but looking at the documentation, your command line seems to be correct.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 23, 2022, 06:27:09 PM
Quote from: eumagga0x2a on June 22, 2022, 08:17:48 PMI have no knowledge of PowerShell, but looking at the documentation, your command line seems to be correct.
I don't know if this is a problem but the first 300MiB of the file is just the same frame contents, there're no movements, do you still want it? Thanks.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 23, 2022, 06:49:18 PM
Please increase the size of the sample to 500 MiB and let me have a look at it.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 24, 2022, 02:04:35 AM
I figured 500MB is still not enough, the video starts to have motion at around 23 mins so at least around 800MB is needed and Get-content is taking way too long to output the 800MB file. Would it be better if I just send you the whole original file?
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 24, 2022, 05:25:38 PM
Something must be really fishy with the source file.

Quote from: Sora on June 24, 2022, 02:04:35 AMWould it be better if I just send you the whole original file?

If your upstream bandwidth allows uploading 7.9 GiB within a reasonable period of time, then do, please. Please keep in mind that installing a Windows version of coreutils (or MSYS2 (https://www.msys2.org/)) and using

head -c 500M /path/to/source.ts > /path/to/output.ts
to write the first 500 MiB of source.ts to a new file output.ts may be faster (and you get a proper all-purpose set of tools for later).
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 26, 2022, 02:58:15 PM
Quote from: eumagga0x2a on June 24, 2022, 05:25:38 PMSomething must be really fishy with the source file.

Quote from: Sora on June 24, 2022, 02:04:35 AMWould it be better if I just send you the whole original file?

If your upstream bandwidth allows uploading 7.9 GiB within a reasonable period of time, then do, please. Please keep in mind that installing a Windows version of coreutils (or MSYS2 (https://www.msys2.org/)) and using

head -c 500M /path/to/source.ts > /path/to/output.ts
to write the first 500 MiB of source.ts to a new file output.ts may be faster (and you get a proper all-purpose set of tools for later).

I just sent you the file through PM. Thanks.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 26, 2022, 09:27:22 PM
Thank you for the sample, the issue should be fixed by [editor] Check for insufficient PTS delay when adding a ref video and correct it if necessary (https://github.com/mean00/avidemux2/commit/be9e40bb6a063495fd0499e53778a006bcbddfa2).

The video contains B-frames, but presentation timestamps (PTS) are not shifted to ensure that they never precede corresponding decode timestamps (DTS). Avidemux was expecting and checking for pretty all sorts of trouble except for the case when all timestamps in a closed-GOP video were present and valid, but the PTS delay was too low (here: equal zero).
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 27, 2022, 10:53:33 AM
Thank you for the reply. May I ask how do I use the script provided to fix the problem?

And if I understand you correctly, since a frame needs to be decoded first in order for it to be displayed, so DTS for the same frame should always be smaller than or equal to its PTS, right? In this video case, there're DTS that are after the PTS? And I'm guessing the PTS delay is to delay PTS so that they are after the DTS?
Title: Re: Settings set to video and audio COPY but output laggy
Post by: eumagga0x2a on June 27, 2022, 12:22:19 PM
Quote from: Sora on June 27, 2022, 10:53:33 AMMay I ask how do I use the script provided to fix the problem?

This is not a script but a patch, already submitted to the repository. Next time Avidemux is compiled off the git master, the resulting application will handle such files correctly (as always, the change may have unwanted side effects with some other files with broken timing, but that's life). If you have some experience with Linux and don't want to depend on officially provided binaries, you can build Avidemux for Windows from source yourself (https://github.com/mean00/avidemux2/blob/master/cross-compiling.txt) which is not too complicated.

Quote from: Sora on June 27, 2022, 10:53:33 AMAnd if I understand you correctly, since a frame needs to be decoded first in order for it to be displayed, so DTS for the same frame should always be smaller than or equal to its PTS, right? In this video case, there're DTS that are after the PTS? And I'm guessing the PTS delay is to delay PTS so that they are after the DTS?

Yes, absolutely correct.
Title: Re: Settings set to video and audio COPY but output laggy
Post by: Sora on June 28, 2022, 08:39:46 AM
Got it, thanks for the help!