[Libav-user] A/V synchronization for an emulator movie recording feature

Ulf Magnusson ulfalizer at gmail.com
Sat Oct 26 07:39:04 CEST 2013


I'm adding a movie recording feature to an emulator I'm working on. I
have the video part working, but since I'm new to movie encoding I'm
unsure what the best practices are when it comes to audio/video
synchronization. I'm aware of these two approaches:

(1) Set PTS values on video and/or audio packets before writing them
with av_interleaved_write_frame().
(2) Stretch/shrink audio to maintain A/V synchronization.

Perhaps (1) should be done even if (2) is done, but I'm not sure how
these two approaches would interact. I've also heard that some
formats/players don't support PTS values for audio frames.

Any recommendations? Latency would not be an issue since you wouldn't
view the movie while playing. I'd prefer for the video to be as smooth
as possible, without jerky motion when scrolling.

The current WIP without audio is at
https://github.com/ulfalizer/nesalizer/blob/movie-wip/movie.cpp (I
based it on libavformat/output-example.c). I'd probably have an
add_audio_frame() function to go with add_video_frame().


More information about the Libav-user mailing list