No Codec Error while resizing mp4 video (1.21 version x86 C#)

11 views
Skip to first unread message

Kiran Kumar

unread,
Oct 8, 2015, 7:03:12 PM10/8/15
to avblocks-support
I am trying to resize a mp4 with resolution 1912 X 1072 to 640 X 480.
But I am getting errors while executing the transcoder.

Below is the code I am using

using (MediaInfo mediaInfo = new MediaInfo())
{
mediaInfo.InputFile = inputFileName;//Input mp4 video

if (!mediaInfo.Load())
{
MessageBox.Show(string.Format("{0} Error, Code: {1} ({2})", mediaInfo.Error.Facility, mediaInfo.Error.Code, mediaInfo.Error.Message ?? ""));
}

using (Transcoder t = new Transcoder())
{
t.AllowDemoMode = true;

MediaSocket insocket = MediaSocket.FromMediaInfo(mediaInfo);
t.Inputs.Add(insocket);
MediaSocket outsocket = MediaSocket.FromPreset("iphone.mp4.h264.480p");
if (outsocket == null)
{
MessageBox.Show("Error");
}
outsocket.File = "C:\\AvBlockOutput\\Test.mp4";
t.Outputs.Add(outsocket);

if (!t.Open())
MessageBox.Show(string.Format("{0} Error, Code: {1} ({2})", t.Error.Facility, t.Error.Code, t.Error.Message ?? ""));

if (!t.Run())
MessageBox.Show(string.Format("{0} Error, Code: {1} ({2})", t.Error.Facility, t.Error.Code, t.Error.Message ?? ""));
t.Close();
}
}

While t.Open is executing Transcoder Error, Code: 4 (No Codec) error is thrown and while t.Run is executing Codec Error, Code: 14 (Invalid Operation) error is thrown

Project settings used, TargetFramework – .NET Framwework 4.6, Platform Target – x86

Am I missing some initialization or doing something wrong?

Milen Yordanov

unread,
Oct 9, 2015, 4:31:26 AM10/9/15
to avblocks-support
Hi Kiran,
There are two special ABlocksSDK methods: Library.Initialize() and Library.Shutdown();
Library.Initialize() - Must be called once before the library is used, usually when the application starts.
Library.Shutdown() - Should be called when the library will not be used anymore, e.g. when the application ends.
If Library.Initialize() is not called then the Transcoder object will not work. That's why it returns "No Codec Error".
Please make sure Library.Initialize() is called in your code.
The sample VideoConverter calls Library.Initialize() and Library.Shutdown() in the Main() method.


Greetings,
Milen

Kiran Kumar

unread,
Oct 9, 2015, 2:23:00 PM10/9/15
to avblocks-support
Hi Milen
That works.
Thanks

Regards
Kiran

avblocks-support

unread,
Oct 9, 2015, 4:06:30 PM10/9/15
to avblocks-support
This example may be helpful.
Reply all
Reply to author
Forward
0 new messages