
Recherche avancée
Autres articles (8)
-
Qualité du média après traitement
21 juin 2013, parLe bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...) -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...)
Sur d’autres sites (4623)
-
Assembling frames into a video in Node.js using fluent-ffmpeg [closed]
14 novembre 2024, par AndreiI have the original video and it's modified frames in a folder. Now I want to assemble the modified frames into a new video. I also want to take the audio from the original video and add it to the new video.


My latest code is this using fluent-ffmpeg. But it's not working.


await new Promise((resolve, reject) => {
 ffmpeg(path.join(processedFramesDir, "frame-%d.png"))
 .inputOptions(["-framerate 30", "-start_number 1"])
 .input(videoPath)
 .outputOptions([
 "-c:v",
 "libx264",
 "-c:a",
 "copy",
 "-shortest",
 "-r",
 "30",
 "-pix_fmt",
 "yuv420p",
 ])
 .outputOptions(["-map 0:v:0", "-map 1:a:0"])
 .save(outputVideoPath)
 .on("start", (commandLine) => {
 console.log("FFmpeg command: " + commandLine);
 })
 .on("stderr", (stderrLine) => {
 console.log("FFmpeg stderr: " + stderrLine);
 })
 .on("end", resolve)
 .on("error", (err, stdout, stderr) => {
 console.error("Error assembling video:", err);
 console.error("FFmpeg stderr:", stderr);
 reject(err);
 });
});



I get this error even though the frames exist and they are valid pngs :

FFmpeg command: ffmpeg -framerate 30 -start_number 1 -i /tmp/video-processing-CyULOE/processedFrames/frame-%05d.png -i /tmp/video-processing-CyULOE/input.mp4 -y -c:v libx264 -c:a copy -shortest -r 30 -pix_fmt yuv420p -map 0:v:0 -map 1:a:0 /tmp/video-processing-CyULOE/output.mp4 2024-11-13 23:40:27 FFmpeg stderr: ffmpeg version 4.1.11-0+deb10u1 Copyright (c) 2000-2023 the FFmpeg developers 2024-11-13 23:40:27 FFmpeg stderr: built with gcc 8 (Debian 8.3.0-6) 2024-11-13 23:40:27 FFmpeg stderr: configuration: --prefix=/usr --extra-version=0+deb10u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared 2024-11-13 23:40:27 FFmpeg stderr: libavutil 56. 22.100 / 56. 22.100 2024-11-13 23:40:27 FFmpeg stderr: libavcodec 58. 35.100 / 58. 35.100 2024-11-13 23:40:27 FFmpeg stderr: libavformat 58. 20.100 / 58. 20.100 2024-11-13 23:40:27 FFmpeg stderr: libavdevice 58. 5.100 / 58. 5.100 2024-11-13 23:40:27 FFmpeg stderr: libavfilter 7. 40.101 / 7. 40.101 2024-11-13 23:40:27 FFmpeg stderr: libavresample 4. 0. 0 / 4. 0. 0 2024-11-13 23:40:27 FFmpeg stderr: libswscale 5. 3.100 / 5. 3.100 2024-11-13 23:40:27 FFmpeg stderr: libswresample 3. 3.100 / 3. 3.100 2024-11-13 23:40:27 FFmpeg stderr: libpostproc 55. 3.100 / 55. 3.100 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646F8A20000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646C89F0000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x524946464EA10000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x5249464628A40000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646AAA30000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x524946467CA10000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646AAA30000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646BAA10000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646ACA30000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x5249464670A80000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646E8A60000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x524946469AA60000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x5249464672A90000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646B8A50000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646AAA80000. 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x52494646A0A70000. 2024-11-13 23:40:27 FFmpeg stderr: Last message repeated 1 times 2024-11-13 23:40:27 FFmpeg stderr: [png @ 0x5630fb89a880] Invalid PNG signature 0x5249464646A80000. 2024-11-13 23:40:27 FFmpeg stderr: [image2 @ 0x5630fb898a40] decoding for stream 0 failed 2024-11-13 23:40:27 FFmpeg stderr: [image2 @ 0x5630fb898a40] Could not find codec parameters for stream 0 (Video: png, none(pc)): unspecified size 2024-11-13 23:40:27 FFmpeg stderr: Consider increasing the value for the 'analyzeduration' and 'probesize' options 2024-11-13 23:40:27 FFmpeg stderr: Input #0, image2, from '/tmp/video-processing-CyULOE/processedFrames/frame-%05d.png': 2024-11-13 23:40:27 FFmpeg stderr: Duration: 00:00:00.60, start: 0.000000, bitrate: N/A 2024-11-13 23:40:27 FFmpeg stderr: Stream #0:0: Video: png, none(pc), 30 fps, 30 tbr, 30 tbn, 30 tbc 2024-11-13 23:40:28 FFmpeg stderr: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/video-processing-CyULOE/input.mp4': 2024-11-13 23:40:28 FFmpeg stderr: Metadata: 2024-11-13 23:40:28 FFmpeg stderr: major_brand : isom 2024-11-13 23:40:28 FFmpeg stderr: minor_version : 512 2024-11-13 23:40:28 FFmpeg stderr: compatible_brands: isomiso2avc1mp41 2024-11-13 23:40:28 FFmpeg stderr: encoder : Lavf60.16.100 2024-11-13 23:40:28 FFmpeg stderr: Duration: 00:00:00.62, start: 0.000000, bitrate: 4289 kb/s 2024-11-13 23:40:28 FFmpeg stderr: Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 4395 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) 2024-11-13 23:40:28 FFmpeg stderr: Metadata: 2024-11-13 23:40:28 FFmpeg stderr: handler_name : VideoHandler 2024-11-13 23:40:28 FFmpeg stderr: Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default) 2024-11-13 23:40:28 FFmpeg stderr: Metadata: 2024-11-13 23:40:28 FFmpeg stderr: handler_name : SoundHandler 2024-11-13 23:40:28 FFmpeg stderr: Stream mapping: 2024-11-13 23:40:28 FFmpeg stderr: Stream #0:0 -> #0:0 (png (native) -> h264 (libx264)) 2024-11-13 23:40:28 FFmpeg stderr: Stream #1:1 -> #0:1 (copy) 2024-11-13 23:40:28 FFmpeg stderr: Press [q] to stop, [?] for help 2024-11-13 23:40:28 FFmpeg stderr: [image2 @ 0x5630fb898a40] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8) 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb9b7700] Invalid PNG signature 0x52494646F8A20000. 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb988dc0] Invalid PNG signature 0x52494646C89F0000. 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba3edc0] Invalid PNG signature 0x524946464EA10000. 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba40600] Invalid PNG signature 0x5249464628A40000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb8c7900] Invalid PNG signature 0x52494646AAA30000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb9b7700] Invalid PNG signature 0x524946467CA10000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb988dc0] Invalid PNG signature 0x52494646AAA30000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba3edc0] Invalid PNG signature 0x52494646BAA10000. 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba40600] Invalid PNG signature 0x52494646ACA30000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: Last message repeated 1 times 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb8c7900] Invalid PNG signature 0x5249464670A80000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb9b7700] Invalid PNG signature 0x52494646E8A60000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb988dc0] Invalid PNG signature 0x524946469AA60000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba3edc0] Invalid PNG signature 0x5249464672A90000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba40600] Invalid PNG signature 0x52494646B8A50000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb8c7900] Invalid PNG signature 0x52494646AAA80000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb9b7700] Invalid PNG signature 0x52494646A0A70000. 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fb988dc0] Invalid PNG signature 0x52494646A0A70000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: [png @ 0x5630fba3edc0] Invalid PNG signature 0x5249464646A80000. 2024-11-13 23:40:28 FFmpeg stderr: Error while decoding stream #0:0: Invalid data found when processing input 2024-11-13 23:40:28 FFmpeg stderr: Last message repeated 4 times 2024-11-13 23:40:28 FFmpeg stderr: Cannot determine format of input stream 0:0 after EOF 2024-11-13 23:40:28 FFmpeg stderr: Error marking filters as finished 2024-11-13 23:40:28 FFmpeg stderr: Conversion failed! 2024-11-13 23:40:28 FFmpeg stderr: 2024-11-13 23:40:28 Error assembling video: Error: ffmpeg exited with code 1: Cannot determine format of input stream 0:0 after EOF 2024-11-13 23:40:28 Error marking filters as finished 2024-11-13 23:40:28 Conversion failed! 2024-11-13 23:40:28 2024-11-13 23:40:28 at ChildProcess.<anonymous> (/usr/src/app/node_modules/fluent-ffmpeg/lib/processor.js:180:22) 2024-11-13 23:40:28 at ChildProcess.emit (node:events:519:28) 2024-11-13 23:40:28 at ChildProcess._handle.onexit (node:internal/child_process:294:12)</anonymous>


The code used to


ffmpeg(videoPath) .screenshots({ folder: framesDir, filename: "frame-%i.png", size: "?x1080", count: 10, }) .on("end", resolve) .on("error", reject);



The pngs are valid and displaying in windows photos viewer


-
Screen recording with ffmpeg has stuttering [closed]
7 novembre 2024, par Adam LabušI am recording with ffmpeg like so :
ffmpeg -f x11grab -probesize 18M -framerate 30 -video_size 1920x1080 -i :0.0+0,0 -f pulse -i -c:v libx264 -preset ultrafast -c:a aac .mkv


Problem :


Usually at the start the video starts to stutter, sometimes stuttering up to 20 seconds, each frame during this stuttering is shown for 1-5 seconds. Example video : https://drive.google.com/file/d/1uwdaFboCO2qNALgaPC8JD15W64BE3VyY/view?usp=sharing


Diagnostics :


Machine details :


OS: Fedora Linux 41 (Server Edition) x86_64
Host: HP ProDesk 600 G2 DM
Kernel: Linux 6.11.5-300.fc41.x86_64
WM: Openbox (X11)
CPU: Intel(R) Core(TM) i5-6500T (4) @ 3.10 GHz
GPU: Intel HD Graphics 530 @ 1.10 GHz [Integrated]
Memory: 884.62 MiB / 15.49 GiB (6%)
Swap: 0 B / 8.00 GiB (0%)
Disk (/): 5.45 GiB / 14.94 GiB (37%) - xfs



My gpu(20%), cpu (50%), disk utilisation is always in well perfect range - I tried stress testing gpu, ram, cpu and disk while recording and it had no effect on the recording. I tried recording to ramdisk. I always have 10gb ram available. I ran the same command on my laptop (hp 850 g5) and computer and encountered no stuttering at all.


If it matters the machine is running bare Xorg and openbox display manager


I have tried :


- 

- setting fps_mode to cfr - because the frame rate does fluctuate around 29-30 at the start
- setting fps_mode to vfr
- setting fps_mode to passthrough
- setting cfr all the way to 40
- presets veryfast, faster
- increasing thread_queue_size
- async=1
















Ffmpeg Log :


ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers 
 built with gcc 14 (GCC) 
 configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-swi
tches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/re
dhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --enable-fontcon
fig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-lcms2 --enable-libaom --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcodec2 --enable-libcdio --enable-libdrm --enabl
e-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enabl
e-libopenmpt --enable-libopus --enable-libpulse --enable-libplacebo --enable-librsvg --enable-librav1e --enable-librubberband --enable-libqrencode --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh
 --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-l
ibx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-strip
ping --shlibdir=/usr/lib64 --enable-lto --enable-libvpl --enable-runtime-cpudetect 
 libavutil 59. 8.100 / 59. 8.100 
 libavcodec 61. 3.100 / 61. 3.100 
 libavformat 61. 1.100 / 61. 1.100 
 libavdevice 61. 1.100 / 61. 1.100 
 libavfilter 10. 1.100 / 10. 1.100 
 libswscale 8. 1.100 / 8. 1.100 
 libswresample 5. 1.100 / 5. 1.100 
 libpostproc 58. 1.100 / 58. 1.100 
Input #0, x11grab, from ':0.0+0,0': 
 Duration: N/A, start: 1730923728.417205, bitrate: 1990656 kb/s 
 Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1990656 kb/s, 30 fps, 29.92 tbr, 1000k tbn 
[aist#1:0/pcm_s16le @ 0x55a29c634a40] Guessed Channel Layout: stereo 
Input #1, pulse, from 'auto_null.monitor': 
 Duration: N/A, start: 1730923728.521148, bitrate: 1536 kb/s 
 Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s 
Stream mapping: 
 Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) 
 Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native)) 
Press [q] to stop, [?] for help 
[libx264 @ 0x55a29c627f00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 
[libx264 @ 0x55a29c627f00] profile High 4:4:4 Predictive, level 4.0, 4:4:4, 8-bit 
[libx264 @ 0x55a29c627f00] 264 - core 164 r3108 31e19f9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 tre
llis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 
Output #0, matroska, to '/tmp/tmp38n41uwz.mkv': 
 Metadata: 
 encoder : Lavf61.1.100 
 Stream #0:0: Video: h264 (H264 / 0x34363248), yuv444p(progressive), 1920x1080, q=2-31, 29.92 fps, 1k tbn 
 Metadata: 
 encoder : Lavc61.3.100 libx264 
 Side data: 
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A 
 Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s 
 Metadata: 
 encoder : Lavc61.3.100 aac 
frame= 915 fps= 24 q=29.0 size= 7936KiB time=00:00:35.79 bitrate=1816.0kbits/s dup=0 drop=167 speed=0.929x 
 
[q] command received. Exiting.



-
Error Opening RTMP Stream through FFmpeg command when executed through exec package [closed]
3 octobre 2024, par AkhilI have been trying to transcode the live stream from RTMP server running on
rtmp://localhost:1936/live/test
with FFmpeg in a Go application usingos/exec
package, But seems to not work and gives the input/output error (I have attached below). The same exact ffmpeg command when I execute on terminal, works as its supposed to. Not Sure why that is, here is my code for reproducing and analyzing the mistakes.

ffmpegCmd := fmt.Sprintf("ffmpeg -nostdin -i rtmp://localhost:1936/live/%s -c:v libx264 -s %s -f %s %s/stream.mpd",
 streamKey, resolution, sp.OutputFormat, outputPath)
 log.Printf("Executing FFmpeg command: %s", ffmpegCmd)

 // Prepare the command execution with a timeout context
 ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Set a 60-second timeout
 defer cancel()

 cmd := exec.CommandContext(ctx, "bash", "-c", ffmpegCmd)



the ffmpeg command looks like this :

ffmpeg -nostdin -i rtmp://localhost:1936/live/test -c:v libx264 -s 1920x1080 -f dash output/test/1080p/stream.mpd


I get the following error :


Error opening input: Input/output error

Error opening input file rtmp://localhost:1936/live/test.

Error opening input files: Input/output error

Exiting normally, received signal 2.

signal: interrupt



I have already tried to break the command, and then execute it. Something like :


cmd := exec.CommandContext(ctx,
 "ffmpeg",
 "-nostdin",
 "-i", "rtmp://localhost:1936/live/"+streamKey,
 "-c:v", "libx264",
 "-s", resolution,
 "-f", sp.OutputFormat,
 outputPath+"/stream.mpd")



After running the ffmpeg command with -loglevel debug and -report :


Here is the logs and errors I get :


When I run it within the go application :


ffmpeg started on 2024-10-02 at 12:00:06
Report written to "ffmpeg-20241002-120006.log"
Log level: 48
Command line:
ffmpeg -loglevel debug -report -i rtmp://localhost:1936/live/test -c:v libx264 -s 1920x1080 -f dash ./output/test/1080p/stream.mpd
ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
 built with Apple clang version 15.0.0 (clang-1500.3.9.4)
 configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.0.2_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
 libavutil 59. 8.100 / 59. 8.100
 libavcodec 61. 3.100 / 61. 3.100
 libavformat 61. 1.100 / 61. 1.100
 libavdevice 61. 1.100 / 61. 1.100
 libavfilter 10. 1.100 / 10. 1.100
 libswscale 8. 1.100 / 8. 1.100
 libswresample 5. 1.100 / 5. 1.100
 libpostproc 58. 1.100 / 58. 1.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtmp://localhost:1936/live/test'.
Reading option '-c:v' ... matched as option 'c' (select encoder/decoder ('copy' to copy stream without reencoding)) with argument 'libx264'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '1920x1080'.
Reading option '-f' ... matched as option 'f' (force container format (auto-detected otherwise)) with argument 'dash'.
Reading option './output/test/1080p/stream.mpd' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url rtmp://localhost:1936/live/test.
Successfully parsed a group of options.
Opening an input file: rtmp://localhost:1936/live/test.
[AVFormatContext @ 0x13f721f90] Opening 'rtmp://localhost:1936/live/test' for reading
[rtmp @ 0x13f6040e0] No default whitelist set
[tcp @ 0x13f7223d0] No default whitelist set
[tcp @ 0x13f7223d0] Original list of addresses:
[tcp @ 0x13f7223d0] Address ::1 port 1936
[tcp @ 0x13f7223d0] Address 127.0.0.1 port 1936
[tcp @ 0x13f7223d0] Interleaved list of addresses:
[tcp @ 0x13f7223d0] Address ::1 port 1936
[tcp @ 0x13f7223d0] Address 127.0.0.1 port 1936
[tcp @ 0x13f7223d0] Starting connection attempt to ::1 port 1936
[tcp @ 0x13f7223d0] Connection attempt to ::1 port 1936 failed: Connection refused
[tcp @ 0x13f7223d0] Starting connection attempt to 127.0.0.1 port 1936
[tcp @ 0x13f7223d0] Successfully connected to 127.0.0.1 port 1936
[rtmp @ 0x13f6040e0] Handshaking...
[rtmp @ 0x13f6040e0] Type answer 3
[rtmp @ 0x13f6040e0] Server version 13.14.10.13
[rtmp @ 0x13f6040e0] Proto = rtmp, path = /live/test, app = live, fname = test
[rtmp @ 0x13f6040e0] Window acknowledgement size = 5000000
[rtmp @ 0x13f6040e0] Max sent, unacked = 5000000
[rtmp @ 0x13f6040e0] New incoming chunk size = 4096
[rtmp @ 0x13f6040e0] Creating stream...
[rtmp @ 0x13f6040e0] Sending play command for 'test'
[rtmp @ 0x13f6040e0] Deleting stream...
[in#0 @ 0x13f721d40] Error opening input: Input/output error
Error opening input file rtmp://localhost:1936/live/test.
Error opening input files: Input/output error
Exiting normally, received signal 2.



This is what i get when i run the same command on terminal :


<same as="as" but="but" please="please" scroll="scroll" further="further">

[rtmp @ 0x1437144c0] No default whitelist set
[tcp @ 0x143604f20] No default whitelist set
[tcp @ 0x143604f20] Original list of addresses:
[tcp @ 0x143604f20] Address ::1 port 1936
[tcp @ 0x143604f20] Address 127.0.0.1 port 1936
[tcp @ 0x143604f20] Interleaved list of addresses:
[tcp @ 0x143604f20] Address ::1 port 1936
[tcp @ 0x143604f20] Address 127.0.0.1 port 1936
[tcp @ 0x143604f20] Starting connection attempt to ::1 port 1936
[tcp @ 0x143604f20] Connection attempt to ::1 port 1936 failed: Connection refused
[tcp @ 0x143604f20] Starting connection attempt to 127.0.0.1 port 1936
[tcp @ 0x143604f20] Successfully connected to 127.0.0.1 port 1936
[rtmp @ 0x1437144c0] Handshaking...
[rtmp @ 0x1437144c0] Type answer 3
[rtmp @ 0x1437144c0] Server version 13.14.10.13
[rtmp @ 0x1437144c0] Proto = rtmp, path = /live/test, app = live, fname = test
[rtmp @ 0x1437144c0] Window acknowledgement size = 5000000
[rtmp @ 0x1437144c0] Max sent, unacked = 5000000
[rtmp @ 0x1437144c0] New incoming chunk size = 4096
[rtmp @ 0x1437144c0] Creating stream...
[rtmp @ 0x1437144c0] Sending play command for 'test'
[flv @ 0x143604b30] Format flv probed with size=2048 and score=100
[flv @ 0x143604b30] Before avformat_find_stream_info() pos: 13 bytes read:2263 seeks:0 nb_streams:0
Transform tree:
 mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
 fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
 fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 120, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
 fft4_fwd_float_neon - type: fft_float, len: 4, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_inv_float_c - type: mdct_float, len: 128, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
 fft_sr_ns_float_neon - type: fft_float, len: 64, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 480, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
 fft16_ns_float_neon - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_inv_float_c - type: mdct_float, len: 512, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
 fft_sr_ns_float_neon - type: fft_float, len: 256, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 960, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
 fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_inv_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
 fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
 mdct_fwd_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]
 fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
[NULL @ 0x144124920] nal_unit_type: 7(SPS), nal_ref_idc: 3
[NULL @ 0x144124920] Decoding VUI
[NULL @ 0x144124920] nal_unit_type: 8(PPS), nal_ref_idc: 3
[NULL @ 0x144124920] Decoding VUI
[h264 @ 0x144124920] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x144124920] Decoding VUI
[h264 @ 0x144124920] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x144124920] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x144124920] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x144124920] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x144124920] Decoding VUI
[h264 @ 0x144124920] Format yuv420p chosen by get_format().
[h264 @ 0x144124920] Reinit context to 1280x720, pix_fmt: yuv420p
[h264 @ 0x144124920] no picture 
[flv @ 0x143604b30] All info found
[flv @ 0x143604b30] rfps: 29.666667 0.016552
[flv @ 0x143604b30] rfps: 29.750000 0.009347
[flv @ 0x143604b30] rfps: 29.750000 0.009347
[flv @ 0x143604b30] rfps: 29.833333 0.004197
[flv @ 0x143604b30] rfps: 29.916667 0.001104
[flv @ 0x143604b30] rfps: 29.916667 0.001104
[flv @ 0x143604b30] rfps: 30.000000 0.000067
[flv @ 0x143604b30] rfps: 30.000000 0.000067
[flv @ 0x143604b30] rfps: 60.000000 0.000270
[flv @ 0x143604b30] rfps: 60.000000 0.000270
[flv @ 0x143604b30] rfps: 120.000000 0.001079
[flv @ 0x143604b30] rfps: 120.000000 0.001079
[flv @ 0x143604b30] rfps: 240.000000 0.004316
[flv @ 0x143604b30] rfps: 240.000000 0.004316
[flv @ 0x143604b30] rfps: 29.970030 0.000204
[flv @ 0x143604b30] rfps: 29.970030 0.000204
[flv @ 0x143604b30] rfps: 59.940060 0.000814
[flv @ 0x143604b30] rfps: 59.940060 0.000814
[flv @ 0x143604b30] After avformat_find_stream_info() pos: 496783 bytes read:496783 seeks:0 frames:179
Input #0, flv, from 'rtmp://localhost:1936/live/test':
 Metadata:
 |RtmpSampleAccess: true
 Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
 displayWidth : 1280
 displayHeight : 720
 fps : 30
 profile : 
 level : 
 Duration: 00:00:00.00, start: 6.742000, bitrate: N/A
 Stream #0:0, 138, 1/1000: Audio: aac (LC), 48000 Hz, stereo, fltp, 163 kb/s
 Stream #0:1, 41, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(tv, bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 0/1, 2560 kb/s, 30 fps, 30 tbr, 1k tbn
Successfully opened the file.
Parsing a group of options: output url ./output/test/1080p/stream.mpd.
Applying option c:v (select encoder/decoder ('copy' to copy stream without reencoding)) with argument libx264.
Applying option s (set frame size (WxH or abbreviation)) with argument 1920x1080.
Applying option f (force container format (auto-detected otherwise)) with argument dash.
Successfully parsed a group of options.
Opening an output file: ./output/test/1080p/stream.mpd.
[out#0/dash @ 0x123707480] No explicit maps, mapping streams automatically...
[vost#0:0/libx264 @ 0x123707d60] Created video stream from input stream 0:1
detected 10 logical cores
[h264 @ 0x123607b70] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x123607b70] Decoding VUI
[h264 @ 0x123607b70] nal_unit_type: 8(PPS), nal_ref_idc: 3
[aost#0:1/aac @ 0x144028080] Created audio stream from input stream 0:0
Transform tree:
 mdct_inv_float_c - type: md

<it simply="simply" starts="starts" working="working">
</it></same>


I am not sure if there is something to do with Permissions.