RoughDraft
RoughDraft copied to clipboard
[Bug]: ProgressAction Parameter returns "Specified argument was out of the range of valid values. (Parameter 'index')"
Description
When I'm trying to suppress the progress bar (because I've wrapped my own around the function), the process is returning an error:
Convert-Media: Specified argument was out of the range of valid values. (Parameter 'index')
This has been attempted with the following file types:
- .avi
- .divx
- .m4v
- .mp4
All files convert without the -ProgressAction flag set. This appears to happen for any of the [ActionPreference] enumerations.
Before Script Run:
After Script Run:
Start-Process -FilePath ( Get-FFMpeg ) -ArgumentList "-version" -NoNewWindow -Wait
ffmpeg version 7.1-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 14.2.0 (Rev1, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1 --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-liblc3 --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 59. 39.100 / 59. 39.100
libavcodec 61. 19.100 / 61. 19.100
libavformat 61. 7.100 / 61. 7.100
libavdevice 61. 3.100 / 61. 3.100
libavfilter 10. 4.100 / 10. 4.100
libswscale 8. 3.100 / 8. 3.100
libswresample 5. 3.100 / 5. 3.100
libpostproc 58. 3.100 / 58. 3.100
Media Information for Files
[
{
"InputPath": "D:\\Scratch\\RoughDraft\\MyExampleMedia.avi",
"streams": [
{
"index": 0,
"codec_name": "mpeg4",
"codec_long_name": "MPEG-4 part 2",
"codec_type": "video",
"codec_tag_string": "DX50",
"codec_tag": "0x30355844",
"width": 640,
"height": 480,
"coded_width": 640,
"coded_height": 480,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 1,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "4:3",
"pix_fmt": "yuv420p",
"level": -99,
"chroma_location": "left",
"refs": 1,
"quarter_sample": "false",
"divx_packed": "true",
"r_frame_rate": "30000/1001",
"avg_frame_rate": "30000/1001",
"time_base": "1001/30000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 42133,
"duration": "1405.837767",
"bit_rate": "776076",
"nb_frames": "42133",
"extradata_size": 46,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
}
},
{
"index": 1,
"codec_name": "mp3",
"codec_long_name": "MP3 (MPEG audio layer 3)",
"codec_type": "audio",
"codec_tag_string": "U[0][0][0]",
"codec_tag": "0x0055",
"sample_fmt": "fltp",
"sample_rate": "44100",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/16000",
"start_pts": 0,
"start_time": "0.000000",
"bit_rate": "128000",
"nb_frames": "22469904",
"extradata_size": 12,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
}
}
],
"format": {
"filename": "D:\\Scratch\\RoughDraft\\MyExampleMedia.avi",
"nb_streams": 2,
"nb_programs": 0,
"nb_stream_groups": 0,
"format_name": "avi",
"format_long_name": "AVI (Audio Video Interleaved)",
"start_time": "0.000000",
"duration": "1405.837767",
"size": "160894976",
"bit_rate": "915582",
"probe_score": 100
},
"FileSize": 160894976,
"CodecTypes": [
"video",
"audio"
],
"Codecs": [
"mpeg4",
"mp3"
],
"Duration": {
"Ticks": 14058377670,
"Days": 0,
"Hours": 0,
"Milliseconds": 837,
"Microseconds": 767,
"Nanoseconds": 0,
"Minutes": 23,
"Seconds": 25,
"TotalDays": 0.01627127045138889,
"TotalHours": 0.39051049083333333,
"TotalMilliseconds": 1405837.767,
"TotalMicroseconds": 1405837767.0,
"TotalNanoseconds": 1405837767000.0,
"TotalMinutes": 23.43062945,
"TotalSeconds": 1405.837767
},
"Width": 640,
"Height": 480,
"Resolution": "640x480"
},
{
"InputPath": "D:\\Scratch\\RoughDraft\\MyExampleMedia.divx",
"streams": [
{
"index": 0,
"codec_name": "mpeg4",
"codec_long_name": "MPEG-4 part 2",
"codec_type": "video",
"codec_tag_string": "DX50",
"codec_tag": "0x30355844",
"width": 720,
"height": 576,
"coded_width": 720,
"coded_height": 576,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "5:4",
"pix_fmt": "yuv420p",
"level": -99,
"chroma_location": "left",
"refs": 1,
"quarter_sample": "false",
"divx_packed": "false",
"r_frame_rate": "25/1",
"avg_frame_rate": "25/1",
"time_base": "1/25",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 38349,
"duration": "1533.960000",
"bit_rate": "1298879",
"nb_frames": "38349",
"extradata_size": 46,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
},
"tags": {
"title": ""
}
},
{
"index": 1,
"codec_name": "mp3",
"codec_long_name": "MP3 (MPEG audio layer 3)",
"codec_type": "audio",
"codec_tag_string": "U[0][0][0]",
"codec_tag": "0x0055",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/20000",
"start_pts": 0,
"start_time": "0.000000",
"bit_rate": "160000",
"nb_frames": "30678600",
"extradata_size": 12,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
},
"tags": {
"title": "Audio"
}
}
],
"format": {
"filename": "D:\\Scratch\\RoughDraft\\MyExampleMedia.divx",
"nb_streams": 2,
"nb_programs": 0,
"nb_stream_groups": 0,
"format_name": "avi",
"format_long_name": "AVI (Audio Video Interleaved)",
"start_time": "0.000000",
"duration": "1533.960000",
"size": "281587704",
"bit_rate": "1468553",
"probe_score": 100
},
"FileSize": 281587704,
"CodecTypes": [
"video",
"audio"
],
"Codecs": [
"mpeg4",
"mp3"
],
"Duration": {
"Ticks": 15339600000,
"Days": 0,
"Hours": 0,
"Milliseconds": 960,
"Microseconds": 0,
"Nanoseconds": 0,
"Minutes": 25,
"Seconds": 33,
"TotalDays": 0.017754166666666668,
"TotalHours": 0.4261,
"TotalMilliseconds": 1533960.0,
"TotalMicroseconds": 1533960000.0,
"TotalNanoseconds": 1533960000000.0,
"TotalMinutes": 25.566,
"TotalSeconds": 1533.96
},
"Width": 720,
"Height": 576,
"Resolution": "720x576"
},
{
"InputPath": "D:\\Scratch\\RoughDraft\\MyExampleMedia.m4v",
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 1280,
"height": 720,
"coded_width": 1280,
"coded_height": 720,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 1,
"pix_fmt": "yuv420p",
"level": 31,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"field_order": "progressive",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"id": "0x1",
"r_frame_rate": "24000/1001",
"avg_frame_rate": "325580000/13579417",
"time_base": "1/90000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 122214753,
"duration": "1357.941700",
"bit_rate": "925691",
"bits_per_raw_sample": "8",
"nb_frames": "32558",
"extradata_size": 44,
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
},
"tags": {
"creation_time": "2012-03-26T22:25:32Z",
"language": "eng",
"vendor_id": "[0][0][0][0]",
"encoder": "JVT/AVC Coding"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"id": "0x2",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 65181696,
"duration": "1357.952000",
"bit_rate": "156753",
"nb_frames": "63654",
"extradata_size": 2,
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
},
"tags": {
"creation_time": "2012-03-26T22:25:32Z",
"language": "eng",
"vendor_id": "[0][0][0][0]"
}
}
],
"format": {
"filename": "D:\\Scratch\\RoughDraft\\MyExampleMedia.m4v",
"nb_streams": 2,
"nb_programs": 0,
"nb_stream_groups": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "1357.952000",
"size": "185042904",
"bit_rate": "1090129",
"probe_score": 100,
"tags": {
"major_brand": "mp42",
"minor_version": "0",
"compatible_brands": "mp42isomavc1",
"creation_time": "2012-03-26T22:25:32Z"
}
},
"major_brand": "mp42",
"minor_version": "0",
"compatible_brands": "mp42isomavc1",
"creation_time": "2012-03-26T22:25:32Z",
"FileSize": 185042904,
"CodecTypes": [
"video",
"audio"
],
"Codecs": [
"h264",
"aac"
],
"Duration": {
"Ticks": 13579520000,
"Days": 0,
"Hours": 0,
"Milliseconds": 952,
"Microseconds": 0,
"Nanoseconds": 0,
"Minutes": 22,
"Seconds": 37,
"TotalDays": 0.015717037037037036,
"TotalHours": 0.37720888888888887,
"TotalMilliseconds": 1357952.0,
"TotalMicroseconds": 1357952000.0,
"TotalNanoseconds": 1357952000000.0,
"TotalMinutes": 22.632533333333335,
"TotalSeconds": 1357.952
},
"Width": 1280,
"Height": 720,
"Resolution": "1280x720"
},
{
"InputPath": "D:\\Scratch\\RoughDraft\\MyExampleMedia.mp4",
"streams": [
{
"index": 0,
"codec_name": "mpeg4",
"codec_long_name": "MPEG-4 part 2",
"profile": "Simple Profile",
"codec_type": "video",
"codec_tag_string": "mp4v",
"codec_tag": "0x7634706d",
"width": 720,
"height": 480,
"coded_width": 720,
"coded_height": 480,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 0,
"sample_aspect_ratio": "8:9",
"display_aspect_ratio": "4:3",
"pix_fmt": "yuv420p",
"level": 3,
"chroma_location": "left",
"refs": 1,
"quarter_sample": "false",
"divx_packed": "false",
"id": "0x1",
"r_frame_rate": "30001/1001",
"avg_frame_rate": "30001/1001",
"time_base": "1/30001",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 2545543,
"duration": "84.848605",
"bit_rate": "1747579",
"nb_frames": "2543",
"extradata_size": 44,
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
},
"tags": {
"creation_time": "1970-01-01T00:00:00Z",
"language": "eng",
"handler_name": "VideoHandler",
"vendor_id": "[0][0][0][0]"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "44100",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"id": "0x2",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 3739648,
"duration": "84.799274",
"bit_rate": "128238",
"nb_frames": "3652",
"extradata_size": 2,
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
},
"tags": {
"creation_time": "1970-01-01T00:00:00Z",
"language": "eng",
"handler_name": "SoundHandler",
"vendor_id": "[0][0][0][0]"
}
}
],
"format": {
"filename": "D:\\Scratch\\RoughDraft\\MyExampleMedia.mp4",
"nb_streams": 2,
"nb_programs": 0,
"nb_stream_groups": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "84.848605",
"size": "19945433",
"bit_rate": "1880566",
"probe_score": 100,
"tags": {
"major_brand": "isom",
"minor_version": "512",
"compatible_brands": "isomiso2mp41",
"creation_time": "1970-01-01T00:00:00Z",
"encoder": "Lavf52.104.0"
}
},
"major_brand": "isom",
"minor_version": "512",
"compatible_brands": "isomiso2mp41",
"creation_time": "1970-01-01T00:00:00Z",
"encoder": "Lavf52.104.0",
"FileSize": 19945433,
"CodecTypes": [
"video",
"audio"
],
"Codecs": [
"mpeg4",
"aac"
],
"Duration": {
"Ticks": 848486050,
"Days": 0,
"Hours": 0,
"Milliseconds": 848,
"Microseconds": 605,
"Nanoseconds": 0,
"Minutes": 1,
"Seconds": 24,
"TotalDays": 0.000982044039351852,
"TotalHours": 0.023569056944444444,
"TotalMilliseconds": 84848.605,
"TotalMicroseconds": 84848605.0,
"TotalNanoseconds": 84848605000.0,
"TotalMinutes": 1.4141434166666667,
"TotalSeconds": 84.848605
},
"Width": 720,
"Height": 480,
"Resolution": "720x480"
}
]
Reproducable Steps
<# Assumes you have the following media files:
D:\Scratch\RoughDraft\MyExampleMedia.avi
D:\Scratch\RoughDraft\MyExampleMedia.divx
D:\Scratch\RoughDraft\MyExampleMedia.m4v
D:\Scratch\RoughDraft\MyExampleMedia.mp4
<See screenshot "before"
#>
$FileExtensions = ".avi", ".divx", ".m4v", ".mp4"
$MediaFiles = @()
ForEach ( $Extension in $FileExtensions ) {
$OriginalFile = "D:\Scratch\RoughDraft\MyExampleMedia$( $Extension )" | Get-Item
$MediaFiles += Get-Media -InputPath $OriginalFile.FullName
# This one runs
Convert-Media -InputPath $OriginalFile.FullName -OutputPath "$( $OriginalFile.FullName.Replace(".", "_from_") ).mkv" -VideoCodec hevc_nvenc
<# and returns:
--------------------------------------------------------------------
Directory: D:\Scratch\RoughDraft
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 1/22/2025 9:58 AM 424315947 MyExampleMedia_from_avi.mkv
#>
# this one fails
Convert-Media -InputPath $OriginalFile.FullName -OutputPath "$( $OriginalFile.FullName.Replace(".", "__with_ProgressAction__from_") ).mkv" -VideoCodec hevc_nvenc -ProgressAction SilentlyContinue
<# and returns:
Specified argument was out of the range of valid values. (Parameter 'index')
#>
}
$MediaFiles | ConvertTo-Json -Depth 10 | Out-File -FilePath D:\Scratch\RoughDraft\MediaFiles.json -Confirm:$false -Encoding utf8 -Force
Links
No response
Fixed return value for "good" run - does not affect the script of the results. It's just me being very specific about :bug: reporting.