Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing string into single #16

Closed
toni15538 opened this issue Apr 10, 2021 · 8 comments
Closed

Error parsing string into single #16

toni15538 opened this issue Apr 10, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@toni15538
Copy link

Well, the error is as the title says...

This problem occurs when I try to encode a thp file either through the GUI or the CLI.

What I've done to minimize the chance of this error:
-Copied the files in directories without spaces(directly on the root of the drive)
-I've moved all the needed files in the Thwimp directory (only FFmpeg, ffplay, and ffprobe on a subdirectory ff)

but after these actions, I still get this error.

Here's some basic info

OS: Win 10 with set Bulgarian UI language

Settings file:
[Thwimp.ini v1.2.0.0]
THPRoot = D:\wbfs\DATA\files\thp
FFMpegDir = C:\THWIMP\ff
FFplay_wdir = C:\THWIMP\ff
irfanview = C:\THWIMP\i_view32.exe
thpconv = C:\THWIMP\THPConv.exe
dataDir = 0
audio = 1
audio_bgm = 1
log_msgBox = 1
log_Full = 1

The file path selected for encoding is C:\single_top and all files are named like this (single_top_A1_1.mp4) and are the same resolutions/framerates as their original subvideos

There's nothing in the logfile even with the full log turned on, only this is saved:
MsgBox:
title: Error during Encoding!
msg: Error parsing string into Single
icon: DefaultButton1, OkOnly, Critical
Line number: 4762

Thanks in advance.

@Tamk1s Tamk1s self-assigned this Apr 11, 2021
@Tamk1s Tamk1s added bug Something isn't working duplicate This issue or pull request already exists labels Apr 11, 2021
@Tamk1s
Copy link
Owner

Tamk1s commented Apr 11, 2021

This seems to be a repeat of Issue #11 , which should be fixed already, but possibly not. I haven't been able to test the bugfix personally on a foreign culture machine.

Quick technical details:
First thing that I've noticed in the error report above is that your PC is of culture Bulgarian UI language on Windows 10, which is quite helpful for debugging the issue and the program flow.

As for the error itself, this is thrown by a function named "TryParseErr_Single" (at the bottom of the program code in main.vb) at line 4762. This function takes a string value as input (expected to be a decimal value encoded within a string), attempts to convert it to a single (decimal type) datatype, and either returns a single value if successful or an error. There are a few calls to this function within the program to attempt converting strings into single values, specifically for FPS handling.

As for your specific error, the problematic function call occurs at line 2923 in main.vb, at the beginning of the THP encoding process (in a subroutine aptly named "Encode"). At the beginning of that subroutine, metadata about the original THP file being replaced is fetched and converted from textboxes in the "THP Info" group box within the "THP" tab to their appropriate variable data types, for further processing during the encoding sequence. The textbox info itself is populated from your Thwimp datafile set used (specifically the fileset's FileData.txt).

At line 2923, the FPS data is fetched as a string from the "FPS" textbox, and then converted to a single. Looks like it is failing to parse the string as a single decimal type properly, hence the error. Within FileData.txt, the FPS string is expected to be formatted in invariant (EN-US) culture, in the format of ww.dd (dot character for separator, not "," comma), where w = whole part and d = decimal part. See Section 5 Customization of the manual for full details on the format and syntax of the Thwimp datafile set.

So there are either 2 things happening here

  1. Bugfix for Issue Error parsing string into Single #11 may not be fully working. I attempted fixing wrong parsing of FPS string data within TryParseErr_Single function by forcing EN-US/Invariant culture (ww.dd dot char) during parsing in the current build; however, the original poster of Issue Error parsing string into Single #11 never replied back to confirm that it fixes the issue . Either that, or the bugfix has different behavior on Windows 10 with the older .NET 3.5 or so that this application has been compiled with. (I've only tested application on Windows 7 EN-US culture). If bugfix isn't working properly, try the workaround discussed in Issue Error parsing string into Single #11 for now by temporarily changing Regional Settings as listed.

  2. Incorrect syntax, formatting, or loading of the FileData.txt or other Thwimp fileset data. In the "Options" tab, point to the correct directory holding the Thwimp fileset data you wish to use (with files FileCDesc.txt, FileData.txt, FileDesc.txt, FileListing.txt, and FileSet.txt). Make sure the textboxes within "THP info" group box in the "THP" populate, and that the FPS data is displayed in EN-US format (ww.dd) .

If it's issue 1, I'll research a proper bugfix and implement it for a fixed build.

@Tamk1s
Copy link
Owner

Tamk1s commented Apr 11, 2021

Please send me over a screenshot of both FileData.txt file used within the Thwimp fileset and of the "THP" tab contents after reproducing the bug during encoding, just to verify stuff is loading correctly on your end.

@toni15538
Copy link
Author

Here are the needed screenshots

Filedata.txt
2021-04-11 14_01_03-FileData txt – Notepad

THP tab after error
2021-04-11 13_59_38-Thwimp

After the detailed explanation, I will re-export the videos once again with Premiere Pro to see if that fixes this error. I'll let you know if it's fixed.

@toni15538
Copy link
Author

Finally made the thp video

Here's what I've done (hope this fixes issue #15)

  • With regional formatting set to Bulgarian I still have the directory parse error
  • After temporarily setting the regional formatting to English(US) Thwimp started encoding, but it stops in the ini hacking/searching. (as in issue 15)
  • Reinstalled Irfanview with default settings and set the directory for the exe. Started Thwimp as admin. still the same error.
  • Added [JPEG] with the two variables in the .ini file like this
    2021-04-11 15_15_22-i_view32 ini – Notepad

And Voila, Thwimp made a thp file without any error(even without admin rights).

Thanks again for the detailed description of the problems in both issues. It helped me.

@Tamk1s Tamk1s removed the duplicate This issue or pull request already exists label Apr 11, 2021
@Tamk1s
Copy link
Owner

Tamk1s commented Apr 11, 2021

I just noticed in your Thwimp screenshot that for some reason the FPS datafield within the "THP" tab has the FPS value set in foreign culture (59,94 with a comma), which would explain the Single parse fail error that you got when set in Bulgaria culture. Although the FileData.txt above has the FPS value strings formatted correctly in EN-US culture (ww.dd dot), the FPS textfield is displaying foreign culture.

I need to dig back in my code, but I may be storing the FPS value as a single datatype and then converting back to a string somewhere for the FPS textfield, and forgot to enforce the expected EN-US culture in the string conversion. This would totally explain the issue, and I'll need to put in a bugfix to fully fix Issue #11 .

Thanks for the bug report; I'll properly fix this within the week or so with a new minor build.

Tamk1s added a commit that referenced this issue Jun 18, 2021
**Issue #16 bugfixes:**
- Fixed issue with FPS textbox in THP Info not displaying culture invariant single string format, further breaking program when processing THP videos on foreign machines
- Fixed issues with video start/end frame single strings for THP Viewer/Ripper cropper not using invariant culture for FFMPEG/FFPlay cmdline calls
- Fixed issues with FFMPEG calls using the FPS string value not using invariant culture while THP encoding
- Fixed issues with the progress bar/application logger not using invariant culture for the progress bar percentage string values
- Added appropriate calls to **Single_ToString()** function to fix these issues

**Single_ToString function:**
- Added new **Single_ToString_Types** enum to support the 3 types of single.ToString() string conversion formats in the program:
  - Percentage ("P2")
  - Single ("F2")
  - Fixed-point (round-tripped audio frames, "G9")
- Created global variable **culture** to handle Invariant CultureInfo object throughout program
- Created new function **Single_ToString()** to handle proper string conversion of single data **(culture invariant)**

**Misc bugfixes:**
- Added more parsing validation, with TryParseErr value conversion checking
  - **Functions**
    - btnPlay_Click() - THP Viewer
    - Rip() - THP Ripper
  - **Parsing changes**
    - Start/end video frame cropping information (TryParseErr_UShort())
    - FPS value (TryParseErr_Single())

- Fixed a typo within function **nudTD_M_ChangeMe()**
  - For the video cropper within THP Viewer/Ripper section, use TryParseErr_UShort(), **not** TryParseErr_Single() for updating the video frame end value

**Enhancements:**
- Updated application version string to v1.2.0.1, copyright to ©2021
- For Y2K bugfix in **btnLogSave_Click()** function (log saver), made date format string a constant rather than an immediate value in date.ToString function call
@Tamk1s
Copy link
Owner

Tamk1s commented Jun 18, 2021

Thwimp_v1201b.zip
@toni15538 Hey, sorry for the delay on fixing this issue! The development laptop died around April 14th and I had to earn enough money to directly replace the machine with the old hard drive inserted.

Attached is Thwimp v1.2.0.1 beta , which should fix this and other lingering invariant culture-related issues. Please try this build while using your normal regional formatting settings (Bulgarian); this should properly fix the "Error parsing string into single" error for the FPS formatting without workarounds. I'll test this on my end tomorrow and verify.

Please report back if this build fixes the Single parsing errors; if so, I'll close this issue and push a formal bugfixed release this week :).

Summary of bugfixes:

  • Fixed issue with FPS textbox parsing
  • Fixed issues with video start/end frame single strings for THP Viewer/Ripper cropper not using invariant culture for FFMPEG/FFPlay cmdline calls
  • Fixed issues with FFMPEG calls using the FPS string value not using invariant culture while THP Encoding
  • Fixed issues with the progress bar/application logger not using invariant culture for the progress bar percentage string values

@toni15538
Copy link
Author

Hello,

I'm sorry to hear, that your laptop broke, but now I'm happy, that you are back.

I've downloaded the latest version(1.2.0.1) and tried to make a new thp clip.
Now decoding/encoding works without changing the region setting.

Thanks again for the support.

@Tamk1s
Copy link
Owner

Tamk1s commented Jun 20, 2021

Awesome! Glad to hear that it fixes the issues.

Will mark this issue as Closed and push out the official v1.2.0.1 release tonight.

@Tamk1s Tamk1s closed this as completed Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants