[Libav-user] Setting libx264 bitrate via API
Rakesh Shivayya Guttedar -ERS, HCL Tech
rakesh-sg at hcl.com
Tue Aug 7 12:02:31 CEST 2012
Hi,
Your finding has fixed the issue in my case also.
Thanks for posting. It would certainly help others who are facing similar issue.
Regards,
Rakesh
-----Original Message-----
From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org] On Behalf Of jettoblack
Sent: Sunday, August 05, 2012 10:10 AM
To: libav-user at ffmpeg.org
Subject: Re: [Libav-user] Setting libx264 bitrate via API
After digging through ffmpeg.c, I finally figured it out.
My code was sending pictures into the encoder using a pts in the stream's
time_base of 1/90000 (e.g. 3003, 6006, 9009). The solution was to first
rescale the AVFrame's pts from the stream's time_base to the codec time_base
to get a simple frame number (e.g. 1, 2, 3).
pic->pts = av_rescale_q(pic->pts, ost->time_base, enc->time_base);
avcodec_encode_video2(enc, &newpkt, pic, &got_packet_ptr);
Then when a packet is received from the encoder, you need to rescale pts and
dts back to the stream time_base.
newpkt.pts = av_rescale_q(newpkt.pts, enc->time_base, ost->time_base);
newpkt.dts = av_rescale_q(newpkt.dts, enc->time_base, ost->time_base);
av_interleaved_write_frame(out, &newpkt);
I guess not every codec requires this to be done, but libx264 does if you
want to encode CBR/ABR.
--
View this message in context: http://libav-users.943685.n4.nabble.com/Setting-libx264-bitrate-via-API-tp4655453p4655531.html
Sent from the libav-users mailing list archive at Nabble.com.
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.
----------------------------------------------------------------------------------------------------------------------------------------------------
More information about the Libav-user
mailing list