0

I am trying to encode live rtmp stream via Libav library encoder by using avconv tool in following command -

avconv -timelimit 4000 -i  rtmp://IP/live/file-name -shortest -s 176*144 -r 10 \
-b:v 56k -ab 12k -ac 1 -ar 22050 -f flv  rtmp://IP/live/file-name_56

But audio is not synchronized with video in output stream, and video lags behind as its bit rate has been changed to 56 kbps. But audio bit rate doesn't change & current audio is audible.

I am playing it via Run Time Environment in Java and 1 hour video stops after 10 mins. This issue is there when I am running a thread in java to run avconv command as follows

public void run() {
    try{
         Thread.sleep(500);
 Process pr=  Runtime.getRuntime().exec("avconv -timelimit 4000  -i  rtmp://IP/live/file-name  -shortest -s 176*144  -r 10 -b:v 56k -ab 12k -ac 1 -ar 22050 -f flv  rtmp://IP/live/file-name_56");
pr.waitFor();
}}

Kindly provide suggestion on this.

Yuvraj Kakkar
  • 1,123
  • 1
  • 11
  • 24

1 Answers1

0

Audio synchronization is achieved by

-async samples_per_second

Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps, the parameter is the maximum samples per second by which the audio is changed. -async 1 is a special case where only the start of the audio stream is corrected without any later correction.

Process pr=  Runtime.getRuntime().exec("avconv -async 15 -timelimit 4000  -i  rtmp://IP/live/file-name  -shortest -s 176*144  -r 10 -b:v 56k -ab 12k -ac 1 -ar 22050 -f flv  rtmp://IP/live/file-name_56");
Yuvraj Kakkar
  • 1,123
  • 1
  • 11
  • 24