How can I synchronize video and audio

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I synchronize video and audio

zelalem
Hi guys, I wanted to record video coming from network into avi file, and wrote some code. The file is created but it is unsynchronized (by almost 2 second) and it is annoying. I am using avimuxer. I also used buffer for the audio source hoping to reduce the time difference. The following is the source and destination codes (the command line version of my code). Is there anything that I should consider to avoid this problem. Please help me. If you think that I should use other file formats and video muxer, please advice me.

Source:
Audio:
gst-launch-0.10 -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
Video:
gst-launch v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate ! video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay ! udpsink port=5000

Destination:
gst-launch-0.10 -v avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998"  ! queue ! rtph263pdepay ! 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} ! mux.video_0 {udpsrc port=5002 caps="application/x-rtp,media=(string)audio,payload=(int)96, rate=(int)8000, encoding-name=(string)PCMA" num-buffers=5000 ! queue ! rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue} ! mux.audio_0;

Thank you.

- Zelalem S.




What can you do with the new Windows Live? Find out
------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How can I synchronize video and audio

Stefan Sauer
Zelalem Sintayehu schrieb:

> Hi guys, I wanted to record video coming from network into avi file,
> and wrote some code. The file is created but it is unsynchronized (by
> almost 2 second) and it is annoying. I am using avimuxer. I also used
> buffer for the audio source hoping to reduce the time difference. The
> following is the source and destination codes (the command line version
> of my code). Is there anything that I should consider to avoid this
> problem. Please help me. If you think that I should use other file
> formats and video muxer, please advice me.
>
> Source:
> Audio:
> gst-launch-0.10
> -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
> audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
> Video:
> gst-launch
> v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
> video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
> ! udpsink port=5000
>
> Destination:
> gst-launch-0.10 -v
> avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc
> port=5000
> caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998"
> ! queue ! rtph263pdepay !
> 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} !
> mux.video_0 {udpsrc port=5002
> caps="application/x-rtp,media=(string)audio,payload=(int)96,
> rate=(int)8000, encoding-name=(string)PCMA" num-buffers=5000 ! queue !
> rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue}
> ! mux.audio_0;
>
try to narrow it down. Check if you receive the material properly timestamped.
Check if avimux handles timestamping correctly when muxing.

STefan

> Thank you.
>
> - Zelalem S.
>
>
>
> _________________________________________________________________
> Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
>
> http://www.microsoft.com/windows/windowslive/products/photos.aspx
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How can I synchronize video and audio

zelalem
Hi Stefan, thank you for your response. You know when I didn't get help for some time, I had lost my hope and abandon it. 2 second is considerable time. Anyway, I am sorry for my sily question, but I don't understnad what you mean by "narrow it down"? Also how can I "Check if you receive the material properly timestamped"?.

Thank you again for your help.

- Zelalem S.


> Date: Sat, 18 Jul 2009 19:03:10 +0300
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [gst-devel] How can I synchronize video and audio
>
> Zelalem Sintayehu schrieb:
> > Hi guys, I wanted to record video coming from network into avi file,
> > and wrote some code. The file is created but it is unsynchronized (by
> > almost 2 second) and it is annoying. I am using avimuxer. I also used
> > buffer for the audio source hoping to reduce the time difference. The
> > following is the source and destination codes (the command line version
> > of my code). Is there anything that I should consider to avoid this
> > problem. Please help me. If you think that I should use other file
> > formats and video muxer, please advice me.
> >
> > Source:
> > Audio:
> > gst-launch-0.10
> > -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
> > audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
> > Video:
> > gst-launch
> > v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
> > video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
> > ! udpsink port=5000
> >
> > Destination:
> > gst-launch-0.10 -v
> > avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc
> > port=5000
> > caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998"
> > ! queue ! rtph263pdepay !
> > 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} !
> > mux.video_0 {udpsrc port=5002
> > caps="application/x-rtp,media=(string)audio,payload=(int)96,
> > rate=(int)8000, encoding-name=(string)PCMA" num-buffers=5000 ! queue !
> > rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue}
> > ! mux.audio_0;
> >
> try to narrow it down. Check if you receive the material properly timestamped.
> Check if avimux handles timestamping correctly when muxing.
>
> STefan
>
> > Thank you.
> >
> > - Zelalem S.
> >
> >
> >
> > _________________________________________________________________
> > Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
> >
> > http://www.microsoft.com/windows/windowslive/products/photos.aspx
> >
> >
> > ------------------------------------------------------------------------
> >
> > ------------------------------------------------------------------------------
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


What can you do with the new Windows Live? Find out
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How can I synchronize video and audio

Stefan Sauer
Zelalem Sintayehu schrieb:
> Hi Stefan, thank you for your response. You know when I didn't get help for some time, I had lost my hope and abandon it. 2 second is considerable time. Anyway, I am sorry for my sily question, but I don't understnad what you mean by "narrow it down"? Also how can I "Check if you receive the material properly timestamped"?.
>
> Thank you again for your help.

Don't expect that everything is ready. I don't have an explanation for the
problem you see. As nobody else was answering, it seems that you will have to
figure our what the probelm is. With "narrow it down", I was suggsting to try to
make simpler/different variants to see if you can pinpoint the problem. E.g.
recod to a mp4 with mp4mux to see if it might be a problem in avimux.

Also you should not start two pipelines on the src side, instead of
Source:
Audio:
gst-launch-0.10
-v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
Video:
gst-launch
v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
! udpsink port=5000

just do

Source:
gst-launch-0.10
-v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
! udpsink port=5000

Then both livesource use the same clock to timestamp buffers.

Stefan


>
> - Zelalem S.
>
>
>> Date: Sat, 18 Jul 2009 19:03:10 +0300
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: [gst-devel] How can I synchronize video and audio
>>
>> Zelalem Sintayehu schrieb:
>>> Hi guys, I wanted to record video coming from network into avi file,
>>> and wrote some code. The file is created but it is unsynchronized (by
>>> almost 2 second) and it is annoying. I am using avimuxer. I also used
>>> buffer for the audio source hoping to reduce the time difference. The
>>> following is the source and destination codes (the command line version
>>> of my code). Is there anything that I should consider to avoid this
>>> problem. Please help me. If you think that I should use other file
>>> formats and video muxer, please advice me.
>>>
>>> Source:
>>> Audio:
>>> gst-launch-0.10
>>> -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
>>> audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
>>> Video:
>>> gst-launch
>>> v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
>>> video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
>>> ! udpsink port=5000
>>>
>>> Destination:
>>> gst-launch-0.10 -v
>>> avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc
>>> port=5000
>>> caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998"
>>> ! queue ! rtph263pdepay !
>>> 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} !
>>> mux.video_0 {udpsrc port=5002
>>> caps="application/x-rtp,media=(string)audio,payload=(int)96,
>>> rate=(int)8000, encoding-name=(string)PCMA" num-buffers=5000 ! queue !
>>> rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue}
>>> ! mux.audio_0;
>>>
>> try to narrow it down. Check if you receive the material properly timestamped.
>> Check if avimux handles timestamping correctly when muxing.
>>
>> STefan
>>
>>> Thank you.
>>>
>>> - Zelalem S.
>>>
>>>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How can I synchronize video and audio

zelalem
Hi Stefan, thank you for your e-mail. I understand what you mean now. I will try to do both and will tell you the result.

Thank you again for the support.

- Zelalem S.


> Date: Sat, 18 Jul 2009 22:51:03 +0300
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [gst-devel] How can I synchronize video and audio
>
> Zelalem Sintayehu schrieb:
> > Hi Stefan, thank you for your response. You know when I didn't get help for some time, I had lost my hope and abandon it. 2 second is considerable time. Anyway, I am sorry for my sily question, but I don't understnad what you mean by "narrow it down"? Also how can I "Check if you receive the material properly timestamped"?.
> >
> > Thank you again for your help.
>
> Don't expect that everything is ready. I don't have an explanation for the
> problem you see. As nobody else was answering, it seems that you will have to
> figure our what the probelm is. With "narrow it down", I was suggsting to try to
> make simpler/different variants to see if you can pinpoint the problem. E.g.
> recod to a mp4 with mp4mux to see if it might be a problem in avimux.
>
> Also you should not start two pipelines on the src side, instead of
> Source:
> Audio:
> gst-launch-0.10
> -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
> audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
> Video:
> gst-launch
> v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
> video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
> ! udpsink port=5000
>
> just do
>
> Source:
> gst-launch-0.10
> -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
> audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
> v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
> video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
> ! udpsink port=5000
>
> Then both livesource use the same clock to timestamp buffers.
>
> Stefan
>
>
> >
> > - Zelalem S.
> >
> >
> >> Date: Sat, 18 Jul 2009 19:03:10 +0300
> >> From: [hidden email]
> >> To: [hidden email]
> >> Subject: Re: [gst-devel] How can I synchronize video and audio
> >>
> >> Zelalem Sintayehu schrieb:
> >>> Hi guys, I wanted to record video coming from network into avi file,
> >>> and wrote some code. The file is created but it is unsynchronized (by
> >>> almost 2 second) and it is annoying. I am using avimuxer. I also used
> >>> buffer for the audio source hoping to reduce the time difference. The
> >>> following is the source and destination codes (the command line version
> >>> of my code). Is there anything that I should consider to avoid this
> >>> problem. Please help me. If you think that I should use other file
> >>> formats and video muxer, please advice me.
> >>>
> >>> Source:
> >>> Audio:
> >>> gst-launch-0.10
> >>> -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 !
> >>> audioconvert ! alawenc ! rtppcmapay ! udpsink port=5002
> >>> Video:
> >>> gst-launch
> >>> v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate !
> >>> video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay
> >>> ! udpsink port=5000
> >>>
> >>> Destination:
> >>> gst-launch-0.10 -v
> >>> avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc
> >>> port=5000
> >>> caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998"
> >>> ! queue ! rtph263pdepay !
> >>> 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} !
> >>> mux.video_0 {udpsrc port=5002
> >>> caps="application/x-rtp,media=(string)audio,payload=(int)96,
> >>> rate=(int)8000, encoding-name=(string)PCMA" num-buffers=5000 ! queue !
> >>> rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue}
> >>> ! mux.audio_0;
> >>>
> >> try to narrow it down. Check if you receive the material properly timestamped.
> >> Check if avimux handles timestamping correctly when muxing.
> >>
> >> STefan
> >>
> >>> Thank you.
> >>>
> >>> - Zelalem S.
> >>>
> >>>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


With Windows Live, you can organize, edit, and share your photos.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel