Hi,

I’m seeing inconsistent behavior in FFmpeg when feeding frames over image2pipe 
from a sender that transmits raw JPEG bytes at variable FPS (frames are only 
sent when changes occur, so the input rate is not constant).

I’ve tried two different approaches on the receiver side:

---------------------------------------------------------------

Approach 1 (works)

On the receiver, I maintain a buffer and duplicate the last frame to enforce a 
constant FPS before passing frames to FFmpeg.

Command line:

> -f image2pipe -framerate {targetFPS} -i - \
> -vf fps={targetFPS} -vsync cfr \
> -c:v libx264 -pix_fmt yuv420p -crf 32 -preset ultrafast -tune zerolatency \
> -g {targetFPS*2} -b:v 2M -maxrate 2M -bufsize 4M \
> -movflags frag_keyframe+empty_moov+default_base_moof \
> -f mp4 -flush_packets 1 pipe:1

This works fine:

-

The receiver outputs data immediately over HTTP and writes to disk.

-

Files written on exit are valid.

---------------------------------------------------------------

Approach 2 (fails)

Here I pass frames directly as they arrive (variable FPS, no duplication logic).

Command line:

> -f image2pipe -vcodec mjpeg -framerate {TARGET_FPS} -i - \
> -vcodec libx264 -pix_fmt yuv420p \
> -preset ultrafast -crf 23 \
> -r {TARGET_FPS} \-y {outputFile}

In this case:

-

On process exit, the file is created but is 0 KB in size.

> -f image2pipe -vcodec mjpeg -framerate {TARGET_FPS} -i - \
> -vcodec libx264 -pix_fmt yuv420p \
> -preset ultrafast -tune zerolatency -crf 23 \
> -r {TARGET_FPS} \
> -g {TARGET_FPS*2} -sc_threshold 0 \
> -movflags frag_keyframe+empty_moov+default_base_moof \
> -f mp4 pipe:1

- Using above config to stream over HTTP, my C# code creates a new FFmpeg 
process, passes the frames and sends the final output over HTTP to receiver.

---------------------------------------------------------------

Question

Why does the second approach fail to produce any output when the input arrives 
at variable FPS? Is there a recommended way to handle sparse/irregular frame 
arrival over image2pipe without manually duplicating frames in my application?

> AIM: Sender sends raw JPEG bytes to my receiver, my receiver must just do the 
> work of passing them to ffmpeg, ffmpeg must do all the processing, keeping 
> the video output natural at constant FPS and then stream the final video 
> bytes that ffmpeg produces over a network (e.g., using HTTP POST). What are 
> the correct command line options for this?

Thanks,
Palaash Jain
_______________________________________________
ffmpeg-user mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to