Skip to main content
TagQt provides FLAC re-encoding capabilities to convert FLAC files to a standardized format (24-bit/48kHz) while preserving all metadata and cover art.

Overview

The FLAC re-encoding feature uses FFmpeg to convert FLAC files to 24-bit/48kHz format with compression level 5, ensuring consistent audio quality across your library.

Requirements

FFmpeg Installation

The re-encoding feature requires FFmpeg to be installed on your system:
sudo apt install ffmpeg
TagQt automatically detects if FFmpeg is installed. If not available, you’ll see an error message with installation instructions.

Encoding Specifications

The re-encoding process converts FLAC files to the following specifications:
ParameterValueDescription
Sample Format32-bit signed integer (s32)Provides 24-bit depth
Sample Rate48000 HzProfessional audio standard
Compression Level5Balance between size and speed
MetadataPreservedAll tags retained
Cover ArtPreservedAlbum artwork maintained

FFmpeg Command

The actual FFmpeg command used (from flac.py:62-71):
cmd = ['ffmpeg', '-y', '-i', filepath, 
       '-map_metadata', '0',
       '-c:a', 'flac', 
       '-compression_level', '5',
       '-sample_fmt', 's32',
       '-ar', '48000',
       '-c:v', 'copy', temp_path]

Command Breakdown

  • -y - Overwrite output file without asking
  • -i filepath - Input file
  • -map_metadata 0 - Copy all metadata from input
  • -c:a flac - Use FLAC codec for audio
  • -compression_level 5 - Medium compression
  • -sample_fmt s32 - 32-bit signed integer samples (24-bit depth)
  • -ar 48000 - 48kHz sample rate
  • -c:v copy - Copy video streams (cover art) as-is

Metadata Preservation

The re-encoding process carefully preserves all metadata:

Tags Preserved

All standard and extended tags are preserved during re-encoding:
# From flac.py:42-47
for attr in ['title', 'artist', 'album', 'year', 'genre', 
             'track_number', 'disc_number', 'album_artist', 
             'comment', 'lyrics', 'bpm', 'initial_key', 
             'isrc', 'publisher']:
    val = getattr(original_meta, attr)
    if val:
        tags_to_preserve[attr] = val

Cover Art Preservation

Cover art is extracted before encoding and restored afterward:
# From flac.py:49
cover_data = original_meta.get_cover()

# After encoding (flac.py:87-88)
if cover_data:
    new_meta.set_cover(cover_data)

Using FLAC Re-encoding

From the Menu

  1. Navigate to Tools → File Actions → Re-encode FLAC
  2. Choose Selected or All Visible
  3. Wait for the encoding process to complete
  4. Review the results in the batch status dialog

From the Context Menu

  1. Right-click on selected FLAC files
  2. Choose Re-encode FLAC (Selected)

From the Sidebar

When viewing a FLAC file:
  1. Click the Re-encode FLAC button in the sidebar
  2. The current file will be re-encoded

From the Command Palette

  1. Press Ctrl+K
  2. Search for “Re-encode FLAC”
  3. Select the command

File Processing

The re-encoding process follows these steps:
  1. Validation - Confirms file is a FLAC file
  2. Metadata Backup - Extracts all tags and cover art
  3. Temporary Encoding - Creates encoded file in temp location
  4. Metadata Restoration - Restores all tags to new file
  5. File Replacement - Replaces original with re-encoded file
  6. Cleanup - Removes temporary files
# From flac.py:57-95
temp_fd, temp_path = tempfile.mkstemp(suffix='.flac')
# ... encoding process ...
shutil.move(temp_path, filepath)  # Replace original

Error Handling

Common Errors

Error: “Neither flac nor ffmpeg is installed”Solution: Install FFmpeg using your system’s package manager (see Requirements section)
Error: “Not a FLAC file”Solution: The re-encoding feature only works with .flac files. Other formats are automatically skipped.
Error: “Encoding failed: [stderr output]”Solution: Check the error message for details. Common causes include:
  • Corrupted input file
  • Insufficient disk space
  • File permissions issues

Batch Operations

When re-encoding multiple files:
  • Progress is displayed in real-time
  • Each file is processed sequentially
  • Failed files don’t stop the batch operation
  • Detailed results are available in the batch status dialog
  • Click the progress bar to view detailed status
Re-encoding is a CPU-intensive operation. For large libraries, consider running the operation in smaller batches or when you don’t need to use your computer for other tasks.

Performance Considerations

Processing Time

Re-encoding time depends on:
  • Original file size and length
  • CPU performance
  • Compression level (fixed at 5)
Typical processing time: 1-3 seconds per minute of audio

Disk Space

Temporary disk space required:
  • At least 2x the size of the largest file being processed
  • Temporary files are automatically cleaned up after processing

Best Practices

Re-encoding is a destructive operation. The original file is replaced with the re-encoded version. Always maintain backups of your original files.

Recommendations

  1. Test first: Re-encode a single file and verify the output before batch processing
  2. Check metadata: Verify that all tags and cover art are preserved after encoding
  3. Listen test: Compare audio quality before and after encoding
  4. Backup: Always maintain backups of your original FLAC files
  5. Free space: Ensure adequate disk space before starting large batch operations

Technical Details

Source Code Reference

  • Source: tagqt/core/flac.py
  • Class: FlacEncoder
  • Main Method: reencode_flac(filepath)
  • Worker: FlacReencodeWorker (in tagqt/ui/workers.py)

Encoder Detection

# From flac.py:17-23
@staticmethod
def get_available_encoder():
    if FlacEncoder.is_flac_available():
        return 'flac'
    elif FlacEncoder.is_ffmpeg_available():
        return 'ffmpeg'
    return None
TagQt first checks for the flac command-line tool, then falls back to FFmpeg. Both can be used for re-encoding.

Build docs developers (and LLMs) love