Recherche avancée

Médias (91)

Autres articles (11)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

Sur d’autres sites (3325)

  • Have an error running one PowerShell script to concatenate avi files, when a very similar script works fine

    1er juillet 2023, par hw22s

    When I run the following PowerShell script, to concatenate the .avi files in a folder, I get an error.

    


    Script :

    


    # Set the folder path where the AVI files are located
$folderPath = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam"

# Get all AVI files in the folder
$aviFiles = Get-ChildItem -Path $folderPath -Filter "*.avi" | Sort-Object Name

# Check if there are at least 2 AVI files for concatenation
if ($aviFiles.Count -ge 2) {
    $videoFiles = $aviFiles.FullName

    Write-Host "Input Files for Concatenation:"
    foreach ($file in $aviFiles) {
        Write-Host $file.Name
    }

    $outputFile = Join-Path -Path $folderPath -ChildPath "concatenated.avi"

    # Create the FFmpeg command for concatenation
    $concatArguments = "-f", "concat", "-i", "`"concat:$videoFiles`"", "-c", "copy", "`"$outputFile`""

    $command = "ffmpeg $concatArguments"
    Write-Host "FFmpeg Command: $command"

    try {
        $process = Start-Process -FilePath "ffmpeg" -ArgumentList $concatArguments -NoNewWindow -PassThru -Wait -ErrorAction Stop
        Write-Host "Concatenation complete. Output file: $outputFile"
    } catch {
        Write-Host "Error occurred while executing FFmpeg command:"
        Write-Host "Error message: $($_.Exception.Message)"
    }
} else {
    Write-Host "Not enough AVI files found in the folder for concatenation."
}


    


    Output with error, (and no concatenated file is actually produced, needless to say) :

    


    Input Files for Concatenation:
webcam0.avi
webcam1.avi
FFmpeg Command: ffmpeg -f concat -i "concat:C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam0.avi C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam1.avi" -c copy "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\concatenated.avi"
ffmpeg version 2023-06-27-git-9b6d191a66-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, 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-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      58. 13.101 / 58. 13.101
  libavcodec     60. 21.100 / 60. 21.100
  libavformat    60.  9.100 / 60.  9.100
  libavdevice    60.  2.100 / 60.  2.100
  libavfilter     9.  8.102 /  9.  8.102
  libswscale      7.  3.100 /  7.  3.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
[in#0 @ 000001d2f05f1b00] Error opening input: Invalid argument
Concatenation complete. Output file: C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\concatenated.avi


    


    But this script, which ostensibly does the same thing to the same files, works fine :

    


    $file1 = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam0.avi"       # Path to the first video file
$file2 = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam1.avi"       # Path to the second video file
$outputFile = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\concat.avi"  # Path to the output concatenated video file

# Create a temporary batch script
$batchScriptPath = [System.IO.Path]::GetTempFileName() + ".bat"
@'
@echo off
ffmpeg -i "%~1" -i "%~2" -filter_complex "[0:v][1:v]concat=n=2:v=1[outv]" -map "[outv]" "%~3"
'@ | Set-Content -Path $batchScriptPath

# Execute the temporary batch script
try {
    & $batchScriptPath $file1 $file2 $outputFile
    Write-Host "Concatenation complete. Output file: $outputFile"
} catch {
    Write-Host "Error occurred while executing FFmpeg command:"
    Write-Host $_.Exception.Message
}

# Remove the temporary batch script
Remove-Item -Path $batchScriptPath -Force


    


    I can't figure out what is wrong with the first script. I tried many variations of the first script but cannot get it to work.

    


    Any help ?

    


  • Have an error running one batch script to concatenate avi files, when a very similar script works fine

    1er juillet 2023, par hw22s

    When I run the following bath script to concatenate the .avi files in a folder, I get an error. I am using powershell on a windows computer
Script :

    


    # Set the folder path where the AVI files are located
$folderPath = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam"

# Get all AVI files in the folder
$aviFiles = Get-ChildItem -Path $folderPath -Filter "*.avi" | Sort-Object Name

# Check if there are at least 2 AVI files for concatenation
if ($aviFiles.Count -ge 2) {
    $videoFiles = $aviFiles.FullName

    Write-Host "Input Files for Concatenation:"
    foreach ($file in $aviFiles) {
        Write-Host $file.Name
    }

    $outputFile = Join-Path -Path $folderPath -ChildPath "concatenated.avi"

    # Create the FFmpeg command for concatenation
    $concatArguments = "-f", "concat", "-i", "`"concat:$videoFiles`"", "-c", "copy", "`"$outputFile`""

    $command = "ffmpeg $concatArguments"
    Write-Host "FFmpeg Command: $command"

    try {
        $process = Start-Process -FilePath "ffmpeg" -ArgumentList $concatArguments -NoNewWindow -PassThru -Wait -ErrorAction Stop
        Write-Host "Concatenation complete. Output file: $outputFile"
    } catch {
        Write-Host "Error occurred while executing FFmpeg command:"
        Write-Host "Error message: $($_.Exception.Message)"
    }
} else {
    Write-Host "Not enough AVI files found in the folder for concatenation."
}



    


    Output with error (and no concatenated file is actually produced, needless to say) :

    


    Input Files for Concatenation:
webcam0.avi
webcam1.avi
FFmpeg Command: ffmpeg -f concat -i "concat:C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam0.avi C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam1.avi" -c copy "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\concatenated.avi"
ffmpeg version 2023-06-27-git-9b6d191a66-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, 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-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      58. 13.101 / 58. 13.101
  libavcodec     60. 21.100 / 60. 21.100
  libavformat    60.  9.100 / 60.  9.100
  libavdevice    60.  2.100 / 60.  2.100
  libavfilter     9.  8.102 /  9.  8.102
  libswscale      7.  3.100 /  7.  3.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
[in#0 @ 000001d2f05f1b00] Error opening input: Invalid argument
Concatenation complete. Output file: C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\concatenated.avi


    


    But this script, which ostensibly does the same thing to the same files, works fine :

    


    $file1 = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam0.avi"       # Path to the first video file
$file2 = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\webcam1.avi"       # Path to the second video file
$outputFile = "C:\Users\HomePC\hswlab\Desktop\videos\eyeblink\022223\2023_04_24\16_15_23\My_WebCam\concat.avi"  # Path to the output concatenated video file

# Create a temporary batch script
$batchScriptPath = [System.IO.Path]::GetTempFileName() + ".bat"
@'
@echo off
ffmpeg -i "%~1" -i "%~2" -filter_complex "[0:v][1:v]concat=n=2:v=1[outv]" -map "[outv]" "%~3"
'@ | Set-Content -Path $batchScriptPath

# Execute the temporary batch script
try {
    & $batchScriptPath $file1 $file2 $outputFile
    Write-Host "Concatenation complete. Output file: $outputFile"
} catch {
    Write-Host "Error occurred while executing FFmpeg command:"
    Write-Host $_.Exception.Message
}

# Remove the temporary batch script
Remove-Item -Path $batchScriptPath -Force



    


    I can't figure out what is wrong with the first script. Any help ?? Thank you !!

    


    Tried many variations on the first script but cannot get it to work.

    


  • How to fix the ffmpeg python issue "Error applying option 'original_size' to filter 'ass' : Invalid argument" ?

    16 février, par Gauthier Buttez

    ENVIRONMENT :

    


    Python 3.10

    


    Windows 11

    


    ffmpeg-python==0.2.0

    


    CONTEXT :

    


    I am trying to add hardcoded subtitles on a video with ffmpeg and Pyton.

    


    PROBLEM :

    


    ffmpeg is not able to find the path of my ass subtitle file. So I tried different ways with different methods. I asked different AI to try to find a solution. Impossible ! It is such a crazy issue that I tested the code from a "test" folder located on the root "C :" from the command line wid nows. No AI was able to fixed this issue. I tried chatGPT, deepseek, claude.ai. They proposed different solutions which were not working.

    


    THE CODE :

    


    import os
import ffmpeg
import subprocess

def add_subtitles_with_ass(video_path, ass_path, output_path):

    video_path = os.path.abspath(video_path)
    ass_path = os.path.abspath(ass_path)
    output_path = os.path.abspath(output_path)

    print(f"🚀 Add susbtitiles with ASS : {ass_path}")
    ass_path_escaped = rf'"{ass_path}"'

    try:
        ffmpeg.input(video_path).output(output_path, vf=f"ass='{ass_path_escaped}'").run(overwrite_output=True)
        print(f"✅ Subtitles added with success : {output_path}")
    except Exception as e:
        print(f"❌ ERROR when adding subtitles : {e}")


def add_subtitles_with_ass_with_subprocess(video_path, ass_path, output_path):
    video_path = os.path.abspath(video_path)
    ass_path = os.path.abspath(ass_path)
    output_path = os.path.abspath(output_path)

    print(f"🚀 Add subtitles with ASS : {ass_path}")

    try:
        command = [
            'ffmpeg',
            '-i', video_path,
            '-vf', f"ass='{ass_path}'",
            '-c:a', 'copy',
            output_path,
            '-y'  # Overwrite output file without asking
        ]

        subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        print(f"✅ Subtitles added with success : {output_path}")
    except subprocess.CalledProcessError as e:
        print(f"❌ ERROR when adding subtitles : {e.stderr.decode('utf-8')}")


print(f"Test 1 -----------------------------------------------------------------------")
ass_path="G:\Mi unidad\Python\Scripts\shorts_videos\10000views_and_higher\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path="G:\Mi unidad\Python\Scripts\shorts_videos\10000views_and_higher\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path="G:\Mi unidad\Python\Scripts\shorts_videos\10000views_and_higher\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path, ass_path, output_path)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 2 -----------------------------------------------------------------------")
ass_path2="G:\\Mi unidad\\Python\\Scripts\\shorts_videos\\10000views_and_higher\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path2="G:\\Mi unidad\\Python\\Scripts\\shorts_videos\\10000views_and_higher\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path2="G:\\Mi unidad\\Python\\Scripts\\shorts_videos\\10000views_and_higher\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path2, ass_path2, output_path2)

print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 3 -----------------------------------------------------------------------")
ass_path3="G:/\Mi unidad/\Python/\Scripts/\shorts_videos/\10000views_and_higher/\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path3="G:/\Mi unidad/\Python/\Scripts/\shorts_videos/\10000views_and_higher/\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path3="G:/\Mi unidad/\Python/\Scripts/\shorts_videos/\10000views_and_higher/\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path3, ass_path3, output_path3)

print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 4 -----------------------------------------------------------------------")
ass_path4="G:/\\Mi unidad/\\Python/\\Scripts/\\shorts_videos/\\10000views_and_higher/\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path4="G:/\\Mi unidad/\\Python/\\Scripts/\\shorts_videos/\\10000views_and_higher/\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path4="G:/\\Mi unidad/\\Python/\\Scripts/\\shorts_videos/\\10000views_and_higher/\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path4, ass_path4, output_path4)




print(f"Test 1 with subprocess -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path, ass_path, output_path)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 2 with subprocess -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path2, ass_path2, output_path2)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 3 with subprocess -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path3, ass_path3, output_path3)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 4 with subprocess -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path4, ass_path4, output_path4)
print(50*"*")
print(50*"*")
print(50*"*")

#======================= IT DIDN'T WORK, SO LET'S DO WITH RELATIVE PATH ===================================


print(f"Test 1 with relative path -----------------------------------------------------------------------")
ass_path_relative="10000views_and_higher\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path_relative="10000views_and_higher\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path_relative="10000views_and_higher\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path_relative, ass_path_relative, output_path_relative)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 2  with relative path -----------------------------------------------------------------------")
ass_path2_relative="10000views_and_higher\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path2_relative="10000views_and_higher\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path2_relative="10000views_and_higher\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path2_relative, ass_path2_relative, output_path2_relative)

print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 3  with relative path -----------------------------------------------------------------------")
ass_path3_relative="10000views_and_higher/\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path3_relative="10000views_and_higher/\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path3_relative="10000views_and_higher/\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path3_relative, ass_path3_relative, output_path3_relative)

print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 4  with relative path -----------------------------------------------------------------------")
ass_path4_relative="10000views_and_higher/\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.ass"
video_path4_relative="10000views_and_higher/\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo.mp4"
output_path4_relative="10000views_and_higher/\\Li2zY7XcOf0_Matthew_Hussey_flip_h_BW_with_logo_EN.mp4"
add_subtitles_with_ass(video_path4_relative, ass_path4_relative, output_path4_relative)




print(f"Test 1 with subprocess  with relative path -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path, ass_path, output_path)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 2 with subprocess  with relative path -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path2_relative, ass_path2_relative, output_path2_relative)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 3 with subprocess  with relative path -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path3_relative, ass_path3_relative, output_path3_relative)
print(50*"*")
print(50*"*")
print(50*"*")

print(f"Test 4 with subprocess  with relative path -----------------------------------------------------------------------")
add_subtitles_with_ass_with_subprocess(video_path4_relative, ass_path4_relative, output_path4_relative)
print(50*"*")
print(50*"*")
print(50*"*")


    


    THE OUTPUT :

    


    The output was too large to post it here. I uploaded it on my github :

    


    https://github.com/gauthierbuttez/public/blob/master/output_ffmpeg.log

    


    I also zipped and uploaded all the files to make reproducing the issue on your computer easy :

    


    https://github.com/gauthierbuttez/public/blob/master/test.zip

    


    Is there any kind super Python Master in the place ?