Josh Millstein
2007-01-12 18:10:45 UTC
Hello. Here is what I'm doing. I'm concatenating mp4, mov, avi files. I'm
doing this by first converting each video to mpg and then cat'in them and
running them through ffmpeg again. I finally got a way to get this to work,
kinda. The video is concatenated, the audio is concatenated, and they both
play in the mpg that is outputted, but they are out of sync. I think the
syncing problem is due to the fact that I have to convert from whatever the
original format is to mpg, which means I have to change the frame rate.
mpeg1video only uses 30 and 24 or something like that. So I have input
sources at 15 fps that get converted to 30 or 24 fps that get converted to
30. The end result, I think, is that frames are being doubled to get the
fps, which makes video play slower than the audio. It also gets worse and
worse (sync) as the concatenated video progresses. Can anybody help me
here? I read something about using -vsync with -map so I can sync the video
to the audio by dropping or adding frames. Here are all the commands I use
in this process. Thanks for the input. They are labeled $one ... $n in the
order that I call the commands from php exec(). A couple things I've tried
lately... On $one and $two I have toggeled the use of -r 30 for the input
file. On $twelve I have tried to convert back to -r 15 in hopes it would
re-sync.
$one = "ffmpeg -y -r 30 -i ./files/11684546964708514650724.82824test2.mov -s
400x300 -vcodec mpeg1video -acodec mp2 -r 30 ./downloads/OvSOne.mpg";
$two = "ffmpeg -y -r 30 -i
./files/1168466060313378706743.940711play_mayer_life.mp4 -s 400x300 -vcodec
mpeg1video -acodec mp2 -r 30 ./downloads/OvSTwo.mpg";
$three = "ffmpeg -y -i ./downloads/OvSOne.mpg -vcodec mpeg1video -an -f
mpeg1video ./downloads/vSOne.mpg";
$four = "ffmpeg -y -i ./downloads/OvSTwo.mpg -vcodec mpeg1video -an -f
mpeg1video ./downloads/vSTwo.mpg";
$five = "ffmpeg -y -i ./downloads/OvSTwo.mpg -acodec mp2 -vn -f mp2
./downloads/vSTwo.mp2";
$six = "ffmpeg -y -i ./downloads/OvSOne.mpg -acodec mp2 -vn -f mp2
./downloads/vSOne.mp2";
$seven = "cat ./downloads/vSOne.mpg ./downloads/vSTwo.mpg >
./downloads/com.mpg";
$eight = "cat ./downloads/vSOne.mp2 ./downloads/vSTwo.mp2 >
./downloads/com.mp2";
$nine = "ffmpeg -y -i ./downloads/com.mpg -an -vcodec mpeg1video -f
mpeg1video ./downloads/outOne.mpg";
$ten = "ffmpeg -y -i ./downloads/com.mp2 -acodec mp2 -vn
./downloads/outOne.mp2";
$eleven = "ffmpeg -y -i ./downloads/outOne.mp3 -i ./downloads/outOne.mpg -f
vob ./downloads/out.mpg";
$twelve = "ffmpeg -y -i ./downloads/out.mpg -acodec mp3 -r 15 -f mov
./downloads/out.mov";
doing this by first converting each video to mpg and then cat'in them and
running them through ffmpeg again. I finally got a way to get this to work,
kinda. The video is concatenated, the audio is concatenated, and they both
play in the mpg that is outputted, but they are out of sync. I think the
syncing problem is due to the fact that I have to convert from whatever the
original format is to mpg, which means I have to change the frame rate.
mpeg1video only uses 30 and 24 or something like that. So I have input
sources at 15 fps that get converted to 30 or 24 fps that get converted to
30. The end result, I think, is that frames are being doubled to get the
fps, which makes video play slower than the audio. It also gets worse and
worse (sync) as the concatenated video progresses. Can anybody help me
here? I read something about using -vsync with -map so I can sync the video
to the audio by dropping or adding frames. Here are all the commands I use
in this process. Thanks for the input. They are labeled $one ... $n in the
order that I call the commands from php exec(). A couple things I've tried
lately... On $one and $two I have toggeled the use of -r 30 for the input
file. On $twelve I have tried to convert back to -r 15 in hopes it would
re-sync.
$one = "ffmpeg -y -r 30 -i ./files/11684546964708514650724.82824test2.mov -s
400x300 -vcodec mpeg1video -acodec mp2 -r 30 ./downloads/OvSOne.mpg";
$two = "ffmpeg -y -r 30 -i
./files/1168466060313378706743.940711play_mayer_life.mp4 -s 400x300 -vcodec
mpeg1video -acodec mp2 -r 30 ./downloads/OvSTwo.mpg";
$three = "ffmpeg -y -i ./downloads/OvSOne.mpg -vcodec mpeg1video -an -f
mpeg1video ./downloads/vSOne.mpg";
$four = "ffmpeg -y -i ./downloads/OvSTwo.mpg -vcodec mpeg1video -an -f
mpeg1video ./downloads/vSTwo.mpg";
$five = "ffmpeg -y -i ./downloads/OvSTwo.mpg -acodec mp2 -vn -f mp2
./downloads/vSTwo.mp2";
$six = "ffmpeg -y -i ./downloads/OvSOne.mpg -acodec mp2 -vn -f mp2
./downloads/vSOne.mp2";
$seven = "cat ./downloads/vSOne.mpg ./downloads/vSTwo.mpg >
./downloads/com.mpg";
$eight = "cat ./downloads/vSOne.mp2 ./downloads/vSTwo.mp2 >
./downloads/com.mp2";
$nine = "ffmpeg -y -i ./downloads/com.mpg -an -vcodec mpeg1video -f
mpeg1video ./downloads/outOne.mpg";
$ten = "ffmpeg -y -i ./downloads/com.mp2 -acodec mp2 -vn
./downloads/outOne.mp2";
$eleven = "ffmpeg -y -i ./downloads/outOne.mp3 -i ./downloads/outOne.mpg -f
vob ./downloads/out.mpg";
$twelve = "ffmpeg -y -i ./downloads/out.mpg -acodec mp3 -r 15 -f mov
./downloads/out.mov";