News:

--

Main Menu

New feature.

Started by AviFan, August 17, 2023, 11:16:39 PM

Previous topic - Next topic

eumagga0x2a

By the way, the easiest workaround if print() (or the length of a string) is limited to 1024 characters would be issuing one print() call for each segment, i. e. inside the while-loop. Of course, this implies that you don't try to display segment layout in a pop-up.

AviFan

ATTENTION to all Avidemux users,
never, I repeat NEVER ignore this message!

Codec or codec settings across a cut point do not match.
Playback of the video saved in copy mode may stop at this point.
Do you want to continue anyway?

All my recording are AVC, from soon I start to record in HEVC!

I add 9 AVC files with one HEVC file, and now my video not working.
But only not working this part with the HEVC codec. All others works.

So sad. :) This was my lesson!

If try to convert AVC <---> HEVC need to wait 10-20 mins.
This never gonna happen. :)

sark

This is a nice little script. I don't know python, but it wasn't too difficult to amend as follows:

Segment layout

Clip1 00:00:00.000
Clip2 00:00:05.160
Clip3 00:00:10.320

Couldn't figure out how to pad with a zero, as below. What should I be looking at.

Clip01
Clip02
Clip03

My adjusted code:

msg = ""
i = 0
linearTime = 0
while i < numberOfSegments:
    msg += "Clip" + str(i + 1)
    msg += " " + timeToString(linearTime)
    linearTime += ed.getDurationForSegment(i)
    msg += " " + "\n"
    i += 1

eumagga0x2a

AviFan, please stick with the subject. It is obvious that warnings displayed during editing are not for fun.

Yes, we are limited to 1024 characters in print() from tinyPy to Avidemux log. Please use

ed = Editor()
gui = Gui()

def timeToString(time):
    time += 499
    time /= 1000
    time = int(time)
    ms = time % 1000
    time = int(time / 1000)
    ss = time % 60
    time = int(time / 60)
    mm = time % 60
    hh = int(time / 60)
    plaintext = ""
    if hh < 10:
        plaintext += "0"
    plaintext += str(hh) + ":"
    if mm < 10:
        plaintext += "0"
    plaintext += str(mm) + ":"
    if ss < 10:
        plaintext += "0"
    plaintext += str(ss) + "."
    if ms < 100:
        plaintext += "0"
    if ms < 10:
        plaintext += "0"
    plaintext += str(ms)
    return plaintext

numberOfSegments = ed.nbSegments()
if not numberOfSegments:
    return 0

i = 0
linearTime = 0
while i < numberOfSegments:
    msg = "Seg " + str(i + 1)
    msg += " video " + str(ed.getRefIdxForSegment(i) + 1)
    msg += " start: " + timeToString(linearTime)
    linearTime += ed.getDurationForSegment(i)
    msg += " offset: " + timeToString(ed.getTimeOffsetForSegment(i))
    print(msg)
    i += 1

gui.displayInfo("Segment layout", "Human-readable list of segments has been written to Avidemux log")
return numberOfSegments

as workaround.

Indeed, text in alert dialogs we show on Windows cannot be selected, will consider adding copy-to-clipboard functionality which might be universally useful.

AviFan

sark:

I have nothing to say - except a big thank you.
Works exactly as I wanted!

eumagga0x2a:

Sorry, but my warning is not for fun - it is real.
After 1 year and more, now I understand I lost small part of some videos.
Because, when I make video with Avidemux - I delete my original source,
and keep only the joined file. I just ignore this message because when
I play my video and it worked, but I didn't know that there will be a
problem when I mix two different codecs - those some parts of the video
are without picture - only audio.

Your last script again have problems, but sark works fine!

[Script] Tinypy INFO - Seg 1 video 1 start: 00:00:00.000 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 2 video 2 start: 00:01:12.000 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 3 video 3 start: 00:02:47.983 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 4 video 4 start: 00:04:51.983 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 5 video 5 start: 00:06:24.983 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 6 video 6 start: 00:07:28.983 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 7 video 7 start: 00:09:15.983 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 8 video 8 start: 00:11:24.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 9 video 9 start: 00:13:00.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 10 video 10 start: 00:14:37.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 11 video 11 start: 00:15:24.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 12 video 12 start: 00:16:47.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 13 video 13 start: 00:17:42.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 14 video 14 start: 00:19:14.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 15 video 15 start: 00:20:50.982 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 16 video 16 start: 00:23:01.981 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 17 video 17 start: 00:24:15.981 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 18 video 18 start: 00:25:35.031 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 19 video 19 start: 00:27:19.031 offset: 00:00:00.000
[Script] Tinypy INFO -

[Script] Tinypy INFO - Seg 20 video 20 start: 00:29:07.031 offset: 00:00:00.000
[Script] Tinypy INFO -

sark looks better:
[Script] Tinypy INFO - Clip1 00:00:00.000
Clip2 00:01:12.000
Clip3 00:02:47.983
Clip4 00:04:51.983
Clip5 00:06:24.983
Clip6 00:07:28.983
Clip7 00:09:15.983
Clip8 00:11:24.982
Clip9 00:13:00.982
Clip10 00:14:37.982
Clip11 00:15:24.982
Clip12 00:16:47.982
Clip13 00:17:42.982
Clip14 00:19:14.982
Clip15 00:20:50.982
Clip16 00:23:01.981
Clip17 00:24:15.981
Clip18 00:25:35.031
Clip19 00:27:19.031
Clip20 00:29:07.031

But huge thanks to both of you for your help!
I never believed that my problem was solved
with just one script and not a whole new version
of the program!

sark

@AviFan

Good to see you have it working for your needs. However, I should point out, none of the script was mine. It was all eumagga0x2a's work. Beyond my capabilities. I just removed what I didn't need.

@eumagga0x2a

Just to clarify a couple of points as I'm on Windows. I can right click the pop up to Select All, then either use the same context menu to Copy, or use the Ctrl+C keys. Also, my play cursor remains in the same position when running the script. It will happily continue from this position when I hit the Play button. Have not tested with other scripts though.

Thanks for your efforts.

eumagga0x2a

Quote from: AviFan on August 20, 2023, 12:35:00 PMSorry, but my warning is not for fun - it is real.

AviFan, we seem to read and write two very different English languages as you got me all wrong, but nevermind.

Segment layouts where all segments reference different videos and always start at zero in reference time are special case not applicable to everyone (or rather, such layouts are probably a rare exception), thus I didn't deem it acceptable to drop offset info.

Emitting empty lines (i.e. containing only the prefix) from print() calls in scripts should be fixed now, bothered me all the time.

sark, thank you for your observation regarding selectability of text in info dialogs on Windows, I'll recheck it later. I expected it to work like on macOS and Linux where I can select text in dialogs with the mouse just fine, thus temporary blindness when being very tired ;D

Quote from: sark on August 20, 2023, 01:09:38 PMAlso, my play cursor remains in the same position when running the script. It will happily continue from this position when I hit the Play button.

This is the case when running scripts via the scripting shell, but not when executing them from a file.

sark

Quote from: eumagga0x2a on August 20, 2023, 03:55:27 PM
Quote from: sark on August 20, 2023, 01:09:38 PMAlso, my play cursor remains in the same position when running the script. It will happily continue from this position when I hit the Play button.

This is the case when running scripts via the scripting shell, but not when executing them from a file.

Just to clarify. I can add the .py file to the Custom folder and run from the Custom menu without the play cursor moving. Same situation if I input the script directly into the scripting shell (under Tools menu).
I only mention this because you suggested return to start was a safety feature... Is my system going to burst into 🔥🔥🔥flames🔥🔥🔥 ;D

AviFan

eumagga0x2a,

Yes, you are right, it is not your guilt, my english is bad!
Someday (I hope...) to be perfect like your's!



sark,
Maybe I'm wrong, but I have a feeling you'll find this script useful too.

Just today is a great and very happy day for me!



eumagga0x2a, sark

eumagga0x2a

Quote from: sark on August 20, 2023, 05:12:17 PMJust to clarify. I can add the .py file to the Custom folder and run from the Custom menu without the play cursor moving.

You are right, it is just the recent scripts menu which routes the call through a common routine responsible for running scripts passed to the application on command line. This routine rewinds after executing a script.

Menu actions in the list of custom scripts and in "File" --> "Project Script" --> "Run Project", implemented inside the Qt GUI, indeed don't rewind, probably hoping that the user is mindful.

Quote from: sark on August 20, 2023, 05:12:17 PMI only mention this because you suggested return to start was a safety feature... Is my system going to burst into 🔥🔥🔥flames🔥🔥🔥 ;D

Probably not the system, but it is trivially easy to crash Avidemux as scripting in Avidemux is very powerful and invalidating the current state is always possible. Now we can even close video via script, which might defeat even rewinding ;D

sark

Quote from: AviFan on August 20, 2023, 05:27:50 PMsark,
Maybe I'm wrong, but I have a feeling you'll find this script useful too.

Just today is a great and very happy day for me!

Not wrong at all, very useful... And when you reach my age, every day is a great day.  ;)

eumagga0x2a

Quote from: sark on August 20, 2023, 01:09:38 PMI can right click the pop up to Select All

Could you please provide information about Avidemux build type (MinGW or VC++) and version as well as about Windows version? This definitely doesn't work with Qt 5.15.x on Windows 11.

Regarding the script, please remove the line

    time += 499
to avoid mismatch with time display in Avidemux which always rounds time down, not to the nearest millisecond.

sark

#27
You cannot view this attachment.


You cannot view this attachment. 


You cannot view this attachment.

Downloaded latest portable (zip) nightly from:
https://www.avidemux.org/nightly/win64/
Avidemux_230710_win64qt5_154.zip

I'm running Windows 7 Pro SP1. 64 bit.

Also, I need to right click on the text (or very close) in the pop up.

Sark

szlldm

Instead of
gui.displayInfo("Segment layout", msg)you can try (in case of the latest nightly build)
dialog = DialogFactory("Segment layout")
t = DFText("Text:")
t.value = msg
dialog.addControl(t)
dialog.show()
The text will be hard to read, but easy to copy (CTRL+A then CTRL+C)

sark

Quote from: szlldm on August 23, 2023, 11:31:04 PMInstead of
gui.displayInfo("Segment layout", msg)you can try (in case of the latest nightly build)
dialog = DialogFactory("Segment layout")
t = DFText("Text:")
t.value = msg
dialog.addControl(t)
dialog.show()
The text will be hard to read, but easy to copy (CTRL+A then CTRL+C)

Works perfectly for my workflow.

The Ctrl+A key was not a big deal for me personally. Easy enough to right click the text.... However, resolving the 1024 character limit is very useful. Was you aware the above solved that issue?

One minor request if possible. I tried different adaptions of zfill and rjust, but could not figure out how to apply them to pad the first 9 values. No big deal, but list would match my files precisely if padded.

Thanks all

Sark