accord-net / framework

Machine learning, computer vision, statistics and general scientific computing for .NET
http://accord-framework.net
GNU Lesser General Public License v2.1
4.48k stars 1.99k forks source link

Cannot open audio codec when use ffmpeg.videofileWriter.Open #959

Open syevanchen opened 6 years ago

syevanchen commented 6 years ago

Issue description when i use accord.video.ffmpeg.videofilewrite to open a writer, an exception occured.

code: videoWriter.Open(videoFileFullPath, w, h, frameRate, VideoCodec.H264, bitRate, AudioCodec.AAC, audioBitrate, sampleRate, channels);

Exception: Accord.Video.VideoException: Cannot open audio codec. in Accord.Video.FFMPEG.open_audio(WriterPrivateData data)

I have put ffmpeg's dll in the exe path.

syevanchen commented 6 years ago

which version ffmpeg is compatiable with accord.net 3.7.0 ?

cesarsouza commented 6 years ago

Hi @syevanchen,

Thanks for opening the issue! There are a couple of issues that I plan to solve regarding FFMPEG after release 3.8, audio support being one of them. The FFMPEG version that Accord.NET 3.7.0 uses is 3.2.2, that can be found in the https://github.com/accord-net/framework/tree/development/Externals/ffmpeg folder here in the framework's repository.

If you would like to try to take a look on the issue yourself, you can first try to download the framework's source code here from GitHub and try to add a new unit test to one of the classes in https://github.com/accord-net/framework/tree/development/Unit%20Tests/Accord.Tests.Video reproducing this issue.

Regards, Cesar

syevanchen commented 6 years ago

thanks for the replay.

when I use accord.net 3.7.0 with ffmpeg 3.2.2, the bug still reproduces.

The accord net 3.3.0 with ffmpeg 3.2.2 has not the problem.

another issue, when use 3.3.0 with 3.2.2, the voice and the video is not sync.

cesarsouza commented 6 years ago

A new (pre-release) version of Accord.Video.FFMPEG has just been pushed to NuGet. If it helps solving the issue (and if it isn't too late for you of course, as I realize it has been some time since the issue was first opened), please let me know!

Regards, Cesar

thijse commented 5 years ago

Hi, I still seem to have this problem in FFMPEG.x64, version 3.8

conghe2402 commented 5 years ago

@cesarsouza Hi, have this issue resolved? cannot open audio device!

conghe2402 commented 5 years ago

using the latest version 3.8.2 alpha there is no this issue,but the pts_time is faster than dts_time 2 times when playing the video file.

NoelFuentesCarmona commented 5 years ago

When using a _writer.WriteAudioFrame (eventArgs.Signal.RawData); To add the audio to the video, an exception is thrown.

Code:

private void audioDevice_NewFrame (object sender, Accord.Audio.NewFrameEventArgs eventArgs) { lock (syncObj) // Save the frame to the video file. { if (IsRecording) { _writer.WriteAudioFrame (eventArgs.Signal.RawData);

        }
    }

Exception: Unhandled exception of type 'System.AccessViolationException' in Accord.Video.FFMPEG.dll

Additional information: Attempt to read or write to protected memory. Often, this indicates that there is another memory damaged.

LunevNF commented 5 years ago

@NoelFuentesCarmona I have the same issue, can't put audio frames. If I set AudioCodec.None - audio not exists in video. :(