
Recherche avancée
Autres articles (16)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Gestion générale des documents
13 mai 2011, parMédiaSPIP ne modifie jamais le document original mis en ligne.
Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...) -
Les vidéos
21 avril 2011, parComme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)
Sur d’autres sites (2569)
-
The problem with pydub.AudioSegment.from_file (ffmpeg)
7 septembre 2024, par akkooldaI'm trying to make a normal voice recording discord. When I try to convert an Audio Data object, an error occurs. I've already tried everything I can, I can't solve the problem.


Here is the code, the error occurs in the seg variable :


async def once_done(sink: discord.sinks.MP3Sink, channel: discord.TextChannel, *args):
 words_list = []
 audio_segs: list[pydub.AudioSegment] = []
 longest = pydub.AudioSegment.empty()
 files: list[discord.File] = []

 for user_id, audio in sink.audio_data.items():
 try:
 payload: FileSource = {
 "buffer": audio.file.read(),
 "mimetype": "audio/mp3" # Указываем тип аудиофайла
 }

 #audio.on_format("mp3")
 seg = pydub.AudioSegment.from_file(audio.file, format="mp3")



The error itself


Exception in thread Thread-3 (recv_audio):
 Traceback (most recent call last):
 File "c:\Users\olimp\OneDrive\Рабочий стол\Work on Python\management-followups-bot\main.py", line 66, in once_done
 seg = pydub.AudioSegment.from_file(audio.file, format="mp3")
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydub\audio_segment.py", line 773, in from_file
 raise CouldntDecodeError(
 pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 3199971767
 
 Output from ffmpeg/avlib:
 
 ffmpeg version 2024-09-02-git-3f9ca51015-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
 built with gcc 13.2.0 (Rev5, 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-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
 libavutil 59. 35.100 / 59. 35.100
 libavcodec 61. 11.100 / 61. 11.100
 libavformat 61. 5.101 / 61. 5.101
 libavdevice 61. 2.100 / 61. 2.100
 libavfilter 10. 2.102 / 10. 2.102
 libswscale 8. 2.100 / 8. 2.100
 libswresample 5. 2.100 / 5. 2.100
 libpostproc 58. 2.100 / 58. 2.100
 [cache @ 000001b25c1c6e00] Inner protocol failed to seekback end : -40
 Last message repeated 1 times
 [mp3 @ 000001b25c1c6840] Failed to find two consecutive MPEG audio frames.
 [cache @ 000001b25c1c6e00] Statistics, cache hits:0 cache misses:0
 [in#0 @ 000001b25c1ac740] Error opening input: Invalid data found when processing input
 Error opening input file cache:pipe:0.
 Error opening input files: Invalid data found when processing input
 
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
 self.run()
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run
 self._target(*self._args, **self._kwargs)
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\voice_client.py", line 868, in recv_audio
 result = callback.result()
 ^^^^^^^^^^^^^^^^^
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 456, in result
 return self.__get_result()
 ^^^^^^^^^^^^^^^^^^^
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 401, in __get_result
 raise self._exception
 File "c:\Users\olimp\OneDrive\Рабочий стол\Work on Python\management-followups-bot\main.py", line 95, in once_done
 await channel.send(f"Ошибка при работе с Deepgram API: {str(e)}")
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\abc.py", line 1666, in send
 data = await state.http.send_message(
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\olimp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 374, in request
 raise HTTPException(response, data)
 discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
 In content: Must be 2000 or fewer in length.

Solving the error, how else can you normally record user audio



How can I fix this, or maybe there are some other options ?


-
Understanding User Flow : Eight Practical Examples for Better UX
4 octobre 2024, par Daniel Crough — Analytics Tips, UX -
When I use ffmpeg to go from a video to frames, and then back to video, the duration is different between the videos
24 février 2024, par bluepandaI am trying to use
ffmpeg
to convert from a .mp4 (or .mov) video into individual frames, do some processing on those frames, and then convert back to .mp4. The problem is that the resulting video I create is a different duration than the input - I can see this visually when I play the two videos side by side. The difference is not large (i.e.00:00:00.50
for the input video and00:00:00.52
for the output video), but when the videos are looped next to each other they get out of sync.

Here is information about the input video retrieved using
fluent-ffmpeg
'sffmpeg.ffprobe(videoPath)
:

metadata {
 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: 1080,
 height: 1920,
 coded_width: 1080,
 coded_height: 1920,
 closed_captions: 0,
 has_b_frames: 2,
 sample_aspect_ratio: 'N/A',
 display_aspect_ratio: 'N/A',
 pix_fmt: 'yuv420p',
 level: 40,
 color_range: 'tv',
 color_space: 'bt709',
 color_transfer: 'bt709',
 color_primaries: 'bt709',
 chroma_location: 'left',
 field_order: 'unknown',
 refs: 1,
 is_avc: 'true',
 nal_length_size: 4,
 id: 'N/A',
 r_frame_rate: '30000/1001',
 avg_frame_rate: '27000/1001',
 time_base: '1/30000',
 start_pts: 0,
 start_time: 0,
 duration_ts: 15100,
 duration: 0.503333,
 bit_rate: 5660223,
 max_bit_rate: 'N/A',
 bits_per_raw_sample: 8,
 nb_frames: 36,
 nb_read_frames: 'N/A',
 nb_read_packets: 'N/A',
 tags: [Object],
 disposition: [Object]
 },
 {
 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,
 id: 'N/A',
 r_frame_rate: '0/0',
 avg_frame_rate: '0/0',
 time_base: '1/48000',
 start_pts: 0,
 start_time: 0,
 duration_ts: 24160,
 duration: 0.503333,
 bit_rate: 248416,
 max_bit_rate: 'N/A',
 bits_per_raw_sample: 'N/A',
 nb_frames: 27,
 nb_read_frames: 'N/A',
 nb_read_packets: 'N/A',
 tags: [Object],
 disposition: [Object]
 }
 ],
 format: {
 filename: '/Users/name/images/input.mp4',
 nb_streams: 2,
 nb_programs: 0,
 format_name: 'mov,mp4,m4a,3gp,3g2,mj2',
 format_long_name: 'QuickTime / MOV',
 start_time: 0,
 duration: 0.503333,
 size: 963879,
 bit_rate: 15319941,
 probe_score: 100,
 tags: {
 major_brand: 'mp42',
 minor_version: '1',
 compatible_brands: 'isommp41mp42',
 creation_time: '2024-02-14T01:21:12.000000Z'
 }
 },
 chapters: []
}



and here is from running
ffprobe
directly :

ffprobe '/Users/name/images/input.mp4'
ffprobe version 6.1.1 Copyright (c) 2007-2023 the FFmpeg developers
 built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
 configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.1_2 --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-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
 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 '/Users/name/images/input.mp4':
 Metadata:
 major_brand : mp42
 minor_version : 1
 compatible_brands: isommp41mp42
 creation_time : 2024-02-14T01:21:12.000000Z
 Duration: 00:00:00.50, start: 0.000000, bitrate: 15319 kb/s
 Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x1920, 5660 kb/s, 26.97 fps, 29.97 tbr, 30k tbn (default)
 Metadata:
 creation_time : 2024-02-14T01:21:12.000000Z
 handler_name : Core Media Video
 vendor_id : [0][0][0][0]
 encoder : AVC Coding
 Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 248 kb/s (default)
 Metadata:
 creation_time : 2024-02-14T01:21:12.000000Z
 handler_name : Core Media Audio
 vendor_id : [0][0][0][0]



And this is my command to go from video to frames :


ffmpeg -i /Users/name/images/input.mp4 -y -f image2 /Users/name/images/frames/%d.png



After which I convert the frames back to video with this - note that I get by seeing
avg_frame_rate
is27000/1001 = 26.97302697
:

ffmpeg -r 26.973026973026972 -i /Users/name/images/frames/%d.png -y -r 26.973026973026972 -b:v 5660223k -f mp4 -pix_fmt yuv420p -t 0.503333 /Users/name/images/output.mp4



And if I then run
fluent-ffmpeg
'sffmpeg.ffprobe(videoPath)
I get :

metadata {
 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: 1080,
 height: 1920,
 coded_width: 1080,
 coded_height: 1920,
 closed_captions: 0,
 has_b_frames: 2,
 sample_aspect_ratio: '1:1',
 display_aspect_ratio: '9:16',
 pix_fmt: 'yuv420p',
 level: 62,
 color_range: 'unknown',
 color_space: 'unknown',
 color_transfer: 'unknown',
 color_primaries: 'unknown',
 chroma_location: 'left',
 field_order: 'unknown',
 refs: 1,
 is_avc: 'true',
 nal_length_size: 4,
 id: 'N/A',
 r_frame_rate: '27000/1001',
 avg_frame_rate: '27000/1001',
 time_base: '1/27000',
 start_pts: 0,
 start_time: 0,
 duration_ts: 14014,
 duration: 0.519037,
 bit_rate: 52138429,
 max_bit_rate: 'N/A',
 bits_per_raw_sample: 8,
 nb_frames: 14,
 nb_read_frames: 'N/A',
 nb_read_packets: 'N/A',
 tags: [Object],
 disposition: [Object]
 }
 ],
 format: {
 filename: '/Users/name/images/output.mp4',
 nb_streams: 1,
 nb_programs: 0,
 format_name: 'mov,mp4,m4a,3gp,3g2,mj2',
 format_long_name: 'QuickTime / MOV',
 start_time: 0,
 duration: 0.52,
 size: 3383708,
 bit_rate: 52057046,
 probe_score: 100,
 tags: {
 major_brand: 'isom',
 minor_version: '512',
 compatible_brands: 'isomiso2avc1mp41',
 encoder: 'Lavf60.3.100'
 }
 },
 chapters: []
}



and here is from running
ffprobe
directly :

ffprobe '/Users/name/images/output.mp4'
ffprobe version 6.1.1 Copyright (c) 2007-2023 the FFmpeg developers
 built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
 configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.1_2 --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-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
 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 '/Users/name/images/output.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf60.3.100
 Duration: 00:00:00.52, start: 0.000000, bitrate: 52153 kb/s
 Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1920 [SAR 1:1 DAR 9:16], 52138 kb/s, 26.97 fps, 26.97 tbr, 27k tbn (default)
 Metadata:
 handler_name : VideoHandler
 vendor_id : [0][0][0][0]
 encoder : Lavc60.3.100 libx264



This seems like it should be a fairly common scenario, but I have not been able to find examples of this, and the other questions about incorrect durations on Stack Overflow are about bigger differences (i.e. 3 seconds instead of 10 seconds : Wrong video duration when recording with ffmpeg).


Some other details :


- 

- I am running this through a Node.js script with
fluent-ffmpeg
, but I have also tried running the commands directly in the terminal and the result is the same. - I am fine with the output frames being .png / .jpg / other formats.
- I am fine with setting this to a different frame rate than the original as long as the two output videos end up with the same duration.
- One suspicious thing is that I set
-t 0.503333
when creating the video, but it doesn't seem to work as the result video showsduration: 0.519037
/00:00:00.52
.










Thank you for any help !


- I am running this through a Node.js script with