Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8168265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:27:54+00:00 2026-06-06T20:27:54+00:00

I am creating a program to access information on different types of files, I

  • 0

I am creating a program to access information on different types of files, I have so far been successful mostly with MP3 files and am now working on the video MPG etc types.

So far I have been able to obtain Video Title, Year, Duration, Genre, video height and width with little effort and now I am attempting to access the slightly more difficult aspects from the VideoHeader section of TagLib.

This is the code I have managed to obtain from finding something about AudioHeaders on here but it didnt work:

TagLib.File f = TagLib.Mpeg.File.Create(GetMPG.FileName);

foreach(ICodec codec in f.Properties.Codecs){
  TagLib.Mpeg.VideoHeader G = (TagLib.Mpeg.VideoHeader) codec;
  MPGbps.Text = G.VideoFrameRate.ToString();
}

Where am I going wrong?

My new current code:

TagLib.File f = TagLib.File.Create(GetMPG.FileName);
foreach(ICodec codec in f.Properties.Codecs){
  TagLib.Mpeg.VideoHeader G = (TagLib.Mpeg.VideoHeader) codec;
  if (G != null)
    {
      MPGbps.Text = G.VideoFrameRate.ToString();
    }
}

This has ended in the error:

Error 2 Operator ‘!=’ cannot be applied to operands of type ‘TagLib.Mpeg.VideoHeader’ and ‘< null >’

note: added spaces in final null as it didn’t show up in the post otherwise

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:27:56+00:00Added an answer on June 6, 2026 at 8:27 pm

    Video files have multiple codecs, an audio and a video one. What’s happening with your code is that in one iteration of the loop, codec is not a VideoHeader meaning G is not set correctly. I’m not sure if this triggers an exception or if G is set to an empty VideoHeader.

    The below code should work:

    TagLib.File f = TagLib.File.Create(GetMPG.FileName);
    
    foreach(ICodec codec in f.Properties.Codecs){
      if(codec is TagLib.Mpeg.VideoHeader) {
        TagLib.Mpeg.VideoHeader G = (TagLib.Mpeg.VideoHeader) codec;
        MPGbps.Text = G.VideoFrameRate.ToString();
      }
    }
    

    Also, you should be using TagLib.File.Create instead. It is a static factory method.

    Update

    Beyond the above initial issue where codec was being cast as the wrong type, there was the issue that the file was not a MPEG and did not actually contain a TagLib.Mpeg.VideoHeader and had a TagLib.Riff.BitmapInfoHeader instead. Beyond the basic properties guaranteed by TagLib.IVideoCodec, the details provided by individual file formats varies widely on a case by case basis. It is important to know what file types are in scope, what features you want to detect, and extract video details as available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a program to open .txt files in a given directory, I have
I'm creating a program which downloads files off various types of servers, such as
I have been creating multiple background threads to parse xml files and recreate new
Bassicly im creating a program that reads information from an xml file into a
I'm creating a program in VB.NET to output multiple images. Some images will have
I am working on a program by C that some processes need to access
I have a program that's creating a secure directory for user output. This is
I have been given the task of creating a sql database and creating a
I have a multi-threaded Delphi program creating multiple instance of some classes, and I
Have a doubt in multithreading. Following is my main program to access a file,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.