Wait...it's easier than that...instead of having to fetch a QTextCodec, I can 
just call QString::fromUtf8().
New patch. :-)

Steven Boswell



________________________________
 From: Steven Boswell II <[email protected]>
To: "[email protected]" <[email protected]> 
Sent: Sunday, May 12, 2013 3:35 PM
Subject: Re: [Mixxx-devel] Mixxx and FFMPEG/Libav status update
 


Tuukka:

So far, all I've noticed wrong is the Unicode handling for metadata (artist, 
title, etc.)
The enclosed patch fixes that.

I also noticed that you're apparently having problems with Unicode paths under 
MS Windows.  After digging around for a while, it appears that this is a known 
bug, though ff_win32_open() in libavformat/os_support.c (at least in my version 
of ffmpeg, i.e. 1.0.5) seems to be doing the right thing for UTF-8.  So it's 
still a mystery.  But maybe this will help you track down the problem.

Steven Boswell


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Get Mixxx, the #1 Free MP3 DJ Mixing software Today
http://mixxx.org


Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel
diff -ur mixxx-cleaned/src/soundsourceffmpeg.cpp mixxx/src/soundsourceffmpeg.cpp
--- mixxx-cleaned/src/soundsourceffmpeg.cpp	2013-05-12 11:34:19.268383000 -0700
+++ mixxx/src/soundsourceffmpeg.cpp	2013-05-12 15:45:37.682676947 -0700
@@ -29,6 +29,7 @@
 //#endif
 
 #include <QDebug>
+#include <QTextCodec>
 
 static QMutex ffmpegmutex;
 static bool ffmpeginit = false;
@@ -161,6 +162,8 @@
      * The method toLocal8Bit() returns the local 8-bit representation of the string as a QByteArray.
      * The returned byte array is undefined if the string contains characters not supported
      * by the local 8-bit encoding.
+     *
+     * See https://ffmpeg.org/trac/ffmpeg/ticket/819 for relevant bug report.
      */
     QByteArray qBAFilename = m_qFilename.toLocal8Bit();
 #else
@@ -408,10 +411,10 @@
 #else
         uint8_t **l_pIn = (uint8_t **)inframe->extended_data;
 #endif
-	
+    
 
 #else
-	int64_t l_lInReadBytes = av_samples_get_buffer_size(NULL, m_pCodecCtx->channels,
+    int64_t l_lInReadBytes = av_samples_get_buffer_size(NULL, m_pCodecCtx->channels,
                                  inframe->nb_samples,
                                  m_pCodecCtx->sample_fmt, 1);
 #endif
@@ -422,7 +425,7 @@
 
         int l_iOutSamplesLines = 0;
 
-	// Alloc too much.. if not enough we are in trouble!
+    // Alloc too much.. if not enough we are in trouble!
         av_samples_alloc(&m_pOut, &l_iOutSamplesLines, 2, l_iOutSamples, AV_SAMPLE_FMT_S16, 0);
 #else
         int l_iOutSamples = av_rescale_rnd(inframe->nb_samples, m_pCodecCtx->sample_rate, m_pCodecCtx->sample_rate, AV_ROUND_UP);
@@ -691,6 +694,8 @@
      * The method toLocal8Bit() returns the local 8-bit representation of the string as a QByteArray.
      * The returned byte array is undefined if the string contains characters not supported
      * by the local 8-bit encoding.
+     *
+     * See https://ffmpeg.org/trac/ffmpeg/ticket/819 for relevant bug report.
      */
     QByteArray qBAFilename = m_qFilename.toLocal8Bit();
 #else
@@ -730,22 +735,24 @@
     //qDebug() << "ffmpeg: Parse HEADER [MP3,WMA]";
 
     while ((FmtTag = av_dict_get(FmtCtx->metadata, "", FmtTag, AV_DICT_IGNORE_SUFFIX))) {
+        // Convert the value from UTF-8.
+        QString strValue (QString::fromUtf8 (FmtTag->value));
 
         if( !strncmp( FmtTag->key, "artist", 7) ) {
-            //qDebug() << "ffmpeg: HEADER [MP3,WMA] artist: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setArtist(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [MP3,WMA] artist: " << FmtTag->key << " = "<< strValue;
+            this->setArtist(strValue);
         } else if( !strncmp( FmtTag->key, "album", 5) ) {
-            //qDebug() << "ffmpeg: HEADER [MP3,WMA] album: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setAlbum(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [MP3,WMA] album: " << FmtTag->key << " = "<< strValue;
+            this->setAlbum(strValue);
         } else if( !strncmp( FmtTag->key, "date", 4) ) {
-            //qDebug() << "ffmpeg: HEADER [MP3,WMA] date: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setYear(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [MP3,WMA] date: " << FmtTag->key << " = "<< strValue;
+            this->setYear(strValue);
         } else if( !strncmp( FmtTag->key, "genre", 5) ) {
-            //qDebug() << "ffmpeg: HEADER [MP3,WMA] genre: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setGenre(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [MP3,WMA] genre: " << FmtTag->key << " = "<< strValue;
+            this->setGenre(strValue);
         } else if( !strncmp( FmtTag->key, "title", 5) ) {
-            //qDebug() << "ffmpeg: HEADER [MP3,WMA] genre: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setTitle(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [MP3,WMA] genre: " << FmtTag->key << " = "<< strValue;
+            this->setTitle(strValue);
         }
 
 
@@ -754,30 +761,33 @@
     //qDebug() << "ffmpeg: Parse HEADER [OGG, FLAC]";
 
     while ((FmtTag = av_dict_get(FmtCtx->streams[m_iAudioStream]->metadata, "", FmtTag, AV_DICT_IGNORE_SUFFIX))) {
+        // Convert the value from UTF-8.
+        QString strValue (QString::fromUtf8 (FmtTag->value));
+
         if( !strncmp( FmtTag->key, "ARTIST", 7) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] artist: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setArtist(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [OGG] artist: " << FmtTag->key << " = "<< strValue;
+            this->setArtist(strValue);
         } else if( !strncmp( FmtTag->key, "ALBUM", 5) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] album: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setAlbum(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [OGG] album: " << FmtTag->key << " = "<< strValue;
+            this->setAlbum(strValue);
         } else if( !strncmp( FmtTag->key, "YEAR", 4) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] year: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setYear(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [OGG] year: " << FmtTag->key << " = "<< strValue;
+            this->setYear(strValue);
         } else if( !strncmp( FmtTag->key, "GENRE", 5) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] genre: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setGenre(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [OGG] genre: " << FmtTag->key << " = "<< strValue;
+            this->setGenre(strValue);
         } else if( !strncmp( FmtTag->key, "TITLE", 5) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] title: " << FmtTag->key << " = "<< FmtTag->value;
-            this->setTitle(FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [OGG] title: " << FmtTag->key << " = "<< strValue;
+            this->setTitle(strValue);
         } else if( !strncmp( FmtTag->key, "REPLAYGAIN_TRACK_PEAK", 20) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_TRACK_PEAK: " << FmtTag->key << " = "<< FmtTag->value;
+            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_TRACK_PEAK: " << FmtTag->key << " = "<< strValue;
         } else if( !strncmp( FmtTag->key, "REPLAYGAIN_TRACK_GAIN", 20) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_TRACK_GAIN: " << FmtTag->key << " = "<< FmtTag->value;
-            this->parseReplayGainString (FmtTag->value);
+            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_TRACK_GAIN: " << FmtTag->key << " = "<< strValue;
+            this->parseReplayGainString (strValue);
         } else if( !strncmp( FmtTag->key, "REPLAYGAIN_ALBUM_PEAK", 20) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_ALBUM_PEAK: " << FmtTag->key << " = "<< FmtTag->value;
+            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_ALBUM_PEAK: " << FmtTag->key << " = "<< strValue;
         } else if( !strncmp( FmtTag->key, "REPLAYGAIN_ALBUM_GAIN", 20) ) {
-            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_ALBUM_GAIN: " << FmtTag->key << " = "<< FmtTag->value;
+            //qDebug() << "ffmpeg: HEADER [OGG] REPLAYGAIN_ALBUM_GAIN: " << FmtTag->key << " = "<< strValue;
         }
 
 
Only in mixxx/src: .soundsourceffmpeg.cpp.swp
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Get Mixxx, the #1 Free MP3 DJ Mixing software Today
http://mixxx.org


Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to