[FFmpeg-devel] stream_copy

Pavel Baykov baykovpa
Tue Nov 16 13:48:48 CET 2010


Hi,

I'm trying to copy input video or audio stream into output stream without
transcoding at all. Below is a piece of code:

           AVPacket opacket;

           av_new_packet(&opacket, ipacket.size);

           //copy ipacket to opacket
           opacket.pts = ipacket.pts;
           opacket.dts = ipacket.dts;
           memcpy(opacket.data, ipacket.data, ipacket.size);
           opacket.size = ipacket.size;
           opacket.stream_index = avr.output_video_stream->index;

           opacket.flags = ipacket.flags;
           opacket.duration = ipacket.duration;

           if (av_write_frame(avr.oc, &opacket) != 0) {
             log() << "Error while writing video frame\n" << endl;
             exit(1);
           }

           av_free_packet(&opacket);

For test purposes i'm using RTMP stream that contains H.264 video. But
output stream doesn't contains any video, but rtmpdump can detect the video
Below is rtmpdump log

DEBUG: RTMP_ClientPacket, received: notify 69 bytes
DEBUG: (object begin)
DEBUG: (object begin)
DEBUG: Property: <Name:           duration, NUMBER: 0.00>
DEBUG: Property: <Name:             height, NUMBER: 240.00>
DEBUG: Property: <Name:              width, NUMBER: 320.00>
DEBUG: (object end)
DEBUG: (object end)
INFO: Metadata:
INFO:   duration              0.00
INFO:   height                240.00
INFO:   width                 320.00
DEBUG: ignoring too small video packet: size: 2
DEBUG: ignoring too small video packet: size: 5
DEBUG: ignoring too small video packet: size: 2
DEBUG: ignoring too small video packet: size: 5
DEBUG: ignoring too small video packet: size: 5

I had also found that AVStream structure have stream_copy field, i set it
but without luck.

Hope for help.

Thanks in advance, Pavel



More information about the ffmpeg-devel mailing list