
Recherche avancée
Médias (1)
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (52)
-
Submit bugs and patches
13 avril 2011Unfortunately 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 (...) -
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...) -
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...)
Sur d’autres sites (11485)
-
Discord FFMPEG audio wont play from yt-dlp
19 mars 2023, par user21236822My question is this : Why isn't my bot playing audio ?


I want the bot to join, play audio from queue, then disconnect without downloading an mp3 file.


I tried using youtube-dl, but I switched to the yt-dlp library after getting errors I couldn't fix.
I am running on Windows 10 locally. All my libraries are up to date.


Here are my ydl_opts and FFMPEG_OPTS :


ydl_opts = {
 'format': 'bestaudio/best',
 'postprocessors': [{
 'key': 'FFmpegExtractAudio',
 'preferredcodec': 'mp3',
 'preferredquality': '192',
 }],
}

FFMPEG_OPTIONS = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
 'options': '-vn'
} 



Here is where I believe the problem is.


async def play():
 print("Play Called")
 musicPlay()
 # Get message object from initial request
 message = ytLinkQue.get()
 print(f"Message object recieved: {message}")
 voiceChannel = message.author.voice.channel
 vc = await voiceChannel.connect()
 songsPlayed = 0
 
 while not ytLinkQue.empty():
 # Get current song
 currentSong = ytLinkQue.get()[0]
 print(f"Current song: {currentSong}")

 # Get song from Youtube
 with yt_dlp.YoutubeDL(ydl_opts) as ydl:
 # song = ydl.download(currentSong)
 info = ydl.extract_info(currentSong, download=False)
 song = info['formats'][0]['url']

 # Play Song
 vc.play(discord.FFmpegPCMAudio(song, **FFMPEG_OPTIONS), after=lambda e: print('Song done'))

 # Wait until the song has finished playing
 while vc.is_playing():
 print("playing rn")
 await asyncio.sleep(1)
 
 await vc.disconnect()
 musicStop()



When play() is called, here is the output in terminal with my annotations as **** text **** :


>python main.py
2023-02-17 15:21:09 INFO discord.client logging in using static token
2023-02-17 15:21:10 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: 60b9fce14faa5daa4aed9eb6db01a74d).
Max que: 50
Text Channel: 828698708123451434
Testing Bot#4591 is ready.
Passing message object
**** play() funciton is called ****
Play Called
Message object recieved: <message channel="<TextChannel" position="7" nsfw="False" news="False"> type= author=<member discriminator="'0199'" bot="False" nick="'Fragnk7?'" guild="<Guild" chunked="True">> flags=<messageflags value="0">>
2023-02-17 15:21:16 INFO discord.voice_client Connecting to voice...
2023-02-17 15:21:16 INFO discord.voice_client Starting voice handshake... (connection attempt 1)
2023-02-17 15:21:17 INFO discord.voice_client Voice handshake complete. Endpoint found seattle2004.discord.media
Current song: https://www.youtube.com/watch?v=vcAp4nmTZCA
[youtube] Extracting URL: https://www.youtube.com/watch?v=vcAp4nmTZCA 
[youtube] vcAp4nmTZCA: Downloading webpage 
[youtube] vcAp4nmTZCA: Downloading android player API JSON 
**** Does not play any audio ****
Playing rn
Song done
2023-02-17 15:21:18 INFO discord.player ffmpeg process 20700 successfully terminated with return code of 1.
2023-02-17 15:21:19 INFO discord.voice_client The voice handshake is being terminated for Channel ID 400178308467392513 (Guild ID 261601676941721602)
2023-02-17 15:21:19 INFO discord.voice_client Disconnecting from voice normally, close code 1000.
</messageflags></member></message>


On Discord's end, the bot successfully connects then disconnects after 2 second.


Note : I've only included code I think is relevant. Please let me know if I should add anything else to the post, otherwise, here is the github for the project. Code is in main.py.
https://github.com/LukeLeimbach/wallMomentMusic


Thank you in advance !


I've applied the advice from these posts but it still will not play audio :


-
https://stackoverflow.com/questions/45770016/how-do-i-make-my-discord-bot-play-audio-from-youtube


-
https://stackoverflow.com/questions/66070749/how-to-fix-discord-music-bot-that-stops-playing-before-the-song-is-actually-over?newreg=c70dd786cf5844e490045494223c0381


-
https://stackoverflow.com/questions/57688808/playing-music-with-a-bot-from-youtube-without-downloading-the-file


-
raw images to mp4 video with ffmpeg or cv2 fails with most codecs
21 février 2023, par Hi_its_meI have a couple of numpy image frames (
np.uint8
, 4 in total) and want to create a mp4 file. So far so easy, it works fine with the mpv4 codec. But that codec compresses the files too much so that a lot of visual quality gets lost. So I tried a thousand of different codecs (h264, h265, av1, vp9 and others) and also other data formats (.mkv, .avi). I tried it with cv2.VideoWriter, skvideo.io.FFmpegWriter and ffmpeg-python. but no matter what I do, the video is either completely or only partially corrupted (approx the last quater of frames).
I use VLC media player to check the files. I don't understand what's going on here. I don't get any error messages. Strangely, sometimes, windows standard video player is able to read the video. So the frames are not always completely corrupted.

The skvideo code :


def to_lossless_mp4(img_list: np.array, target_path):
 height, width, _ = img_list[0].shape
 writer = skvideo.io.FFmpegWriter(target_path,
 inputdict={
 '-framerate': str(FPS),
 '-f': 'rawvideo',
 '-s': '{}x{}'.format(width, height)
 },
 outputdict={
 '-vcodec': 'libx265', # h.264 codec
 '-crf': '0', 
 '-preset': 'veryslow', # the slower the better compression
 '-framerate': str(FPS),
 })
 for i, image in enumerate(img_list):
 # some images are grayscale, since all frames need to be same size I do this:
 if len(image.shape) < 3:
 image = np.stack([image] * 3, axis=2)

 image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
 writer.writeFrame(image)
 writer.close()



the cv2 code :


def to_mp4(img_list: np.array, target_path):
 height, width, _ = img_list[0].shape
 if OVERRIDE or not os.path.exists(target_path):
 out = cv2.VideoWriter(target_path, cv2.VideoWriter_fourcc(*'x265'), FPS, (width, height))

 for image in img_list:
 if len(image.shape) < 3:
 image = np.stack([image] * 3, axis=2)
 image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
 out.write(image)
 out.release()



the ffmpeg-python code :


def to_mp4(fn, images, framerate=1, vcodec='libx264'):
 if not isinstance(images, np.ndarray):
 images = np.asarray(images)
 n, height, width, channels = images.shape
 process = (
 ffmpeg
 .input('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(width, height))
 .output(fn, pix_fmt='yuv420p', vcodec=vcodec, r=framerate)
 .run_async(pipe_stdin=True)
 .overwrite_output()
 )
 for frame in images:
 if len(frame.shape) < 3:
 frame = np.stack([frame] * 3, axis=2)
 process.write(
 frame
 .astype(np.uint8)
 .tobytes()
 )
 process.stdin.close()
 process.wait()



edit : this is the output when I use the code proposed by Rotem :


[00:00<?, ?it/s]ffmpeg version 2.7 Copyright (c) 2000-2015 the FFmpeg developers
 built with gcc 4.9.2 (GCC)
 configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
 libavutil 54. 27.100 / 54. 27.100
 libavcodec 56. 41.100 / 56. 41.100
 libavformat 56. 36.100 / 56. 36.100
 libavdevice 56. 4.100 / 56. 4.100
 libavfilter 5. 16.101 / 5. 16.101
 libswscale 3. 1.101 / 3. 1.101
 libswresample 1. 2.100 / 1. 2.100
 libpostproc 53. 3.100 / 53. 3.100
[rawvideo @ 00000000051767c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, rawvideo, from 'pipe:':
 Duration: N/A, start: 0.000000, bitrate: 75497 kb/s
 Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 2048x1536, 75497 kb/s, 1 tbr, 1 tbn, 1 tbc
x265 [info]: HEVC encoder version 1.7
x265 [info]: build info [Windows][GCC 4.9.2][64 bit] 8bpp
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x265 [info]: Main profile, Level-5 (Main tier)
x265 [info]: Thread pool created using 16 threads
x265 [info]: frame threads / pool features : 5 / wpp(24 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut : 1 / 250 / 40
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb / refs: 1 / 1 / 0 / 3
x265 [info]: AQ: mode / str / qg-size / cu-tree : 1 / 1.0 / 64 / 1
x265 [info]: Rate Control / qCompress : CRF-24.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=0.30 signhide tmvp strong-intra-smoothing
x265 [info]: tools: deblock sao
Output #0, mp4, to 'C:datamerged_datatestsubsubsub2022-10-12_11-03-44_3583968045500ns_io.mp4':
 Metadata:
 encoder : Lavf56.36.100
 Stream #0:0: Video: hevc (libx265) ([35][0][0][0] / 0x0023), yuv420p, 2048x1536, q=2-31, 1 fps, 16384 tbn, 1 tbc
 Metadata:
 encoder : Lavc56.41.100 libx265
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
frame= 4 fps=0.0 q=0.0 Lsize= 761kB time=00:00:02.00 bitrate=3117.4kbits/s 
video:759kB audio:0kB subtitle:0kB other streams:0kB global headers:1kB muxing overhead: 0.236524%
x265 [info]: frame I: 2, Avg QP:13.55 kb/s: 2078.50 
x265 [info]: frame P: 1, Avg QP:15.08 kb/s: 1560.14 
x265 [info]: frame B: 1, Avg QP:18.28 kb/s: 502.67 
x265 [info]: global : 4, Avg QP:15.11 kb/s: 1554.95 
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 66.7% 33.3% 0.0% 0.0% 0.0% 



-
How to change `yuv420p(progressive)` to `yuv420p(tv, progressive)` ?
8 mars 2023, par RoyI have a video
in.mp4
:

Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 375 kb/s, 30 fps, 30 tbr, 15360 tbn (default)



I want to convert it into the following spec (need to change the time-base and also add an empty audio) :


Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 20744 kb/s, 30 fps, 30 tbr, 30k tbn (default)
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)



Currently I'm using this
ffmpeg
command :

ffmpeg -f lavfi -i anullsrc -i in.mp4 -c:v libx264 -pix_fmt yuv420p -profile:v main -video_track_timescale 30k -c:a aac -map 0:a -map 1:v -shortest out.mp4



The output
out.mp4


Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
Stream #0:1[0x2](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 27 kb/s, 30 fps, 30 tbr, 30k tbn (default)



As you can see, the output audio stream matches what I wanted. But the output video stream is missing the "tv" part in the "yuv420p(tv, progressive)" spec.


How do I add back the "tv" part in the "yuv420p(tv, progressive)" spec ?


My misc assumptions :


- 

- In the output, the order of audio and video stream are changed. I assume that doesn't matter.
- In the input and the output, the bit-rate for both audio and video are change, but I assume it's okay because h264 and aac are not fixed bit-rate (I hope ?).