On 09/04/2016 09:01 PM, M N wrote:
That was my question, how can I read a frame from a specific stream? And what
does av_read_frame really reads?
I don't think you can, you will need to read all frames and keep the packets
that match your stream.
See https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/transcoding.c
avformat_find_stream_info around line 60
You can fprobe the file for stream info too
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, bt709), 1280x720 [SAR 1:1
DAR 16:9], 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
That is the stream number
Find the one you want and only pass data that is part of that stream, that is
the demuxing.
See https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/transcoding.c
Line 498 could be
if ( packet.stream_index == mystreamid ) then avcodec_send_packet
Compile transcoding.c and make small changes to it until it does what you want.
Thanks
cco
05.09.2016, 04:01, "Christopher Snowhill" <[email protected]>:
On 9/4/16 5:27 PM, Charles wrote:
On 09/04/2016 10:52 AM, M N wrote:
Gonzalo then how should I continue to read packets from input format
context and write them to output format context?
04.09.2016, 05:14, "Charles" <[email protected]>:
On 09/03/2016 08:34 PM, Gonzalo Garramuño wrote:
El 03/09/2016 a las 17:55, M J escribió:
Hi
MJ,
I probably wasn't clear, each call is dependent on the return value of
the previous call.
i.e. if you did not get return 0 or EAGIN from send_packet you should
probably not call receive_frame
while(av_read_frame(input_ctx, pkts) == 0)
{
//decoding
int ret1 = avcodec_send_packet(input_codecCtx, pkts);
int ret2 = avcodec_receive_frame(input_codecCtx, rawFrame);
Why don't you just print the return values. SEE av_strerror
https://ffmpeg.org/doxygen/3.1/group__lavu__error.html#ga5792b4a2d18d7d9cb0efbcfc335dce24
//encoding
avcodec_send_frame(output_codecCtx, rawFrame);
avcodec_receive_packet(output_codecCtx, pktr);
These have return values also.
int ret = av_interleaved_write_frame(output_ctx, pktr);
}
*************************************************
Hi, MJ.
Assuming everything is setup correctly, and 1 frame -> 1 packet && 1
packet -> 1 frame
while ( av_read_frame == 0 )
if avcodec_send_packet == 0
if avcodec_receive_frame == 0
if avcodec_send_frame == 0
if avcodec_receive_packet == 0
av_interleaved_write_frame
But, each of those IF's have multiple return values
What are you going to do if the return is AVERROR(EAGAIN) or AVERROR_EOF
What about the frame delay on the encoder?
Thanks
cco
Don't forget, maybe he's parsing an interleaved stream, and isn't paying
attention to which stream each packet belongs to.
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user