[Libav-user] av_packet_rescale_ts vs av_rescale_q

cesar pachon cesarpachon at gmail.com
Thu Apr 23 20:27:02 CEST 2015


hello, I am trying to create a chrome extension to capture desktop video
stream and produce a video file. I based my work on the muxer.c example and
it works except for the fact that av_packet_rescale_ts is not defined (I
commented that line and I am able to get a video where only the first frame
is visible and the video duration is zero)

as I am using PNACL port of ffmepg (2.1.3), I am forced to use libavcodec
55.39.101, and in that version av_packet_rescale_ts is not defined.

in other tutorials I had found that av_rescale_q is used. I highly
appreciate any suggestions about how to replace the call to
av_packet_rescale_ts with av_rescale_q or similar.

this is the current code for my add_frame method:

int test_addframe(const uint8_t * data, uint32_t size, int w, int h){

   int ret;
    AVCodecContext *c;
    AVFrame *frame;
    int got_packet = 0;

    c = video_st.st->codec;
    frame = test_get_video_frame(&video_st, data, size, w, h);

        AVPacket pkt = { 0 };
        av_init_packet(&pkt);

        ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
        if (ret < 0) {
            fprintf(stderr, "Error encoding video frame: %s\n",
av_err2str(ret));
            exit(1);
        }

        if (got_packet) {
            //old version ret = write_frame(oc, &c->time_base, video_st.st,
&pkt);
        //new version: this is the code of write_frame:
        // rescale output packet timestamp values from codec to stream
timebase

        //THIS METHOD DOES NOT EXIST IN PNACL VERSION OF FFMPEG 2.1.3
      //av_packet_rescale_ts(&pkt, &c->time_base, video_st.st->time_base);

        pkt.stream_index = video_st.st->index;

        // Write the compressed frame to the media file.
        log_packet(oc, &pkt);
        ret = av_interleaved_write_frame(oc, &pkt);

        } else {
            ret = 0;
        }


    if (ret < 0) {
        fprintf(stderr, "Error while writing video frame: %s\n",
av_err2str(ret));
        exit(1);
    }
    return (frame || got_packet) ? 0 : 1;
};



Cesar  Pachón
-------------------------------------------------------------
www.cesarpachon.com, just a digital hermit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150423/58d29e51/attachment.html>


More information about the Libav-user mailing list