NativeInstruments / ni-media

NI Media is a C++ library for reading and writing audio streams.
MIT License
235 stars 34 forks source link

Linux does not support mp4 or m4a? #41

Closed lqniunjunlper closed 3 years ago

lqniunjunlper commented 4 years ago

Only wav?

lqniunjunlper commented 4 years ago

Makefile:

if ( APPLE OR WIN32 ) option( NIMEDIA_ENABLE_MP3_DECODING "Enable ni-media mp3 decoding" ON ) option( NIMEDIA_ENABLE_MP4_DECODING "Enable ni-media mp4 decoding" ON ) else() option( NIMEDIA_ENABLE_MP3_DECODING "Enable ni-media mp3 decoding" OFF ) option( NIMEDIA_ENABLE_MP4_DECODING "Enable ni-media mp4 decoding" OFF ) endif()

In os_source.h, there is no os_source definition for Linux?

`#pragma once

include <ni/media/audio/source_impl.h>

include <boost/predef.h>

if BOOST_OS_MACOS || BOOST_OS_IOS

include <ni/media/audio/os/mac/core_audio_source.h>

template using os_source = source_impl<core_audio_source>;

elif BOOST_OS_WINDOWS

include <ni/media/audio/os/win/media_foundation_source.h>

template using os_source = source_impl<media_foundation_source>;

endif`

``

lqniunjunlper commented 4 years ago

On Linux, i got an error of Segmentation fault.

ifstream.cpp:65] ifstream:ttt.wav Segmentation fault

std::string file="test.wav"; auto stream = audio::ifstream(file);

`ifstream::ifstream( const std::string& file ) : ifstream() {

if NIMEDIA_ENABLE_ITUNES_DECODING

if ( is_itunes_url( file ) )
{
    auto source = avassetreader_source( file, 0 );
    auto info   = source.info();
    *this = ifstream( make_stream_buffer( std::move( source ) ), std::make_unique<info_type>( std::move( info ) ) );
    return;
}

endif

LOG(INFO) << __func__ << ":" << file;

auto container = ifstream_container( file );
if ( !container )
    throw std::runtime_error( "Unsupported file extension" );

*this = ifstream( file, *container );

LOG(INFO) << __func__ << " done!";

} `

marcrambo commented 4 years ago

Mp3 and Mp4 are currently not supported on Linux. On linux only wav, aiff, ogg and flac extensions are supported see https://github.com/NativeInstruments/ni-media/blob/master/audiostream/doc/ifstream.md.

The audio:.ifstream constructor will throw a runtime error when passing an unsupported file path, which is expected behavior. Client code should be using a try / catch block around the constructor and decide what to do in this case.

lqniunjunlper commented 4 years ago

Thanks@marcrambo Why Linux can not support mp4? Is there any plan for supporting mp4 on Linux? Another question is how can we get meatadata of music, like sample-rate, bit-rate, artist,...

lqniunjunlper commented 4 years ago

How to generate a new music audio from scratch, in which there is track name, artist, etc,... More importantly it can be played in musicpalyer.

FalconPDX commented 4 years ago

@lqniunjunlper ni-media does not generate audio, but simply streams it. If you're looking for metadata support, you should check out TagLib, which you can use alongside ni-media.

FalconPDX commented 4 years ago

Regarding your other comment about mp4 support, there was an initiative to integrate GStreamer into ni-media, which you can take a look at here: https://github.com/NativeInstruments/ni-media/pull/11

lqniunjunlper commented 4 years ago

@FalconPDX Thanks