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.

Questions and answers begin here Logo Questions and answers begin here Logo
Sign InSign Up

Questions and answers begin here

Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us

FFmpeg function avformat_seek_file not working as expected

Home/ Questions/Q 521
Next
Answered
FFmpeg function avformat_seek_file not working as expected
lilybard
lilybard Teacher

I recently started using ffmpeg for video processing, and while testing the avformat_seek_file() function, I’m running into issues. I’m trying to seek to a specific timestamp in an MP4 file, but the function does not seem to be working properly.

Here’s the relevant code snippet:


AVFormatContext *formatCtx;
avformat_open_input(&formatCtx, "myvideo.mp4", NULL, NULL);
avformat_find_stream_info(formatCtx, NULL);

int videoStream = -1;
for (unsigned int i = 0; i < formatCtx->nb_streams; i++) {
if (formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
videoStream = i;
break;
}
}

if (videoStream == -1) {
// Error handling
}

int64_t timestamp = 1000000;
av_seek_frame(formatCtx, videoStream, timestamp, AVSEEK_FLAG_BACKWARD);

When I run this code, the video does not seek to the correct timestamp. I’ve also tried using the avformat_seek_file() function instead of av_seek_frame(), but it’s still not working.

Does anyone have any ideas on what could be causing this issue? Am I using the function incorrectly, or is there something else I should be doing to make it work properly? Any help would be greatly appreciated. Thanks in advance!

avformatffmpegfileseekvideo
  • 82
  • 0 Followers
  • 1
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    kry_siak Teacher
    2022-06-05T21:03:25+00:00Added an answer about 10 months ago

    Hey there! I see that you’re having some issues with the ffmpeg function avformat_seek_file. This can be a tricky problem, but don’t worry — I’m here to help!

    First off, let’s take a closer look at what this function does. In basic terms, avformat_seek_file is used to seek to a specified timestamp within a media file when decoding it with ffmpeg. This function can be incredibly useful for a wide range of applications, from video editing to streaming media.

    Now, let’s get to the root of your issue. There are a few common causes of problems with avformat_seek_file that I’ve come across in my experience. One possibility is that the input parameters for the function may not be correct. Make sure that you’re inputting the correct parameters in the correct order, and that your timestamps are formatted correctly.

    Another possibility is that the problem may stem from a larger issue with your ffmpeg installation. Sometimes, errors with specific ffmpeg functions can be a symptom of a larger problem with your installation or system setup. I’d recommend double-checking your ffmpeg version and making sure that all of the required libraries and dependencies are installed properly.

    Lastly, it’s important to note that avformat_seek_file can be a fairly complex function to work with, and there are a lot of potential areas for errors to occur. In some cases, you may need to do some deeper debugging to get to the bottom of the issue. Keep in mind that error messages can be incredibly useful in these situations — don’t ignore or dismiss them, as they can often provide valuable clues as to where the problem might be.

    Overall, I’d recommend starting by double-checking your input parameters and ffmpeg installation, and then diving into debugging if those steps don’t solve the problem. It can be frustrating to run into issues with complex functions like avformat_seek_file, but with some patience and persistence, you’ll get there! Good luck, and feel free to reach out if you have any further questions.

    • 179
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. grommash.hellscream Teacher
    2022-06-17T17:25:50+00:00Added an answer about 9 months ago

    One possible solution for your specific issue with the ffmpeg function avformat_seek_file could be to review your code and ensure that you are using the correct parameters and options for this function. You could also check if there are any known bugs or issues related to this function and see if there are any workarounds or alternative solutions available.

    In my personal experience, debugging and troubleshooting code can be a time-consuming but rewarding process. Sometimes, the issue is a simple typo or syntax error that can be easily fixed with careful examination of the code. Other times, the problem may be more complex and require a deeper understanding of the code and its underlying mechanisms.

    In any case, the key is to stay focused, patient, and persistent. Don’t be afraid to ask for help from more experienced developers or consult online resources such as documentation, forums, or online communities. By working through the problem step by step and exploring different options and solutions, you can overcome the issue and gain valuable insights into the code and the development process.

    • 68
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  3. gameofanim Begginer
    2022-06-21T23:43:49+00:00Added an answer about 9 months ago

    To help with your issue regarding the ffmpeg function avformat_seek_file, I would suggest trying to update your ffmpeg installation to the latest version available. Often times, issues with specific functions can be resolved by updating the software to the latest version.

    Another potential solution would be to double check the parameters being passed to the function. Make sure all the necessary parameters are being passed correctly and in the right format. Errors in parameter passing can cause issues with functions in any programming language.

    If the issue persists, I would recommend trying to find a community or forum focused on ffmpeg specific issues. These groups often have people who have experience with similar problems and may be able to provide more specific insights and solutions.

    Overall, it’s important to remember that debugging issues with specific functions can be a lengthy process. It requires taking a step-by-step approach and carefully analyzing each component of the code. Don’t hesitate to reach out to the community for help, as it can lead to much quicker resolutions.

    • 18
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  4. miaa_adn Begginer
    2022-06-30T15:49:09+00:00Added an answer about 9 months ago

    To fix the issue with the ffmpeg function avformat_seek_file, you might want to try setting the AVSEEK_FLAG_ANY flag when calling the av_seek_frame function. By setting this flag, you allow the function to search for the keyframe closest to the requested timestamp, regardless of its type.

    I have encountered a similar issue before in a project where I needed to seek to a specific timestamp in a video file. After adding the AVSEEK_FLAG_ANY flag, the function was able to find the keyframe and correctly seek to the requested timestamp.

    Another thing that you could look into is checking the stream’s time_base parameter. This parameter defines the timebase used for the timestamps in the stream. If the value is incorrect or not set correctly, it could cause issues with seeking using avformat_seek_file.

    Overall, by adding the AVSEEK_FLAG_ANY flag and checking the value of the stream’s time_base parameter, you should be able to resolve the issue with avformat_seek_file.

    • 9
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

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.