Opened 5 years ago

Closed 5 years ago

#1951 closed defect (invalid)

Ffmpeg meta data fails to write UTF-8 and screws up files

Reported by: burzum Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: win
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I'm trying to write meta data to different audio formats in UTF-8. I've already made sure the command line is set to UTF-8 by checking the output of chcp which shows me code page 65001. I'm using windows 8.

How to reproduce:

ffmpeg.exe -i "test-files\cd-quality-song.mp3" -metadata title="! Äüß!*" -metadata artist="Burzum #äääüüüüüß" -metadata track="11" -metadata date="2012" -metadata album="Test Album" -c:a copy -id3v2_version 3 -write_id3v1 1 -y "test-files\cd-quality-song.mp3" 2>&1

ffmpeg.exe -i "test-files\cd-quality-song.ogg" -metadata title="! Äüß!*" -metadata artist="Burzum #äääüüüüüß" -metadata track="11" -metadata date="2012" -metadata album="Test Album" -c:a copy -id3v2_version 3 -write_id3v1 1 -y "test-files\cd-quality-song.ogg" 2>&1

ffmpeg.exe -i "test-files\cd-quality-song.flac" -metadata title="! Äüß!*" -metadata artist="Burzum #äääüüüüüß" -metadata track="11" -metadata date="2012" -metadata album="Test Album" -c:a copy -id3v2_version 3 -write_id3v1 1 -y "test-files\cd-quality-song.flac" 2>&1  
ffmpeg version N-46146-g11d695d Copyright (c) 2000-2012 the FFmpeg developers
built on Oct 29 2012 18:10:27 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable
-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enab
le-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroed
inger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib

The result for the artist is "Burzum #äääüüüüüß" and the result for the title is "! Äüß!*". This looks like wrong encoding to me. I'm using foobar2000 to look at the tracks.

Another issue with that is that the flac file is ok, it keeps its original length of 3:19, the mp3 gets truncated for some reason to 0:06 and the ogg vorbis to 0:01! I have no idea why this happens.

Change History (4)

comment:1 Changed 5 years ago by cehoyos

  • Keywords win added

Since it works fine here, I suspect this is a Windows-specific issue.

Please add complete, uncut console output to make this a valid ticket.

comment:2 Changed 5 years ago by burzum

Yes, I'm also pretty sure it is a windows specific issue.

I've also started looking at cmdutils.c ~line 217 master branch, but as far as I can tell (I don't know C) this seems to already do the job? Or should do it? It's taking the input and should change it to UTF8.

Here is the whole log from my php application:

2012-11-22 21:16:19 Shell-processor: \Lib\Utility\ShellProcessor.php Line: 102
2012-11-22 21:16:19 Shell-processor: \Bin\Win\ffmpeg\bin\ffmpeg.exe -i "\tmp\test-files\cd-quality-song.mp3" -metadata title="! Äüß!*" -metadata artist="Burzum #äääüüüüüß" -metadata track="11" -metadata date="2012" -metadata album="Test Album" -c:a copy -id3v2_version 3 -write_id3v1 1 -y "\tmp\test-files\cd-quality-song.mp3" 2>&1
2012-11-22 21:16:19 Shell-processor: \Lib\MetaData\FfmpegId3v2.php Line: 81
2012-11-22 21:16:19 Shell-processor: Array
(
    [0] => ffmpeg version N-46146-g11d695d Copyright (c) 2000-2012 the FFmpeg developers
    [1] =>   built on Oct 29 2012 18:10:27 with gcc 4.7.2 (GCC)
    [2] =>   configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    [3] =>   libavutil      52.  1.100 / 52.  1.100
    [4] =>   libavcodec     54. 69.100 / 54. 69.100
    [5] =>   libavformat    54. 35.100 / 54. 35.100
    [6] =>   libavdevice    54.  3.100 / 54.  3.100
    [7] =>   libavfilter     3. 20.109 /  3. 20.109
    [8] =>   libswscale      2.  1.101 /  2.  1.101
    [9] =>   libswresample   0. 16.100 /  0. 16.100
    [10] =>   libpostproc    52.  1.100 / 52.  1.100
    [11] => [mp3 @ 0000000001eb3180] max_analyze_duration 5000000 reached at 5015510
    [12] => Input #0, mp3, from '\tmp\test-files\cd-quality-song.mp3':
    [13] =>   Metadata:
    [14] =>     encoder         : Lavf54.0.100
    [15] =>   Duration: 00:03:18.97, start: 0.000000, bitrate: 256 kb/s
    [16] =>     Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 256 kb/s
    [17] => Output #0, mp3, to '\tmp\test-files\cd-quality-song.mp3':
    [18] =>   Metadata:
    [19] =>     TALB            : Test Album
    [20] =>     TIT2            : ! Äüß!*
    [21] =>     TPE1            : Burzum #äääüüüüüß
    [22] =>     TRCK            : 11
    [23] =>     TYER            : 2012
    [24] =>     TSSE            : Lavf54.35.100
    [25] =>     Stream #0:0: Audio: mp3, 44100 Hz, stereo, 256 kb/s
    [26] => Stream mapping:
    [27] =>   Stream #0:0 -> #0:0 (copy)
    [28] => Press [q] to stop, [?] for help
    [29] => size=     192kB time=00:00:06.16 bitrate= 255.7kbits/s    
    [30] => video:0kB audio:191kB subtitle:0 global headers:0kB muxing overhead 0.595177%
    [31] => 
)

2012-11-22 21:16:19 Shell-processor: \Lib\Utility\ShellProcessor.php Line: 102
2012-11-22 21:16:19 Shell-processor: \Bin\Win\ffmpeg\bin\ffmpeg.exe -i "\tmp\test-files\cd-quality-song.ogg" -metadata title="! Äüß!*" -metadata artist="Burzum #äääüüüüüß" -metadata track="11" -metadata date="2012" -metadata album="Test Album" -c:a copy -id3v2_version 3 -write_id3v1 1 -y "\tmp\test-files\cd-quality-song.ogg" 2>&1
2012-11-22 21:16:19 Shell-processor: \Lib\MetaData\FfmpegId3v2.php Line: 81
2012-11-22 21:16:19 Shell-processor: Array
(
    [0] => ffmpeg version N-46146-g11d695d Copyright (c) 2000-2012 the FFmpeg developers
    [1] =>   built on Oct 29 2012 18:10:27 with gcc 4.7.2 (GCC)
    [2] =>   configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    [3] =>   libavutil      52.  1.100 / 52.  1.100
    [4] =>   libavcodec     54. 69.100 / 54. 69.100
    [5] =>   libavformat    54. 35.100 / 54. 35.100
    [6] =>   libavdevice    54.  3.100 / 54.  3.100
    [7] =>   libavfilter     3. 20.109 /  3. 20.109
    [8] =>   libswscale      2.  1.101 /  2.  1.101
    [9] =>   libswresample   0. 16.100 /  0. 16.100
    [10] =>   libpostproc    52.  1.100 / 52.  1.100
    [11] => Input #0, ogg, from '\tmp\test-files\cd-quality-song.ogg':
    [12] =>   Duration: 00:03:18.93, start: 0.000000, bitrate: 455 kb/s
    [13] =>     Stream #0:0: Audio: vorbis, 44100 Hz, stereo, s16, 499 kb/s
    [14] =>     Metadata:
    [15] =>       ENCODER         : Lavf54.0.100
    [16] => Output #0, ogg, to '\tmp\test-files\cd-quality-song.ogg':
    [17] =>   Metadata:
    [18] =>     title           : ! Äüß!*
    [19] =>     artist          : Burzum #äääüüüüüß
    [20] =>     TRACKNUMBER     : 11
    [21] =>     date            : 2012
    [22] =>     album           : Test Album
    [23] =>     encoder         : Lavf54.35.100
    [24] =>     Stream #0:0: Audio: vorbis, 44100 Hz, stereo, 499 kb/s
    [25] =>     Metadata:
    [26] =>       ENCODER         : Lavf54.0.100
    [27] => Stream mapping:
    [28] =>   Stream #0:0 -> #0:0 (copy)
    [29] => Press [q] to stop, [?] for help
    [30] => size=      64kB time=00:00:01.11 bitrate= 465.7kbits/s    
    [31] => video:0kB audio:59kB subtitle:0 global headers:0kB muxing overhead 7.393971%
    [32] => 
)

2012-11-22 21:16:19 Shell-processor: \Lib\Utility\ShellProcessor.php Line: 102
2012-11-22 21:16:19 Shell-processor: \Bin\Win\ffmpeg\bin\ffmpeg.exe -i "\tmp\test-files\cd-quality-song.flac" -metadata title="! Äüß!*" -metadata artist="Burzum #äääüüüüüß" -metadata track="11" -metadata date="2012" -metadata album="Test Album" -c:a copy -id3v2_version 3 -write_id3v1 1 -y "\tmp\test-files\cd-quality-song.flac" 2>&1
2012-11-22 21:16:19 Shell-processor: \Lib\MetaData\FfmpegId3v2.php Line: 81
2012-11-22 21:16:19 Shell-processor: Array
(
    [0] => ffmpeg version N-46146-g11d695d Copyright (c) 2000-2012 the FFmpeg developers
    [1] =>   built on Oct 29 2012 18:10:27 with gcc 4.7.2 (GCC)
    [2] =>   configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    [3] =>   libavutil      52.  1.100 / 52.  1.100
    [4] =>   libavcodec     54. 69.100 / 54. 69.100
    [5] =>   libavformat    54. 35.100 / 54. 35.100
    [6] =>   libavdevice    54.  3.100 / 54.  3.100
    [7] =>   libavfilter     3. 20.109 /  3. 20.109
    [8] =>   libswscale      2.  1.101 /  2.  1.101
    [9] =>   libswresample   0. 16.100 /  0. 16.100
    [10] =>   libpostproc    52.  1.100 / 52.  1.100
    [11] => [flac @ 00000000037c3180] max_analyze_duration 5000000 reached at 5015510
    [12] => Input #0, flac, from '\tmp\test-files\cd-quality-song.flac':
    [13] =>   Metadata:
    [14] =>     ENCODER         : Lavf54.0.100
    [15] =>   Duration: 00:03:18.93, bitrate: 1045 kb/s
    [16] =>     Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
    [17] => Output #0, flac, to '\tmp\test-files\cd-quality-song.flac':
    [18] =>   Metadata:
    [19] =>     album           : Test Album
    [20] =>     title           : ! Äüß!*
    [21] =>     artist          : Burzum #äääüüüüüß
    [22] =>     TRACKNUMBER     : 11
    [23] =>     date            : 2012
    [24] =>     encoder         : Lavf54.35.100
    [25] =>     Stream #0:0: Audio: flac, 44100 Hz, stereo
    [26] => Stream mapping:
    [27] =>   Stream #0:0 -> #0:0 (copy)
    [28] => Press [q] to stop, [?] for help
    [29] => size=     768kB time=00:00:06.26 bitrate=1003.7kbits/s    
    [30] => video:0kB audio:760kB subtitle:0 global headers:0kB muxing overhead 1.083087%
    [31] => 
)

Here is the code that generated that:

/**
 * Executes
 *
 * @param string $params
 * @return array
 */
	public function execute($params = '') {
		$params = $this->beforeExecute($params);
		$command = $this->bin . ' ' . $params . ' 2>&1';
		$this->log($command, 'shell-processor');
		$this->rawData = shell_exec($command);
		return $this->afterExecute($this->rawData);
	}

comment:3 Changed 5 years ago by reimar

I'm fairly certain this is purely a PHP shell_exec issue, if you search around you will see that lots of people can't even get it to work on Linux.
While it depends on implementation internals, I suspect that chcp does not have the slightest effect on what happens here, it should basically only affect things that operate on an actual terminal.
Your output looks like your string gets converted by PHP to wchar/UCS-2 (the format in which FFmpeg will receive the commandline) by just expanding each byte to two, instead of by doing proper conversion from UTF-8.
For example this one mentions the "obvious" hack of using the native CreateProcessW, a function I am sure you will have a lot of "fun" with: http://stackoverflow.com/questions/9608583/pass-unicode-string-to-php-shell-exec-on-windows
Personally I hold it with: Windows, or using anything beyond plain ASCII, pick at most one.

comment:4 Changed 5 years ago by cehoyos

  • Resolution set to invalid
  • Status changed from new to closed

As I understand it, this is not a problem that can be fixed in FFmpeg.

Note: See TracTickets for help on using tickets.