[Python] javacv and moviepy comparison for video generation

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to generate video using images, where image have some overlays text and png icons. I am using javacv library for this. Final output video seems pixelated, i don't understand what is it since i do not have video processing domain knowledge, i am beginner to this. I know that video bitrate and choice of video encoder are important factor which contributes to video quality and there are many more factors too.

    I am providing you two output for comparison, one of them is generated using javacv and another one is from moviepy library

    Please watch it in full screen since the problem i am talking about only gets highlighted in full screen, you will see the pixel dancing in javacv generated video, but python output seems stable

    https://imgur.com/a/aowNnKg - javacv generated

    https://imgur.com/a/eiLXrbk - Moviepy generated

    I am using same encoder in both of the implementation

    Encoder - libx264
    bitrate -
    800 Kbps for javacv
    500 Kbps for moviepy

    frame rate - 24fps for both of them

    output video size ->
    7MB (javacv)
    5MB (Moviepy)




    generated output size from javacv is bigger then moviepy generated video.

    here is my java configuration for FFmpegFrameRecorder

    FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(this.outputPath,
    this.screensizeX, this.screensizeY);
    if(this.videoCodecName!=null && "libx264".equals(this.videoCodecName)) {
    recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
    }
    recorder.setFormat("mp4");
    recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420);
    recorder.setVideoBitrate(800000);
    recorder.setImageWidth(this.screensizeX);



    and here is python configuration for writing video file

    Full_final_clip.write_videofile(
    f"{video_folder_path}/{FILE_ID}_INTERMEDIATE.mp4",
    codec="libx264",
    audio_codec="aac",
    temp_audiofile=f"{FILE_ID}_INTER_temp-audio.m4a",
    remove_temp=True,
    fps=24,
    )



    as you can see i am not specifying bitrate in python, but i checked that bitrate of final output is around 500 kbps, which is lower then what i specified in java, yet java generated video quality seems poor.

    I have tried setting crf value also , but it seems it does not have any impact when used.

    increasing bitrate improve quality somewhat but at the cost of file size, still generated output seems pixelated.

    Can someone please highlight what might be the issue, and how python is generating better quality video, when both of the libraries use ffmpeg at the backend.

    Continue reading...

Compartilhe esta Página