News:

--

Main Menu

Create a log file using tinypy

Started by bebert64, September 10, 2019, 04:16:03 PM

Previous topic - Next topic

bebert64

Hi everyone,

I've tried to research a lot before posting, but haven't found anything yet. I'm scripting in avidemux 2.7.3 using tinypy and a .bat file, and the "main" part is working well. I do not have any issue getting avidemux to do what I want, as long as we're talking about manipulating video files (which is the point I guess...).
My trouble starts when I try to get info about the file and write them in a separate log file. After a couple of days researching it, I'm not even sure if it's at all possible.

Ok, let's get to it. I'm trying to :

  • load a list of video files, one by one (working)
  • do some manipulation (working)
  • get its final total frame number (I use Avidemux.markerB, and I can display it using the Gui displayInfo method, so I know that info is the one I want)
  • write a line in my log file with the name and that total frame number (problem...)

Basically, I have no idea how to use TinyPy to create or open/edit an existing txt file. I've tried open(full_path_to_file.txt), but it doesn't seem to work. I've copied the standard librairies in the good repertory, and tried to use import os and os.open(full_path_to_file.txt), but I also get an error. It seems that I can use "import", but I can't manipulate anything imported. In fact, even trying something as simple as print(os.name) gives me an Exception (Exception :(_tp_dict_get) KeyError: name). Also, and it might be absolutely normal, but it does seem weird from my uneducated point of view : import os does not raise any exception, whereas from os import path does raise one immediately.
Also, I'm not sure if it matters, but I'm running Win7.

I know tinypy is NOT python, but I'm jut not sure what are its limits, and if there is a syntax I don't know yet, or if what I'm trying to do is simply not possible.


eumagga0x2a

Quote from: bebert64 on September 10, 2019, 04:16:03 PM
I'm scripting in avidemux 2.7.3

Why not the current?

QuoteBasically, I have no idea how to use TinyPy to create or open/edit an existing txt file.

I am pretty sure this is not possible.

bebert64

Quote from: eumagga0x2a on September 10, 2019, 10:11:52 PM
Why not the current?
I'm actually using the portable version (from portableapps), because I do not have the admin rights on my computer. But so far, it has not created any issues, and it doesn't seem to be related to my log problem.

Quote
I am pretty sure this is not possible.
Too bad... Any other ideas on how I might track what I do ? Are there already log files existing, that I could open and maybe extract information from ?

eumagga0x2a

Quote from: bebert64 on September 11, 2019, 05:32:50 AM
I'm actually using the portable version (from portableapps), because I do not have the admin rights on my computer.

Grab the ZIP of the latest official MinGW nightly from https://avidemux.org/nightly/win64/ and you don't need to rely on third-party packages.

To make it portable, i.e. let it save configuration in the program directory instead of the folder the env variable %appData% points to, create a shortcut, edit the command in the properties of this shortcut and add --portable option after avidemux.exe, separated by a space. If it is okay for you to let Avidemux to save its profile in %appdata% on that computer, you even don't need to turn the portable mode on.

Alternatively install Avidemux VC++ on a system where you have admin permissions (unfortunately, the QtIFW installer always shows a UAC prompt, even when installing into %userprofile%) and copy the application directory to a flash drive (you should delete the QtIFW maintenance tool / the uninstaller). Avidemux doesn't use registry to store any information and doesn't need to be installed.

QuoteBut so far, it has not created any issues,

Good, there have been some improvements in various areas: http://fixounet.free.fr/avidemux/news.html

Quoteand it doesn't seem to be related to my log problem.

This is true.

Quote
Quote
I am pretty sure this is not possible.
Too bad... Any other ideas on how I might track what I do ? Are there already log files existing, that I could open and maybe extract information from ?

The file name should come right from the batch file (please ask user "dosdan" for advice). When saving using the MKV, WebM or MP4 muxer, the number of output frames could be retrieved from %localappdata%\avidemux\admlog.txt:

[saveLoop] 11:21:56-609 [FF] Wrote 641 frames, nb audio streams 1
[saveLoop] 11:21:56-610 [FF] Found 0 missing PTS / 641 total frames


after each Avidemux run.

dosdan

#4
Quote from: eumagga0x2a on September 11, 2019, 11:36:52 AM

The file name should come right from the batch file (please ask user "dosdan" for advice). When saving using the MKV, WebM or MP4 muxer, the number of output frames could be retrieved from %localappdata%\avidemux\admlog.txt:

[saveLoop] 11:21:56-609 [FF] Wrote 641 frames, nb audio streams 1
[saveLoop] 11:21:56-610 [FF] Found 0 missing PTS / 641 total frames


after each Avidemux run.

bebert64, please post your batchfile.

First, to get the full name with path of your ADM logfile:

Help | Advanced | Open Application Data Folder. Hold down your Shift-key and R.click on admlog.txt. Click on the "Copy as path" option. (This option will not be visible in the R.click menu unless you first hold down the Shift-key).

This is what was copied to my clipboard:  "C:\Users\Dan\AppData\Roaming\avidemux\admlog.txt"

Here's a test batchfile:

read_log.txt
@echo off
echo ****Start of log**** > d:\test_log.txt
type "C:\Users\Dan\AppData\Roaming\avidemux\admlog.txt" | find /i "[FF] Wrote" >> d:\test_log.txt
rem type "C:\Users\Dan\AppData\Roaming\avidemux\admlog.txt" | find /i " nb" >> d:\test_log.txt
if exist d:\test_log.txt start /i d:\test_log.txt
echo ------------------------ >> d:\test_log.txt


> creates d:\test_log.txt or overwrites it if it already exists. 
>> appends to an existing file, and creates it if it doesn't already exist.
start /i "runs" the text file in the associated program, usually Notepad, so a window pops up.

Modify to suit your setup.   

After doing a ADM Copy|Copy remux of a .MTS -> .MP4 and then running this batchile I saw this in Notepad:
****Start of log****
[muxerFFmpeg::saveLoop] 19:31:42-067 [FF] Wrote 1229 frames, nb audio streams 1
------------------------


Next, I REMed (remarked) out the first FIND line, unREMed the 2nd FIND line, saved the change in the batchfile and rerun it. I saw:
****Start of log****
[ADM_Composer::checkForValidPts] 19:30:22-242 nbBFrames:64
[ADM_Composer::checkForValidPts] 19:30:22-242 nbPFrames:30
[ADM_Composer::checkForValidPts] 19:30:22-242 nbIFrames:3
[ADM_Composer::checkForValidPts] 19:30:22-242 nbNoImage:3
[ADM_Composer::checkForValidPts] 19:30:22-242 nbPtsgoingBack:0
[muxerFFmpeg::saveLoop] 19:31:42-067 [FF] Wrote 1229 frames, nb audio streams 1
------------------------


So it's possible to save other info from a ADM processing run, if you wish, as long as you can find something unique to filter on. You could have multiple FIND lines, looking for different info.

In your multi-file situation I presume you're running a FOR IN () DO loop. It should be possible to include each mediafile's name in the log as you loop.

So show me your current batchfile.

Dan.




bebert64

Hello,

I haven't found the time yet to look into the answer, but I wanted to thank you anyway for your answer. I do appreciate you taking the time to help me.
I will let you know as soon as I have a moment to test all of that.

Have a great day everyone,
Romain