[Libav-user] Questions about transcoding h264 and h265

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Questions about transcoding h264 and h265

Leandro Moreira
Hello there,

I'm writing this tutorial and right now I'm attempting to create a section for transcoding.

1) Is there a single way to setup GOP and scenecut for h264 and h265?
I tried to use avcodectxt->gop_size, avcodectxt->keyint_min, av_opt_set(avcodecctxt->priv_data, "sc_threshold", "0", 0) but it seemed to work only for h264... to make it work I forced the priv_data x264 and x265-params while looking at the source code of both plugins I saw h264 uses gop_size but not h265 (both x___ libs)
2) Is there a single way to setup "CBR" for h264 and h265?
I could get the expected results while using x264 but no x265 using
|encoder_codec_context->bit_rate = 1200 * 1000;
|encoder_codec_context->rc_max_rate = 1200 * 1000;
|encoder_codec_context->rc_min_rate = 1200 * 1000;
|encoder_codec_context->rc_buffer_size = 2 * 1200 * 1000;
here it's weird because at source code level both libs seems to use rc_max_rate and rc_buffer_size
3) After I transcoded with my code I'm getting a 60.11 fps while the original video has fixed 60fps, why this usually happens?

Thanks

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Questions about transcoding h264 and h265

Vassilis
3) After I transcoded with my code I'm getting a 60.11 fps while the original video has fixed 60fps, why this usually happens?

While I am not able to .help you with the two first issues I think I may have an idea for the third. This seems like an issue I faced with my own attempt at transcoding video and a fix was suggested by a member of this mailing list (thanks James). You need to set the AVPacket duration field, otherwise this issue is present. This would mean adding something in the lines of the following line of code before your av_interleaved_write_frame is called:

// for example, if 25 FPS, and time_base is 12800, then packet.duration = 12800 / 25 = 512
output_packet.duration = format_context->streams[stream_index]->time_base.den / format_context->streams[stream_index]->time_base.num / format_context->streams[stream_index]->avg_frame_rate.num * format_context->streams[stream_index]->avg_frame_rate.den;

 /* mux encoded frame */
    ret = av_interleaved_write_frame(format_context, output_packet);

Hope this helps!

Vas


 

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Questions about transcoding h264 and h265

Leandro Moreira
Thanks Vassilis that's awesome, it worked, I just had to get the frame rate from the decoder context but now this fps problem was fixed thanks to you (and James). I still need to figure it out how to fix all the other issues.

On Sun, Dec 29, 2019 at 3:06 AM Vassilis <[hidden email]> wrote:
3) After I transcoded with my code I'm getting a 60.11 fps while the original video has fixed 60fps, why this usually happens?

While I am not able to .help you with the two first issues I think I may have an idea for the third. This seems like an issue I faced with my own attempt at transcoding video and a fix was suggested by a member of this mailing list (thanks James). You need to set the AVPacket duration field, otherwise this issue is present. This would mean adding something in the lines of the following line of code before your av_interleaved_write_frame is called:

// for example, if 25 FPS, and time_base is 12800, then packet.duration = 12800 / 25 = 512
output_packet.duration = format_context->streams[stream_index]->time_base.den / format_context->streams[stream_index]->time_base.num / format_context->streams[stream_index]->avg_frame_rate.num * format_context->streams[stream_index]->avg_frame_rate.den;

 /* mux encoded frame */
    ret = av_interleaved_write_frame(format_context, output_packet);

Hope this helps!

Vas


 
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".