[Libav-user] Output video data to file and pipe: concurrently
Hillel Rosensweig
hillelro at yahoo.com
Fri Apr 1 06:39:42 EEST 2022
On Thursday, March 31, 2022, 10:39:47 PM GMT+3, Yurii Monakov <monakov.y at gmail.com> wrote:
Hi
Sorry for some kind of offtopic on this list, but you should try to create simple gstreamer pipeline. From my opinion, gstreamer has all pipeline elements which you need (tee, decode, encode, whatever) and will be much more simpler to get working than bare ffmpeg libraries. You can test your pipeline with gst-launch utility.
Yurii
чт, 31 марта 2022 г. в 10:30, Hillel Rosensweig via Libav-user <libav-user at ffmpeg.org>:
Hello all,
I have been trying to output video (from my webcam) simultaneously to both a file ('out.mkv') and pipe: The file gets filtered frames packets, and the pipe: gets ufiltered rawvideo.My frame rate is 30 fps. However, I am getting a far lower framerate in my file output.
Attached is the while loop which reads packets and writes them to output:
while (1) { av_read_frame(ifmt_ctx, packet); stream_index = packet->stream_index; StreamContext *stream = &file_stream_ctx[stream_index]; av_packet_rescale_ts(packet, ifmt_ctx->streams[stream_index]->time_base, stream->dec_ctx->time_base); avcodec_send_packet(stream->dec_ctx, packet); while (ret >= 0) { avcodec_receive_frame(stream->dec_ctx, stream->dec_frame); stream->dec_frame->pts = stream->dec_frame->best_effort_timestamp; ret = filter_encode_write_frame(stream->dec_frame, stream_index, file_stream_ctx, file_filter_ctx, file_ofmt_ctx); ret = av_interleaved_write_frame(pipe_ofmt_ctx, packet); }}
'ifmt_ctx' is the AVFormatContext for the webcam.'file_ofmt_ctx', is the AVFormatContext for the pipe for the output file, and pipe_ofmt_ctx is the AVFormatContext.'file_stream_ctx' and 'file_filter_ctx' are the stream and filter contexts used for filtering and encoding the file output.
My guess is that writing to the pipe is taking too long and not allowing the next packet to be read on time - causing a lower frame rate. Does that make sense? If so - any suggestions on how to fix it? (I tried using AVFMT_FLAG_NONBLOCK but it doesn't seem to help).
Thanks
Hillel_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user
To unsubscribe, visit link above, or email
libav-user-request at ffmpeg.org with subject "unsubscribe".
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user
To unsubscribe, visit link above, or email
libav-user-request at ffmpeg.org with subject "unsubscribe".
That may be, but for the time being I need to work with ffmpeg libraries directly. Any help with my current diretion would be appreciated.
Hillel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220401/56381f91/attachment.htm>
More information about the Libav-user
mailing list