0

I create TPorocess for ffmpeg to stream a video from /dev/video0 in Linux Ububntu 14.04. After 5 minutes of work the stream send stops and on the receiveng side (ffplay) the picture freezes.

The strange thing - If I try to read stdout of ffmpeg with cat /procs/3535 (where 3535 is ffmpeg PID) it continues to work and the client sees the live picture again! After next 5 minutes of work this situation repeats. And thr call to read stdout helps again.

When I stream an audio stream the same way it doesn't happen. When I start ffmpeg video streaming from terminal it works without the problem!

OS Linux Ubuntu 14.04 32-bit. FFmpeg v3.4 built with GCC 4.8

FFmpeg start string: ffmpeg -vsync drop -frame_drop_threshold 1 -f v4l2 -video_size 640x480 -i /dev/video0 -vcodec libx264 -pix_fmt yuv420p -tune zerolatency -preset ultrafast -b 500k -fflags +genpts -f rtp rtp://10.0.6.70:2666

Free Pascal code:

  FVideoTranslation := TProcessUTF8.Create(nil);
  FVideoTranslation.Options := [poUsePipes]; 
  with FVideoTranslation do
  begin
    Executable := Format(PATH_PATTERN, [FProgramPath, TRANSLATION_PROGRAM]);
    Parameters.Add('-vsync');
    Parameters.Add('drop');
    Parameters.Add('-frame_drop_threshold');
    Parameters.Add('1');
    DeviceParams := GetCaptureParam(AVideoDevice, dtVideo);
    for i := 0 to DeviceParams.Count - 1 do
      Parameters.Add(DeviceParams[i]);
    FreeAndNil(DeviceParams);
    Parameters.Add('-vcodec');
    Parameters.Add('libx264');
    Parameters.Add('-pix_fmt');
    Parameters.Add('yuv420p');
    Parameters.Add('-tune');
    Parameters.Add('zerolatency');
    Parameters.Add('-preset');
    Parameters.Add('ultrafast');
    Parameters.Add('-b');
    Parameters.Add('500k');
    Parameters.Add('-fflags');
    Parameters.Add('+genpts');
    Parameters.Add('-f');
    Parameters.Add('rtp');
    Parameters.Add('rtp://%s:%d', [AAbonentIp, AVideoPort]);     
    Execute();
    Log.AddMessage(Parameters.Text);
  end;      
  SdpInfo.Clear;
  while (SdpInfo.Count = 0) do
  try
    SdpInfo.LoadFromStream(FVideoTranslation.Output);
  except
    on E: Exception do
      Log.AddMessage('VideoTranslation.Output: ' + E.Message);
  end;
  Log.AddMessage(SdpInfo.Text);
  FVideoFile := SdpInfo.Text;

Any suggestions why it can be?

Dr.eel
  • 1,837
  • 3
  • 18
  • 28

0 Answers0