Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Info Columns for Similar/Duplicate Videos | Resolution, Codec, Bitrate #1263

Open
C-BoT-AU opened this issue Apr 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@C-BoT-AU
Copy link

C-BoT-AU commented Apr 4, 2024

Feature Description

  • Add Columns to the Video list including:
    • Duration
    • Video-CodecID
    • Video-AspectRatio
    • Video-BitRate (and/or Video-BitRateString)
    • Video-FrameRate
    • Video-Height
    • Video-Width
    • Audio-Format
    • Audio-CodecID
    • Audio-BitRate
  • Ability to include/exclude columns in the settings would also be useful

("Resolution" such as 1080p/720p etc appear mostly as a custom entered field and not always available so I've found it easier to just pull height and width and interpret from there.

From what I can tell, Czkawka uses at least parts of FFMPEG. I believe what I mentioned here can be accomplished with it, however, I've found it easier with MediaInfo CLI after some solid trial and error and research getting the template right.
I don't speak Rust, but do speak some Python and have a script that extracts the mentioned info using MediaInfo CLI to a CSV file for a directory. It isn't perfect and occasionally files return blank values in fields like BitRate when it shouldn't, but it does work so I'm happy to share if it helps at all.

Cut Down version of my Python Script:

def mediainfo_extract():
    report_name = get_report_name()
    list_of_files = get_list_of_files()
    
    # Clear the DataFrame before processing each directory
    df = pd.DataFrame(columns=['FilePath', 'FileName', 'FileSize', 'Duration', 'DurationString', 'FileExtension',
                            'Video-CodecID', 'Video-AspectRatio', 'Video-BitRate', 'Video-BitRateString', 'Video-FrameRate',
                            'Video-Height', 'Video-Width', 'Audio-Format', 'Audio-CodecID', 'Audio-BitRate'])
    
    for file in list_of_files:
        file_path = os.path.join(root, file)
                  
        ### Run the MEDIAFINO COMMAND command using subprocess
        mediainfo_command = ["mediainfo", "--Inform=file:///app/template.txt", file_path]
      
        mediainfo_output = subprocess.check_output(mediainfo_command, text=True).strip()

        # Parse the mediainfo output and extract relevant information
        parsed_info = parse_mediainfo_output(mediainfo_output)

        parsed_info_df = pd.DataFrame.from_dict(parsed_info, orient='index').transpose()

        # Append the information to the DataFrame
        df = pd.concat([df, parsed_info_df], axis=0, ignore_index=True)

    # CSV File Path Declaration
    csv_file_name = f"{report_name}_report.csv"
    csv_path = os.path.join("/app/reports/", csv_file_name)

    # Check if the CSV file already exists
    if os.path.exists(csv_path):
        # If it does, rename and move to the archive folder
        date_created = datetime.now().strftime("%y%m%d-%H%M%S")
        new_csv_name = f"{date_created}_{csv_file_name}"
        new_csv_path = os.path.join("/app/archive/", new_csv_name)
        os.rename(csv_path, new_csv_path)
    
    # Write the DataFrame to a new CSV file
    df.to_csv(csv_path, index=False)

template.txt

General;FilePath: %CompleteName%\rDuration: %Duration%\rDurationString: %Duration/String%\r
Video;Video-CodecID: %CodecID%\rVideo-AspectRatio: %DisplayAspectRatio%\rVideo-BitRate: %BitRate%\rVideo-BitRateString: %BitRate/String%\rVideo-FrameRate: %FrameRate%\rVideo-Height: %Height%\rVideo-Width: %Width%\r\n
Audio;Audio-Format: %Format%\rAudio-CodecID: %CodecID%\rAudio-BitRate: %BitRate%\r\n

I can try to see if I can get the same results with FFPROBE if it is something you're interested in incorporating it (and you don't already have a better way). I don't speak rust but I'm happy to try to help in some way to show my thanks for the app!

@C-BoT-AU C-BoT-AU added the enhancement New feature or request label Apr 4, 2024
@boognish-rising
Copy link

+1 for resolution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants