radek-k / FFMediaToolkit

FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
MIT License
352 stars 56 forks source link

Error: Invalid data found when processing input #76

Closed leopripos closed 3 years ago

leopripos commented 3 years ago

Hi, I'm trying to use FFMediaToolkit in Jetson using ffmpeg for jetson from Nvidia FFmpeg

But it throws error when trying to open the file (mp4 and Codec: H264 - MPEG-4 AVC (part 10) (avc1)). The code part var file = MediaFile.Open(videoPath);

Here the error:

Unhandled exception. System.Exception: Failed to open the media file
 ---> FFMediaToolkit.FFmpegException: An error occurred while opening the file Error code: -1094995529 : Invalid data found when processing input
at FFMediaToolkit.Decoding.Internal.InputContainer.MakeContainer(String url, MediaOptions options, AVFormatContextDelegate contextDelegate)
at FFMediaToolkit.Decoding.Internal.InputContainer.LoadFile(String path, MediaOptions options)
at FFMediaToolkit.Decoding.MediaFile.Open(String path, MediaOptions options) 
--- End of inner exception stack trace --- 
at FFMediaToolkit.Decoding.MediaFile.Open(String path, MediaOptions options)
at FFMediaToolkit.Decoding.MediaFile.Open(String path)

Could you help me how to solve this issue?

leopripos commented 3 years ago

I'm using the latest (FFMediaToolkit 4.1.0) version BTW.

The ffmpeg share library /usr/lib/aarch64-linux-gnu/

libavcodec.so.57
libavcodec.so.57.107.100
libavdevice.so.57
libavdevice.so.57.10.100 
libavfilter.so.6 
libavfilter.so.6.107.100
libavformat.so.57
libavformat.so.57.83.100
libavresample.so.3
libavresample.so.3.7.0
libavutil.so.55
libavutil.so.55.78.10

So in my code, I added:

FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["avcodec"] = 57;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["avdevice"] = 57;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["avfilter"] = 6;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["avformat"] = 57;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["avutil"] = 55;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["postproc"] = 54;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["swresample"] = 2;
FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["swscale"] = 4;

could you help me please?

hey-red commented 3 years ago

You process multiple files? I noticed one thing - when I try to process multiple files in different threads (with different MediaFile instances) it crash with same error. So, I put lock to my operation and it works without errors. Maybe FFmpeg.Autogen needs lock for some operations that uses shared resources?

leopripos commented 3 years ago

I don't process multiple files, just a single file.

I have fixed this one, I updated the ffmpeg version using jocover/jetson-ffmpeg. It think it is because the version mismatch. And updated the library location to /usr/bin