Audio/video sync issues when working with MP4 from a mobile phone/cellphone

Asked by ADFH

I have a Nokia N95 and it can record Square NTSC (640x480) at ~30fps (it's a phone, so occasionally there's some shearing)..

... aaaanyway, when I try to work on a vid from my phone in Openshot (reduce it in size for upload or to edit out parts etc.), it seems frequently that sync is lost between video and audio, with the video ending before the audio has (the video seems to run faster than the audio when watching onscreen events and listening for corresponding audio).

Any ideas on how to correct this? I had this problem with my previous phone (Nokia N70) and video packages so I'm thinking, perhaps it's a problem with the framerate that the phone says it's using and is actually using. That said, when I play back vision in a standalone player (totem, xine, vlc etc.) sync is not an issue so perhaps there's something else afoot. I don't think it's a bug in openshot per se, hence me asking a question.. Is there a way to tweak A/V sync on imported clips? Perhaps to auto-assume that a file's audio and video run for the same duration and should be synced accordingly?

"file" reports a file as:
ISO Media, MPEG v4 system, version 2

"ffmpeg -i" reports a file as:
  Duration: 00:01:01.35, start: 0.000000, bitrate: 1537 kb/s
    Stream #0.0(und): Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 30k tbr, 30k tbn, 30k tbc
    Stream #0.1(und): Audio: aac, 48000 Hz, mono, s16

Question information

Language:
English Edit question
Status:
Solved
For:
OpenShot Video Editor Edit question
Assignee:
No assignee Edit question
Solved by:
ADFH
Solved:
Last query:
Last reply:
Revision history for this message
Jonathan Thomas (jonoomph) said :
#1

Please check out the following FAQ. It has instructions to test the clip using ffplay and melt, which might help reveal the source of the problem: https://answers.launchpad.net/openshot/+faq/983

However, it's likely that the only work-around will be to re-encode the videos as another format, and then try to edit the re-encoded files in OpenShot. Here is an example command to re-encode a folder full of videos:

$ find '/home/USER/MyMovie/Videos' -iname "*.MP4" -exec ffmpeg -i {} -acodec ac3 -ab 128k -ac 2 -r 60 -vcodec mpeg4 -f mp4 -y -sameq {}_new.mp4 \;

Good luck!

Revision history for this message
ADFH (adfh) said :
#2

I'll have a look at that link.

Is the re-encoding a lossless process though? It'd be like opening, editing and resaving a JPEG, no?

Revision history for this message
Jonathan Thomas (jonoomph) said :
#3

Yes, any time you move from one codec to another, the frames are decoded and re-encoded using the new codec. There is almost always compression that is also being applied. So, saving a JPEG is a good analogy.

Revision history for this message
ADFH (adfh) said :
#4

So I used ffplay and I got "error while seeking" whilst jumping back and forward but it still seemed to get synch back.

I tried another clip which was longer than a minute and then used the minute back/forward skip in melt and well and truly lost sync.

There isn't a tool, perhaps, that might demux and remux with the correct sync parameters without needing to re-encode?

Either way, I have searched about the Nokia N95 since you raised the transcoding suggestion and found that apparently it records a variable framerate and that it's notorious for getting out of sync (wheeee).. Fun fun..

Thankyou for your suggestion.