Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FLAC support unicode? (Read 49512 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FLAC support unicode?

I am a newer for FLAC. I am using FLAC to convert wave files into flac. But if the filename or directory contians Chinese, the tools told me "Error: can not open input file F:\audio\---------------".

FLAC does not support UNICODE? I need to re-complile the FLAC project?

Thanks.

FLAC support unicode?

Reply #1
Hi, currently flac tools do not support unicode filenames. But you can work-around this limitation with this script:
Quote
@echo off
set encoder="C:\Program Files\flac-1.1.2-win\bin\flac.exe"
set tempfile=%random%%random%%random%%random%
type "%1" | %encoder% -8 - -o "%~d1%~p1%tempfile%"
ren "%~d1%~p1%tempfile%" "%~n1.flac"

Copy this to a text file and rename it to "flac.cmd", change the path to flac.exe (marked with green color). Then you will be able to use flac.cmd like this:

Examples:

F:\audio>flac.cmd 你好世界.wav

this will encode to F:\audio\你好世界.flac output file.


F:\>flac.cmd \audio\你好世界.wav

this will also encode to F:\audio\你好世界.flac

FLAC support unicode?

Reply #2
Not true.

I use flac 1.1.2 on linux and unicode (utf-8) works like a charm. I do not use Asian characters, but quite a few Easter European that are not part of the normal ASCII.

Maybe Windows is different, I dunno.

Triza

FLAC support unicode?

Reply #3
I've had problems with special characters, though some of them work, so I don't believe the FLAC tools support Unicode, at least on Windows.

FLAC support unicode?

Reply #4
Not many command-line encoders seem to support Unicode filenames on Windows; if some characters from the filenames are not in your codepage, you'll get problems.

I'd use foobar2000's converter together with flac.exe to encode using %s %d. (Using pipes seems to create minor problems with seektables.)

FLAC support unicode?

Reply #5
I need to make a FAQ out of this but haven't yet...  the basic problem is windows' implementation of unicode filenames, which can only be supported via windows APIs (non-portable), and is different for different versions of windows.  I searched quite a bit and even major projects like python have rejected supporting unicode filenames because of the complexity of it (at least when I looked).

unicode filenames on pretty much any other system are not a problem.

Egor's solution for windows is best I think.

Josh

FLAC support unicode?

Reply #6
Is lack of Unicode support still a problem using Vista?

FLAC support unicode?

Reply #7
Is lack of Unicode support still a problem using Vista?

Yes.

Try the workaround mentioned above, or use foobar2000 - it has full Unicode support and some compatibility tricks for commandline encoders like flac.exe.

FLAC support unicode?

Reply #8
Try the workaround mentioned above, or use foobar2000 - it has full Unicode support and some compatibility tricks for commandline encoders like flac.exe.

I use the following script found here on the forums (with slight modifications) for recoding FLAC files to the newest version installed:

Code: [Select]
@echo off
set encoder="C:\Program Files\FLAC\flac.exe"
for /r "." %%d in (.) do (cd %%d & for %%f in (*.flac) do %encoder% --best -V -f "%%f")


What I'm after, is making this script also work with unicode names (currently I get the "invalid argument" error). I'll try the workaround described above.

Can foobar easily recode all of the FLAC files in my music library fully automatically, just like this script can?

Edit: Tested, didn't work. I made a flac.cmd containing exactly what is described above (except for the path), and I used the script above using flac.cmd instead of flac.exe. I got the following error:

Code: [Select]
ERROR: for encoding a raw file you must specify a value for --endian, --sign, --channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options


Edit #2: I can't help thinking that the two scripts must be merged. Can someone do this for me? I have little knowledge of such scripting... I want the settings and the recursive functionality of the script I mentioned, and the unicode support of the workaround script.

FLAC support unicode?

Reply #9
Bump for great justice! Is anyone able to merge the two scripts mentioned above? I haven't found out how to do it...

FLAC support unicode?

Reply #10
Anyone? I just added a few songs to my collection with Unicode filenames, but have not been able to merge the two scripts above...

FLAC support unicode?

Reply #11
Try the workaround mentioned above, or use foobar2000 - it has full Unicode support and some compatibility tricks for commandline encoders like flac.exe.

I use the following script found here on the forums (with slight modifications) for recoding FLAC files to the newest version installed:

Code: [Select]
@echo off
set encoder="C:\Program Files\FLAC\flac.exe"
for /r "." %%d in (.) do (cd %%d & for %%f in (*.flac) do %encoder% --best -V -f "%%f")


What I'm after, is making this script also work with unicode names (currently I get the "invalid argument" error). I'll try the workaround described above.

Can foobar easily recode all of the FLAC files in my music library fully automatically, just like this script can?

Edit: Tested, didn't work. I made a flac.cmd containing exactly what is described above (except for the path), and I used the script above using flac.cmd instead of flac.exe. I got the following error:

Code: [Select]
ERROR: for encoding a raw file you must specify a value for --endian, --sign, --channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options




Edit #2: I can't help thinking that the two scripts must be merged. Can someone do this for me? I have little knowledge of such scripting... I want the settings and the recursive functionality of the script I mentioned, and the unicode support of the workaround script.



Did anyone ever help you figure out how to merge these files?    I am having a similar problem with my audio files. I'm hoping that you are still a member of this forum so you can help me out if you had success.  I'm having a ton of trouble trying to solve this. I'm wanting this fixed so that I can use a specific audio to play on my outdoor speakers.  Thanks for your help.

FLAC support unicode?

Reply #12
Did anyone ever help you figure out how to merge these files?    I am having a similar problem with my audio files. I'm hoping that you are still a member of this forum so you can help me out if you had success.  I'm having a ton of trouble trying to solve this. I'm wanting this fixed so that I can use a specific audio to play on my outdoor speakers.  Thanks for your help.

the workaround is to specify the code page of the current system (that is what i do), the bat file may look like:
Code: [Select]
::flac.bat
@ECHO OFF
chcp
chcp 1250

flac.exe --keep-foreign-metadata "%%1"

that would also skip the piping.
PANIC: CPU 1: Cache Error (unrecoverable - dcache data) Eframe = 0x90000000208cf3b8
NOTICE - cpu 0 didn't dump TLB, may be hung

FLAC support unicode?

Reply #13
I had a similar problem a few years back. I had trouble using Unicode in Linux. The trouble I had was mainly related to the use of Asian characters and did fail at most times. And back then I used it on windows and some of the problems were solved just like that and I have been using windows ever since. The characters especially Asian ones doesn’t seem to come up with any more complaints and most of the problems were gone after I started using windows.

FLAC support unicode?

Reply #14
To [a href=\'index.php?act=findpost&pid=518387\']MiSP[/a], [a href=\'index.php?act=findpost&pid=761077\']whitejason[/a] and everybody who is having similar problem )

I could to offer my own version of a workaround to solve the problem with file names in Unicode on Windows. This is exactly as requested in the messages above -- slightly improved recursive script from the [a href=\'index.php?act=findpost&pid=518387\']MiSP's post[/a] combined with the [a href=\'index.php?act=findpost&pid=428988\']script by Egor[/a]. In my edition of the script the basic settings are in a separate section at the beginning (Adjustable parameters). There should be specified the actual path to the flac executable. Moreover, there are settings for the extensions of the source and destination files and a set of options for the encoder. In addition, during the process script prints the current working directory and names of the files which are being encoded at the moment. In my opinion, it's better than seeing only the progress for the current file, which displays flac, not knowing which particular file is re-encoded now.

Now a few words about the behavior of the script. The script traverses the subtree rooted at the current directory. In each directory of the subtree, the script enumerates all files with the extension "%srcext%" and passes them through a pipe to the encoder. The result flac writes to a temporary file with a name consisting of the name of the script and the current timestamp. If the processing was successful and the temporary file has been created, it is moved to a file with the same name as the original and the extension "%dstext%". If extensions of the input and the output files are the same, then the original file will be replaced by the newly created. To change this behavior is enough to specify an output file extension different from the original, such as "reenc.flac" or something along the same lines.

Below is the current version of the script (reflac.cmd), which has all the functionality described above and requires no additional tools to work:

Code: [Select]
[font=Courier New]::
:: This script is a wrapper for the flac command-line tool
::  to ensure proper handling of file names in unicode when transcoding
:: ---------------------------------------------------------------------
::
:: The script transcodes all the files with the given extension
::  in the current directory and all subdirectories. If the specified
::  extensions of source and destination files are the same
::  the original files will be replaced by the resulting.
::
:: Before use, you should specify the correct path to the flac
::  executable (in adjustable parameters section). In that section
::  can also be specified the extensions for the input and output
::  files, as well as set of options for the encoder.
:: ---------------------------------------------------------------------
::  reflac (mar 2012 by jar)
::

@echo off

setlocal enabledelayedexpansion

::
:: Adjustable parameters
:: ---------------------------------------------------------------------

set "encoder=с:\program files\flac\flac.exe"
set "options= --best --verify"

set "srcext=flac"
set "dstext=flac"

::
:: Print the header and create a line for underscore subheaders
:: ---------------------------------------------------------------------

echo.
echo %~n0: transcoding all the .%srcext% files in the current subtree

set "maxcol=79"

for /l %%i in (1, 1, %maxcol%) do (set "uline=!uline!-")

::
:: Traversing the directory subtree transcoding each target file
:: ---------------------------------------------------------------------

for /r %%d in (.) do (

  set "dir=%%d"
  set "dir=!dir:~0,-2!"

  pushd "!dir!"

  set "hasfiles="

  for %%f in (*.%srcext%) do (
    if not defined hasfiles (

      echo.
      echo %uline%
      echo directory: !dir!
      echo %uline%

      set "hasfiles=true"
    )

    set "timestamp=!time:.=!"
    set "timestamp=!timestamp::=!"
    set "timestamp=!timestamp: =0!"

    set "tempfile=%~n0-!timestamp!.tmp"

    echo.
    echo processing: %%f --^> *.%dstext%
    echo %uline%

    type "%%f" 2>nul | %encoder% %options% -o "!tempfile!" -

    if exist "!tempfile!" (
      move /y "!tempfile!" "%%~nf.%dstext%"
    )
  )

  popd
)

endlocal[/font]
just jar