Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ffmpeg accurate timing with video/audio extraction

Posted on 2014-03-15
3
Medium Priority
?
729 Views
Last Modified: 2014-03-15
I am trying to extract very small pieces of a .mp4 file using ffmpeg.

I am using ffmpeg at the command line for this.

I am using win32 static build, build on 3/14/2014.
(Does ffmpeg for linux work better than ffmpeg for windows?)

An example extract command is -
ffmpeg -ss 20.05 -i robert2.mp4 -t 0.1 -c copy output2.mp4

In this example I am trying to start at a position of 20.05 seconds and extract .1 seconds of video.

the problem is that ffmpeg seems to be aligning itself to certain boundaries.

So it doesn't seem to matter whether I tell it to start at 20.0 seconds or 20.5 seconds, it still seems to start at the same point.

I have also tried using frames -
ffmpeg -i robert2.mp4 -ss 14.6 -frames:v 20 output3.mp4

Using frames seems to be very accurate, but the audio and the video don't seem to sync properly.

Does anyone know how to get ffmpeg to give me very accurate small extractions?

I need to go down to < .1 second resolution.  Also, I need the audio to properly extract and sync as well.

Or is there a better command line tool for this?

I am willing to pay for a  tool (within reasonable cost) as long as I can use it at the command line and/or with scripting and as long as it is accurate and efficient.

Thanks, Kevin.
0
Comment
Question by:kevinvw1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 total points
ID: 39931885
AFAIK, on encoding you setup key frames. Usually at 10-15 frames interval.
When you tell ffmpeg to give you something at some point in time, it will start from the nearest key frame, cause that's the first full image it has.

I think you'll need to reencode the movie and setup every key as a key frame.

The definition from Final Cut manual:
Key Frames: Key frames are available if your selected codec uses temporal compression. Most video frames in close proximity have a high percentage of visual redundancy. Compression key frames reduce data rate by only storing complete images at regular intervals or when abrupt visual shifts occur. The remaining frames only store information about the change, or delta, between themselves and the key frame. Increasing the number of frames between key frames increases the amount of compression and makes the final file size smaller.

HTH,
Dan
0
 

Author Comment

by:kevinvw1
ID: 39932212
Yes!  It was the key frames.  I re-encoded using a key frame interval of 2 -

ffmpeg -i robert2.mp4 -g 2 robert3.mp4

The video went from 2 megs to 14 megs, but now I can accurately edit it on 2 frame intervals which is about 1/15 of second.

Thanks a million!

Kevin.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39932219
Glad I could help!
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question