Skip to content

Issue with incorrect file import using MLT Library #1073

Closed as not planned
Closed as not planned

Description

@ice0

Hi, guys!

First of all, thank you so much for your excellent library!

Now, onto the issue:

We are currently experiencing a problem with incorrect file import when using the MLT library.
Specifically, we have a file that is being decoded incorrectly upon import.
The file shows incorrect metadata such as sample rate, duration, etc.

Here is the output of some fields after creating a producer:

Mlt::Producer *track = new Mlt::Producer(profile, (std::string("avformat:") + real_filename).c_str());

Output:
Duration (frames): 2147483647
Frame rate: 25
Sample rate: 0
Channels: 0

Initially, we thought we might be using the API incorrectly, so we tried converting the file using melt.
However, the conversion command never completes:

melt ./crash-audio-file.flac -consumer avformat:output.mp3

Interestingly, ffmpeg works fine with the same file:

ffmpeg -i ./crash-audio-file.flac out.mp3

Could you suggest what might be causing this issue?

OS: Linux Mint 22 (Ubuntu 24.04 based)

crash-audio-file.flac.zip

Activity

  1. ddennedy commented on Mar 16, 2025

    @ddennedy
    Member

    It is working for me using the version of MLT included in the Linux Mint 22 repos. It also works for me using a Shotcut build I make for shotcut.org for any OS. You can easily try that yourself. Here is mint output:

    melt -consumer xml '/home/ddennedy/Music/01-Stereo Test Tone.flac'
    No LADSPA plugins were found!
    
    Check your LADSPA_PATH environment variable.
    <?xml version="1.0"?>
    <mlt LC_NUMERIC="C" version="7.22.0" title="01-Stereo Test Tone.flac">
      <profile description="DV/DVD PAL" width="720" height="576" progressive="0" sample_aspect_num="16" sample_aspect_den="15" display_aspect_num="4" display_aspect_den="3" frame_rate_num="25" frame_rate_den="1" colorspace="601"/>
      <producer id="producer0" in="0" out="106">
        <property name="length">107</property>
        <property name="eof">pause</property>
        <property name="resource">/home/ddennedy/Music/01-Stereo Test Tone.flac</property>
        <property name="meta.media.nb_streams">1</property>
        <property name="meta.media.0.stream.type">audio</property>
        <property name="meta.media.0.codec.sample_fmt">s32</property>
        <property name="meta.media.0.codec.sample_rate">96000</property>
        <property name="meta.media.0.codec.channels">2</property>
        <property name="meta.media.0.codec.name">flac</property>
        <property name="meta.media.0.codec.long_name">FLAC (Free Lossless Audio Codec)</property>
        <property name="meta.media.0.codec.bit_rate">0</property>
        <property name="meta.attr.ALBUM.markup">The Well-Tempered Synthesizer</property>
        <property name="meta.attr.track.markup">1</property>
        <property name="meta.attr.DATE.markup">1969</property>
        <property name="meta.attr.ARTIST.markup">Walter Carlos</property>
        <property name="meta.attr.GENRE.markup">Electronic</property>
        <property name="meta.attr.TITLE.markup">Stereo Test Tone</property>
        <property name="seekable">1</property>
        <property name="audio_index">0</property>
        <property name="video_index">-1</property>
        <property name="mute_on_pause">0</property>
        <property name="mlt_service">avformat</property>
      </producer>
      <playlist id="playlist0">
        <entry producer="producer0" in="0" out="106"/>
      </playlist>
      <tractor id="tractor0" title="01-Stereo Test Tone.flac" in="0" out="106">
        <track producer="playlist0"/>
      </tractor>
    </mlt>
    

    Maybe you are using an old version of MLT. There was an important fix for FLAC committed around 2 years ago.,

  2. ice0 commented on Mar 17, 2025

    @ice0
    ContributorAuthor

    Yes, but could you please check the attached file?
    This is what it shows on my system:

    melt -consumer xml ./crash-audio-file.flac                        
    No LADSPA plugins were found!
    
    Check your LADSPA_PATH environment variable.
    <?xml version="1.0"?>
    <mlt LC_NUMERIC="C" version="7.22.0" title="crash-audio-file.flac">
      <profile description="DV/DVD PAL" width="720" height="576" progressive="0" sample_aspect_num="16" sample_aspect_den="15" display_aspect_num="4" display_aspect_den="3" frame_rate_num="25" frame_rate_den="1" colorspace="601"/>
      <producer id="producer0" in="0" out="2147483646">
        <property name="length">2147483647</property>
        <property name="eof">loop</property>
        <property name="resource">./crash-audio-file.flac</property>
        <property name="meta.media.nb_streams">1</property>
        <property name="meta.media.0.stream.type">audio</property>
        <property name="meta.media.0.codec.sample_fmt">s16</property>
        <property name="meta.media.0.codec.sample_rate">44100</property>
        <property name="meta.media.0.codec.channels">2</property>
        <property name="meta.media.0.codec.name">flac</property>
        <property name="meta.media.0.codec.long_name">FLAC (Free Lossless Audio Codec)</property>
        <property name="meta.media.0.codec.bit_rate">0</property>
        <property name="seekable">1</property>
        <property name="audio_index">0</property>
        <property name="video_index">-1</property>
        <property name="mute_on_pause">0</property>
        <property name="mlt_service">avformat</property>
      </producer>
      <playlist id="playlist0">
        <entry producer="producer0" in="0" out="2147483646"/>
      </playlist>
      <tractor id="tractor0" title="crash-audio-file.flac" in="0" out="2147483646">
        <track producer="playlist0"/>
      </tractor>
    </mlt>

    As you may notice length is 2147483647.

  3. ddennedy commented on Mar 17, 2025

    @ddennedy
    Member

    That value is INT_MAX, which is our special value that means unknown or possibly a live source. MLT uses the duration provided by AVFormatContext.duration. For this file, FFmpeg libavformat returns AV_NOPTS_VALUE, which is their constant for the same thing. ffprobe on the file reports "Duration: N/A ... bitrate: N/A". MLT cannot determine length by decoding a file until it ends or errors to determine its length because that will take took long. I suppose a ffmpeg transcode command does that, but MLT is more complicated than that. You, the user or application, can choose to do that and set the "length" property on the producer. Not every file can be used with MLT and some can be converted using remux, transmux, or transcode to be usable.

  4. ice0 commented on Mar 23, 2025

    @ice0
    ContributorAuthor

    Dan, thank you for the detailed explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions