![]() |
#1 | Link |
---|---|
i5mast Registered User Join Date: Nov 2011 |
ffmpeg: -vsync 0 versus -r (frame rate) |
<br /> Are these two options mutually exclusive?
I have Office LiveMeeting presentation encoded in WMV3 and WMA. The video is about 1h long and it contains only static slides. There are a total of 151 key frames in WMV video. Some frames stay up for over one minute.
I’m using ffmpeg (v0.8.6)/libx264 to transcode the video to MP4.
ffmpeg -i “presentation.wmv” -acodec libfaac -ab 16k -vcodec libx264 -fpre “\ffmpeg-0.8.6\ffpresets\libx264-baseline.ffpreset” -profile main -s 480x360 -aspect 4:3 “presentation.mp4”
This gives me two issues when trying to play MP4 video.
Video does not sync up very well with audio. The slide may change a second or two earlier/sooner than expected.
The playback of MP4 video in a JWPlayer widget: I cannot advance the slider to fast forward or back, eg., the slider is jumping from 00:00 to 9:00 (nine minutes). I cannot advance to anything in between.
The issue #1 can be resolved with -vsync 0 option. The video and audio then sync up perfectly.
The issue #2 can be resolved -r 6 (setting fps to 6). If I don’t set the frame rate then it ends up being 0.4.
Here comes my third issue: I cannot seem to use both of these options at the same time If I set vsync 0 then frame rate option is ignored and it ends up being 0.4 (which gives me issues with JWPlayer).
Are there any workarounds to both achieve higher fps than default 0.4 and to have audio and video in perfect sync?
I tried uploading the video to YouTube and they got it right. I downloaded the encoded video and then was able play/advance in JWPlayer, audio and video were synced up too.
Help
P.S. I do use qt-faststart to move “moov” atom to the beginning.
|
| |
|
Last edited by i5mast; 1st December 2011 at 21:50. |
---|
<br /> Posts: 4 <br /> <br /> <br /> <br /> <br /> <br /> <br />
![]() |
#2 | Link |
---|---|
smok3 brontosaurusrex ![]() Join Date: Oct 2001 |
is your generated mp4 some sort of variable frame rate? does jwplayer/flash support such files? did you try forcing keyframe distance? http://mewiki.project357.com/wiki/X264_Settings#keyint __ certain other member |
![]() |
![]() |
<br /> Posts: 2,392 <br /> <br /> <br /> <br /> <br /> <br /> <br />
![]() |
#3 | Link |
---|---|
i5mast Registered User Join Date: Nov 2011 |
I didn’t use anything special outside of ffmpeg baseline presets: |
Here are the options:
[libx264 @ 01868520] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=0 keyint=250 keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
<br />Quote:<br /> |
| did you try forcing keyframe distance? | |
| is your generated mp4 some sort of variable frame rate? does jwplayer/flash support such files? | |
| |
|
<br /> Posts: 4 <br /> <br />what would be a reasonable setting for keyframe?
I’m not sure how to answer these questions. Like I said, there are only 151 frames in the whole video. So yes, it should be a variable frame rate in that sense that one frame stays for 1 minute, second frame may stay for 15 seconds.
Btw, MP4 ends up with 0.04 fps if I don’t specify -r 6.
Quote:
![]() |
#4 | Link |
---|---|
b66pak Registered User ![]() Join Date: Aug 2008 |
use “-async 1” instead “-vsync 0” and “-r 23.976”… _ if you ask a question and somebody give you the correct answer don’t forget to leave a “thank you” note… Visit The Land Of Dracula (Romania - EU)! |
![]() |
![]() |
<br />Location: The Land Of Dracula (Romania - EU)<br /> Posts: 934 <br /> <br /> <br /> <br /> <br /> <br /> <br />
![]() |
#5 | Link |
---|---|
i5mast Registered User Join Date: Nov 2011 |
Quote: |
use “-async 1” instead “-vsync 0” and “-r 23.976”… | |
![]() |
![]() |
Last edited by i5mast; 2nd December 2011 at 21:59. |
---|
<br /> Posts: 4 <br /> <br />"-async 1" and "-r 23.976" did not help with my syncing issues. However, what helped in my situation was a little bit of AviSynth
script.avs:
DirectShowSource(“presentation.wmv”, fps=6, ConvertFPS=True)
I think this created more frames and I generated a second WMV file.
ffmpeg -i “script.avs” -sameq “presentation2.wmv”
Then the final conversion gave me the desired result: FPS at 6 and a working seeking in JWPlayer.
ffmpeg -i “presentation2.wmv” -acodec libfaac -ab 16k -vcodec libx264 -fpre “\code\ffmpeg-0.8.6\ffpresets\libx264-baseline.ffpreset” -profile main -s 480x360 -aspect 4:3 “presentation.mp4”
![]() |
#6 | Link |
---|---|
nm Registered User Join Date: Mar 2005 |
Quote: |
Originally Posted by i5mast ![]() “-async 1” and “-r 23.976” did not help with my syncing issues. |
|
Originally Posted by i5mast ![]() ffmpeg -i “script.avs” -sameq “presentation2.wmv” |
|
![]() |
![]() |
<br />Location: Finland<br /> Posts: 2,642 <br /> <br />Have you tried _-vsync 1 -r 23.976_ (or 6 or whatever rate)?
This is not a good idea. You are re-encoding the video with FFmpeg’s wmv2 encoder, which is bad compared to almost anything. Just encode using the AVS script as source in your final stage. That does the same thing.
Would you happen to have a sample clip that you could share with us?
Quote:
![]() |
#7 | Link |
---|---|
Maccara Registered User Join Date: Dec 2001 |
One thing that has worked for me with “problematic” VFR sources (flagged “interestingly” etc etc problems from one customer): |
ffmpeg -fflags +genpts+igndts -i
That effectively tries to sync the video to the audio and drops frames to prevent frames with same pts, flags the stream as 30fps (was proper for this particular source, adjust to yours) and keeps it VFR still (i.e. does not output duplicate frames).
EDIT: using -vsync 1 will duplicate frames instead to reach the requested framerate, which seems to be what you want. Other options stay the same.
That’s with a recent git version (there has been some syntax changes “recently”, just using -r does not work anymore correctly without stream index specifier and -map syntax is completely different too). Also, this method didn’t use to work so well with older ffmpeg anyway, so recent git master version suggested.
Hmm. I’m not sure if the -fflags actually do anything, so might want to omit that (or test it).
|
| |
|
Last edited by Maccara; 4th December 2011 at 16:27. |
---|
<br /> Posts: 145 <br /> <br /> <br /> <br /> <br /> <br /> <br />
![]() |
#8 | Link |
---|---|
i5mast Registered User Join Date: Nov 2011 |
Quote: |
Have you tried -vsync 1 -r 23.976 (or 6 or whatever rate)? | |
Would you happen to have a sample clip that you could share with us? | |
One thing that has worked for me with “problematic” VFR sources (flagged “interestingly” etc etc problems from one customer): |
ffmpeg -fflags +genpts+igndts -i
Last edited by i5mast; 6th December 2011 at 01:33. |
---|
<br /> Posts: 4 <br /> <br />Yes, I've tried that. It didn't fix the issues with sync.
I’ll have it for a limited time here: http://www.accordant.net/press/presentation.wmv
To see any sync issues, you have to watch from minute 5:00 to 6:00.
I couldn’t figure out the map command. It wouldn’t work for me. WMV has audio as a first stream which I think was the issue.
Thank you for all of your suggestions.
Quote:
Quote: