Re: [Libav-user] time_scale issue with 3.1 ABI
Is this a bug? ffmpeg -loglevel debug -f x11grab -r 60 -video_size 1024x768 -i :0.3 -vcodec h264_nvenc -pix_fmt yuv420p -preset lossless -profile:v high -rc vbr_minqp -gpu 1 test2.mp4ffmpeg version N-81328-gceab04f Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17) configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --extra-cflags=-I../Video_Codec_SDK_7.0.1/Samples/common/inc --pkg-config-flags=--static --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-decoder=aac --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libopenjpeg --enable-libpulse --enable-libtheora --enable-libvorbis --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect --enable-opengl --enable-nvenc --enable-vdpau libavutil 55. 28.100 / 55. 28.100 libavcodec 57. 51.102 / 57. 51.102 libavformat57. 46.101 / 57. 46.101 libavdevice57. 0.102 / 57. 0.102 libavfilter 6. 51.100 / 6. 51.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 [...] cur_dts is invalid (this is harmless if it occurs once at the start per stream) [...] Spam on cur_dts is invalid Output: Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 522 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default) Thanks cco On 08/24/2016 05:08 PM, Charles wrote: Not sure where the problem is but the same code with different containers Can't seem to make the container honor the encoders frame_rate How do you get the time_scale correct in a video only stream? in transcoding.c it just copies the input pts in muxing.c its set fron next_pts for number of audio samples in remuxing.c it is set from av_rescale_q_rnd with in stream to out stream Thanks cco Details: mp4 header Stream #0:0: Video: h264 (h264_nvenc), yuv420p, 1024x768, q=-1--1, 3000 kb/s, 60 tbr, 60 tbn mp4 600 frames (ffprobe) Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 3027 kb/s, 60.10 fps, 60 tbr, 15360 tbn, 120 tbc (default) mkv header Stream #0:0: Video: h264 (h264_nvenc), yuv420p, 1024x768, q=-1--1, 3000 kb/s, 60 tbr, 60 tbn mkv 600 frame (ffprobe) Stream #0:0: Video: h264 (High), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 1k fps, 60 tbr, 1k tbn, 120 tbc (default) From the dumps I can tell that tbn is messed up and from libavformat/dump.c I see it is related to frame_rate I can play both output in VLC does it has issues... I create the codec and and context then video_st = avformat_new_stream( av_out_fmt_ctx, av_encode_codec ); video_st->time_base = AVRational{ 1, fps }; av_stream_set_r_frame_rate( video_st, AVRational{ fps, 1 } ); avcodec_parameters_from_context avcodec_open2 flags |= CODEC_FLAG_GLOBAL_HEADER av_dump_format( av_out_fmt_ctx, 0, fname.c_str(), 1 ); avformat_write_header dst_frame->pts = frame_count; avcodec_send_frame avcodec_receive_packet This is what I have tried av_packet_rescale_ts( _av_packet, m_av_codec_ctx->time_base, m_av_out_fmt_ctx->streams[ 0 ]->time_base ); /// m_av_packet.pts = m_av_packet.dts = AV_NOPTS_VALUE; /// m_av_packet.pts++; /// m_av_packet.pts = packet_count++; /// m_av_packet.dts = m_av_packet.pts - 1; ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user
[Libav-user] time_scale issue with 3.1 ABI
Not sure where the problem is but the same code with different containers Can't seem to make the container honor the encoders frame_rate How do you get the time_scale correct in a video only stream? in transcoding.c it just copies the input pts in muxing.c its set fron next_pts for number of audio samples in remuxing.c it is set from av_rescale_q_rnd with in stream to out stream Thanks cco Details: mp4 header Stream #0:0: Video: h264 (h264_nvenc), yuv420p, 1024x768, q=-1--1, 3000 kb/s, 60 tbr, 60 tbn mp4 600 frames (ffprobe) Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 3027 kb/s, 60.10 fps, 60 tbr, 15360 tbn, 120 tbc (default) mkv header Stream #0:0: Video: h264 (h264_nvenc), yuv420p, 1024x768, q=-1--1, 3000 kb/s, 60 tbr, 60 tbn mkv 600 frame (ffprobe) Stream #0:0: Video: h264 (High), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 1k fps, 60 tbr, 1k tbn, 120 tbc (default) From the dumps I can tell that tbn is messed up and from libavformat/dump.c I see it is related to frame_rate I can play both output in VLC does it has issues... I create the codec and and context then video_st = avformat_new_stream( av_out_fmt_ctx, av_encode_codec ); video_st->time_base = AVRational{ 1, fps }; av_stream_set_r_frame_rate( video_st, AVRational{ fps, 1 } ); avcodec_parameters_from_context avcodec_open2 flags |= CODEC_FLAG_GLOBAL_HEADER av_dump_format( av_out_fmt_ctx, 0, fname.c_str(), 1 ); avformat_write_header dst_frame->pts = frame_count; avcodec_send_frame avcodec_receive_packet This is what I have tried av_packet_rescale_ts( _av_packet, m_av_codec_ctx->time_base, m_av_out_fmt_ctx->streams[ 0 ]->time_base ); /// m_av_packet.pts = m_av_packet.dts = AV_NOPTS_VALUE; /// m_av_packet.pts++; /// m_av_packet.pts = packet_count++; /// m_av_packet.dts = m_av_packet.pts - 1; ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user
[Libav-user] Dumping RTSP(H264) stream to container
Hello, As the title say I'm trying to remux(I dont know if this is the correct term) a rtsp h264 stream into a container(mp4). I've been fiddling with the remuxing example given in the documentation for ffmpeg 3.1 ( https://www.ffmpeg.org/doxygen/3.1/remuxing_8c-example.html) with no avail. I know I can read the frames because I wrote them to disk (decode -> encoded, not in h264 might i say so.). So I'm having troubles with the writing them raw part (writing the frames without an decode/encode pipeline). I'm also a bit lost with the dts and pts in this part, how would this work for an encoded stream?. These are the errors I'm getting when remuxing from two files [mp4 @ 0x1d869e0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead. [mp4 @ 0x1d869e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. [mp4 @ 0x1d869e0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead. [mp4 @ 0x1d869e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. [mp4 @ 0x1d869e0] track 1: codec frame size is not set [mp4 @ 0x1d869e0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly And when remuxing from the rtsp stream [avi @ 0x18d1fe0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead. [avi @ 0x18d1fe0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. [avi @ 0x18d1fe0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 15 >= 6 Thanks in advance. ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user
Re: [Libav-user] Suggest how to propery fill incomming AVFrame pointer in a decoder !
Hi, I am able to fill incoming AVFrame pointers. Can anyone suggest how to wrap buf[] array of the avframe pointers ! I am too much stuck at this point . Below the code, where *decoder->dst_data[]* array consist of Y, U and V buffers of image. And *decoder->dst_linesize[]* array consist of respective line sizes. AVFrame **avframe_src* = NULL; if(NULL != (avframe_src = *av_frame_alloc*())) { avframe_src->width = decoder->video_resolution.frame_width; avframe_src->height = decoder->video_resolution.frame_height; avframe_src->format = AV_PIX_FMT_YUV420P; //Allocate data array of avframe pointer if(*av_image_alloc*(avframe_src->data, avframe_src->linesize, decoder->video_resolution.frame_width, decoder->video_resolution.frame_height, AV_PIX_FMT_YUV420P, 1) < 0) { ERROR("Error : Allocating AVFRAME data\n"); } else { //Fill data array of avframe pointer with data from dst_data[0] if(*av_image_fill_arrays*(avframe_src->data, avframe_src->linesize, decoder->dst_data[0], avframe_src->format, avframe_src->width, avframe_src->height, 1) > 0) { //This is done to make sure that incoming avframe pointer's buf[0] //has proper referenced buffer and YUV data AVFrame **avframe_dst* = (AVFrame *) pFrame; if(0 == *av_frame_ref*(avframe_dst,avframe_src)) { //av_buffer_create is used to make sure that //buf array of avframe has wrapped data array //such that its opaque value is set to the //incoming opaque pointer avframe_dst->buf[0] = *av_buffer_create*(avframe_dst->data[0], avframe_dst->linesize[0], NULL, opaque, 0); avframe_dst->buf[1] = *av_buffer_create*(avframe_dst->data[1], avframe_dst->linesize[1], NULL, opaque, 0); avframe_dst->buf[2] = *av_buffer_create*(avframe_dst->data[2], avframe_dst->linesize[2], NULL, opaque, 0); if((NULL != avframe_dst->buf[0]) && (NULL != avframe_dst->buf[1]) && (NULL != avframe_dst->buf[2])) { ret = 1; } } } av_frame_unref(avframe_src); } av_frame_free(_src); } else { ERROR("Error : Not able to allocate avframe source pointer\n"); } -- View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Suggest-how-to-propery-fill-incomming-AVFrame-pointer-in-a-decoder-tp4662417p4662464.html Sent from the libav-users mailing list archive at Nabble.com. ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user