Recherche avancée

Médias (1)

Mot : - Tags -/vidéo

Sur d’autres sites (330)

  • AWS Lambda failed to resolve hostname in child_process spawn

    28 mars, par warly

    i'm trying to get ffmpeg working in AWS Lambda reading from and writing to S3. I crawled through dozens of aws documentations, stackoverflow questions and blog posts. All do it slightly different, but in the end none of them worked for me. So I hope to find help here :)
I sticked to the tutorial from InPlainEnglish : https://plainenglish.io/community/automated-video-processing-with-aws-lambda-and-ffmpeg-2834b7

    


    The ffprobe command does work, so ffmpeg is callable. But when calling ffmpeg within a child_process.spawn command i get the error Failed to resolve hostname my-bucket.s3.eu-central-1.amazonaws.com: System error

    


    export const handler = async (event) => {
    const s3 = new S3Client({});
    const bucket = event.Records[0].s3.bucket.name;
    const sourceKey = event.Records[0].s3.object.key;
    const sourceURL = await getSignedUrl(s3, new GetObjectCommand({
        Bucket: bucket,
        Key: sourceKey,
    }), {
        expiresIn: 900,
    });

    const tmpFilePath = 'tmp/video.mp4';
    const { convertOut } = await commander(`/opt/ffmpeg -i "${sourceURL}" -vf scale=1080:-2,format=yuv420p ${tmpFilePath}`);

    return {
        statusCode: 200,
        body: {
            result: JSON.stringify(convertOut),
        },
    };
};


    


    the signed url is fine. I've tested it with vanilla js await fetch(sourceURL) and it returned the file. The problem is that for some reason the child_process has no internet access.

    


    if anyone is able to point me in the right direction i would appreciate it :D

    


    Full error message :

    


    {
  "errorType": "Error",
  "errorMessage": "Command failed: /opt/ffmpeg -i \"https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject\" -vf scale=1080:-2,crop=1080:1350,format=yuv420p tmp/video.mp4\nffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers\n  built with gcc 8 (Debian 8.3.0-6)\n  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzimg\n  libavutil      58. 29.100 / 58. 29.100\n  libavcodec     60. 31.102 / 60. 31.102\n  libavformat    60. 16.100 / 60. 16.100\n  libavdevice    60.  3.100 / 60.  3.100\n  libavfilter     9. 12.100 /  9. 12.100\n  libswscale      7.  5.100 /  7.  5.100\n  libswresample   4. 12.100 /  4. 12.100\n  libpostproc    57.  3.100 / 57.  3.100\n[tcp @ 0x141950d0] Failed to resolve hostname my-bucket.s3.eu-central-1.amazonaws.com: System error\n[in#0 @ 0x14190900] Error opening input: Input/output error\nError opening input file https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject.\nError opening input files: Input/output error\n",
  "trace": [
    "Error: Command failed: /opt/ffmpeg -i \"https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject\" -vf scale=1080:-2,crop=1080:1350,format=yuv420p tmp/video.mp4",
    "ffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers",
    "  built with gcc 8 (Debian 8.3.0-6)",
    "  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzimg",
    "  libavutil      58. 29.100 / 58. 29.100",
    "  libavcodec     60. 31.102 / 60. 31.102",
    "  libavformat    60. 16.100 / 60. 16.100",
    "  libavdevice    60.  3.100 / 60.  3.100",
    "  libavfilter     9. 12.100 /  9. 12.100",
    "  libswscale      7.  5.100 /  7.  5.100",
    "  libswresample   4. 12.100 /  4. 12.100",
    "  libpostproc    57.  3.100 / 57.  3.100",
    "[tcp @ 0x141950d0] Failed to resolve hostname my-bucket.s3.eu-central-1.amazonaws.com: System error",
    "[in#0 @ 0x14190900] Error opening input: Input/output error",
    "Error opening input file https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject.",
    "Error opening input files: Input/output error",
    "",
    "    at ChildProcess.exithandler (node:child_process:422:12)",
    "    at ChildProcess.emit (node:events:518:28)",
    "    at maybeClose (node:internal/child_process:1105:16)",
    "    at ChildProcess._handle.onexit (node:internal/child_process:305:5)"
  ]
}
enter code here


    


    Update : Turns out it is not S3 or internet, but the child_process which does not seem to have internet access. I've update my description above.

    


  • AWS Lambda failed to resolve hostname on S3 signed url

    9 février, par warly

    i'm trying to get ffmpeg working in AWS Lambda reading from and writing to S3. I crawled through dozens of aws documentations, stackoverflow questions and blog posts. All do it slightly different, but in the end none of them worked for me. So I hope to find help here :)
I sticked to the tutorial from InPlainEnglish : https://plainenglish.io/community/automated-video-processing-with-aws-lambda-and-ffmpeg-2834b7

    


    The ffprobe command does work, so ffmpeg is callable. But when calling ffmpeg with an S3 signed url i get the error Failed to resolve hostname my-bucket.s3.eu-central-1.amazonaws.com: System error

    


    export const handler = async (event) => {
    const s3 = new S3Client({});
    const bucket = event.Records[0].s3.bucket.name;
    const sourceKey = event.Records[0].s3.object.key;
    const sourceURL = await getSignedUrl(s3, new GetObjectCommand({
        Bucket: bucket,
        Key: sourceKey,
    }), {
        expiresIn: 900,
    });

    const tmpFilePath = 'tmp/video.mp4';
    const { convertOut } = await commander(`/opt/ffmpeg -i "${sourceURL}" -vf scale=1080:-2,format=yuv420p ${tmpFilePath}`);

    return {
        statusCode: 200,
        body: {
            result: JSON.stringify(convertOut),
        },
    };
};


    


    if anyone is able to point me in the right direction i would appreciate it :D

    


    Full error message :

    


    {
  "errorType": "Error",
  "errorMessage": "Command failed: /opt/ffmpeg -i \"https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject\" -vf scale=1080:-2,crop=1080:1350,format=yuv420p tmp/video.mp4\nffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers\n  built with gcc 8 (Debian 8.3.0-6)\n  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzimg\n  libavutil      58. 29.100 / 58. 29.100\n  libavcodec     60. 31.102 / 60. 31.102\n  libavformat    60. 16.100 / 60. 16.100\n  libavdevice    60.  3.100 / 60.  3.100\n  libavfilter     9. 12.100 /  9. 12.100\n  libswscale      7.  5.100 /  7.  5.100\n  libswresample   4. 12.100 /  4. 12.100\n  libpostproc    57.  3.100 / 57.  3.100\n[tcp @ 0x141950d0] Failed to resolve hostname my-bucket.s3.eu-central-1.amazonaws.com: System error\n[in#0 @ 0x14190900] Error opening input: Input/output error\nError opening input file https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject.\nError opening input files: Input/output error\n",
  "trace": [
    "Error: Command failed: /opt/ffmpeg -i \"https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject\" -vf scale=1080:-2,crop=1080:1350,format=yuv420p tmp/video.mp4",
    "ffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers",
    "  built with gcc 8 (Debian 8.3.0-6)",
    "  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzimg",
    "  libavutil      58. 29.100 / 58. 29.100",
    "  libavcodec     60. 31.102 / 60. 31.102",
    "  libavformat    60. 16.100 / 60. 16.100",
    "  libavdevice    60.  3.100 / 60.  3.100",
    "  libavfilter     9. 12.100 /  9. 12.100",
    "  libswscale      7.  5.100 /  7.  5.100",
    "  libswresample   4. 12.100 /  4. 12.100",
    "  libpostproc    57.  3.100 / 57.  3.100",
    "[tcp @ 0x141950d0] Failed to resolve hostname my-bucket.s3.eu-central-1.amazonaws.com: System error",
    "[in#0 @ 0x14190900] Error opening input: Input/output error",
    "Error opening input file https://my-bucket.s3.eu-central-1.amazonaws.com/original/Testvideo.MOV?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential={redacted}&X-Amz-Date=20240209T212255Z&X-Amz-Expires=900&X-Amz-Security-Token={redacted}&X-Amz-Signature={redacted}&X-Amz-SignedHeaders=host&x-id=GetObject.",
    "Error opening input files: Input/output error",
    "",
    "    at ChildProcess.exithandler (node:child_process:422:12)",
    "    at ChildProcess.emit (node:events:518:28)",
    "    at maybeClose (node:internal/child_process:1105:16)",
    "    at ChildProcess._handle.onexit (node:internal/child_process:305:5)"
  ]
}
enter code here


    


  • FFMpeg clip broken, generated from images [closed]

    5 février, par thomassss

    I hope someone can help me out here, would really appreciate it :).

    


    I created a video out of images, and then merged it with other videos.
The problem is that the final result is kinda broken - when I want to add background music to it, it won't play the music on the parts with the video generated by images, and on mobile phones it seems even more broken.

    


    The commands I used :

    


    Extracting the images from the video :

    


    ffmpeg.exe -i E:\dev\chatgpt\temp11\peng\final\1_runway.mp4 -vsync 0 -f image2 E:\dev\chatgpt\temp9\peng\final/1_runway-%06d.png


    


    Then I edit the images, then merging them back with :

    


    ffmpeg.exe  -i  E:\dev\chatgpt\temp11\peng\final\2_runway_final-%06d.png E:\dev\chatgpt\temp9\peng\final\5_runway_final.mp4



    


    This file now seems to be broken

    


    Now when i merge this file with other mp4s via

    


    ffmpeg.exe -f concat   -i E:\dev\chatgpt\temp11\peng\\final\ENGLISH_ffmpeg_input.txt  -vcodec copy -acodec copy E:\dev\chatgpt\temp9\peng\\final\ENGLISH_output.mp4


    


    Ad then add background music via

    


    ffmpeg.exe -i "E:\dev\chatgpt\temp11\peng\final\ENGLISH_output.mp4" -i "E:\dev\chatgpt\background.mp3" -filter_complex "[1:a]volume=0.2[a1];[0:a][a1]amix=inputs=2:duration=longest[a]" -map 0:v -map "[a]" -c:v copy -c:a aac -shortest "E:\dev\chatgpt\temp10\peng\final\ENGLISH_output_background.mp4"


    


    the background music isn't played in the parts with the "video generated from images".
Even VLC sometimes have problem displaying all parts correctly - that's why I added Youtube-links - this seems to work somehow.

    


    Does anyone have a clue how I can investigate further ?

    


    I tried converting both, the final video-file and the generated clip from images into different formats with different framerates - but nothing worked

    


    Thanks in advance !

    


    Endfile with backgroundmusic
Dropbox :
https://www.dropbox.com/scl/fi/peouyis2eezakc91mzfvt/ENGLISH_output_background.mp4?rlkey=4yfcyxzvh6fa3w0qxbiaz4auf&dl=1
Youtube :
https://www.youtube.com/watch?v=9gV6wP08lWA

    


    Without backgroundmusic
https://www.dropbox.com/scl/fi/7543al9kngtkdy92rqhe3/ENGLISH_output.mp4?rlkey=og6jnxgbqwc2r6gxg2xpphfwc&dl=1
Youtube :
https://www.youtube.com/shorts/1zIRFs6bYgU

    


    Standalone file - generated from images :
https://www.dropbox.com/scl/fi/cy46ngkvoofnf7mur420i/3_runway_final.mp4?rlkey=70emr5t9dv53s5rcz4qaygwla&dl=1

    


    Edit :

    


    Download Single Images of one Video :
https://www.dropbox.com/scl/fi/817kakf1sksqfnulv1cja/singleimagesofonevideo.7z?rlkey=xkc73s7z8rfkp1js2epuzebs0&dl=1

    


    All Videos :
https://www.dropbox.com/scl/fi/817kakf1sksqfnulv1cja/singleimagesofonevideo.7z?rlkey=xkc73s7z8rfkp1js2epuzebs0&dl=1

    


    ffprobe of "normal" video :

    


    ffprobe.exe ENGLISH_0.mp4
ffprobe version 6.1.1-full_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
configuration : —enable-gpl —enable-version3 —enable-static —pkg-config=pkgconf —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-libuavs3d —enable-libzvbi —enable-librav1e —enable-libsvtav1 —enable-libwebp —enable-libx264 —enable-libx265 —enable-libxavs2 —enable-libxvid —enable-libaom —enable-libjxl —enable-libopenjpeg —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-ffnvcodec —enable-nvdec —enable-nvenc —enable-dxva2 —enable-d3d11va —enable-libvpl —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-libopencore-amrnb —enable-libopus —enable-libspeex —enable-libvorbis —enable-ladspa —enable-libbs2b —enable-libflite —enable-libmysofa —enable-librubberband —enable-libsoxr —enable-chromaprint
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ENGLISH_0.mp4' :
Metadata :
major_brand : isom
minor_version : 512
compatible_brands : isomiso2avc1mp41
encoder : Lavf60.16.100
Duration : 00:00:03.38, start : 0.000000, bitrate : 238 kb/s
Stream #0:00x1 : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 1080x1920, 160 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata :
handler_name : VideoHandler
vendor_id : [0][0][0][0]
encoder : Lavc60.31.102 libx264
Stream #0:10x2 : Audio : aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata :
handler_name : SoundHandler
vendor_id : [0][0][0][0]