
Recherche avancée
Médias (1)
-
The pirate bay depuis la Belgique
1er avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (55)
-
Participer à sa traduction
10 avril 2011Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
Actuellement MediaSPIP n’est disponible qu’en français et (...) -
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 -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
Sur d’autres sites (7981)
-
How would I go about packaging an mp3 file into an mp4 container ?
22 novembre 2020, par JacobSo here's the issue that I'm currently having. I need an audio player for iOS that will play mp3. Now at first glance this may seem like a trivial issue, just create an
audio
tag and give it the URL to the mp3 file. While this technically works, it's basically unusable since iOS needs to download the entire file before starting to play it. This results in a really long wait time when trying to play large mp3 files (could get close to a minute).
So the first thing I tried was to manually mimic the chunking that chrome does for playing mp3 files. I first sent aHEAD
request to get the byte length of the audio file. Used that length / duration in seconds to get the average bytes per second and use that data to request chunks based on where the user seeks to. That didn't work since sometimes mp3 files contain metadata that throw off the calculation (like a cover image). Additionally, sometimes mp3 files use VBR (Variable Bit Rate) and then I'm well and truly screwed.


So this lead me to thinking, Safari couldn't possibly require the end user to download an entire mp4 file before playing it. So I took an mp3 file, converted it to mp4 on an online converter and tested my theory out. Voila, it worked. Safari was streaming the mp4 file in chunks and the wait time went to close to 0. Alright, so now all I need to do is convert mp3 files to mp4 files. The problem now is, I have requirement not to use my server for converting these files. I want to offload this expensive operation to the client. After looking around for a bit I found a few
wasm
libraries to do this, great ! Nope. Thesewasm
libraries are huge (24 MB) and would add an unacceptable amount to my already large bundles files. So this brings me to my question. Is there any way to "trick" safari into thinking that my mp3 file is mp4. What I've tried already :


On input change event -> get the file -> clone it into a new Blob with a mimeType of
video/mp4
and then upload that file to the server. Chrome plays this file no problem (probably because it detects it's an mp3 file), on Safari however it's unable to play the file.


So my question is, is there any way to package the mp3 file in an mp4 container (Client Side !important) to "force" Safari into chunking the file.


-
Trouble downloading a youtube playlist and converting to mp4 with audio/video
15 mars 2024, par Patrick CooganI am having difficulty with a side project I am working on. The goal of the program is to be able to do a few functions with a youtube video or playlist link.


- 

- download a youtube video and audio and merge them.
- download a youtube playlist's video and audio and merge them.
- download a youtube video's audio only.
- download a youtube playlist's audio only.










My main issues arise with the 2. function, downloading a playlist with video and audio and merging them. The program is able to complete function 1 successfully (download a video and audio and merge to one file), and function 3 successfully (download video and output just audio file) Function 4 hasn't been implemented at all yet.


The program is broken into 2 main files : youtube_downloader.py and main.py
The errors I receive from output of running function 2 are listed after the code below


I am hoping for some clarification on what the errors are describing any advice on implementing the second function outlined in comments below.


main.py


from youtube_downloader import download_playlist,input_links,download_video,convert_to_mp3,convert_to_mp4
from moviepy.editor import VideoFileClip, AudioFileClip, concatenate_videoclips
import os


print("Load Complete\n")

print('''
What would you like to do?
(1) Download a YouTube video and audio
(2) Download a YouTube Playlist (video and audio)
(3) Download a YouTube Video's audio only
(4) Download a Youtube Playlist's audio only
(q) Quit
''')

done = False

while done == False:
 #ask user for choice
 choice = input("Choice: ")
 if choice == "1" or choice == "2":
 # Sets Quality Option of video(s)
 quality = input("Please choose a quality (low or 0, medium or 1, high or 2, very high or 3):")
 #download videos manually
 if choice == "1":
 links = input_links()
 print('Download has been started')
 for link in links: 
 filename = download_video(link, quality)
 convert_to_mp4(filename)
 print("Download finished!")
 #download a playlist
 if choice == "2":
 link = input("Enter the link to the playlist: ")
 print("Downloading playlist...")
 filenames = download_playlist(link, quality)
 print("Download finished! Beginning conversion...")
 **#################################################################
 for file in os.listdir('./Downloaded/'):
 convert_to_mp4(filenames)
 #################################################################**
 print("Conversion finished!")
 elif choice == "3":
 links = input_links()
 for link in links:
 print("Downloading...")
 filename = download_video(link, 'low')
 print("Converting...")
 convert_to_mp3(filename)
 os.remove(filename)
 elif choice == "4":
 pass
 #TODO: add option 4 code
 elif choice == "q" or choice == "Q":
 done = True
 print("Goodbye")
 else:
 print("Invalid input!")



youtube_downloader.py


import pytube
from pytube import YouTube, Playlist
from pytube.cli import on_progress
from moviepy.editor import VideoFileClip, AudioFileClip
import os

"""
Downloads video to a 'Downloaded' folder in the same dir as the program.

"""

def download_video(url, resolution):
 itag = choose_resolution(resolution)
 video = YouTube(url,on_progress_callback=on_progress)
 stream = video.streams.get_by_itag(itag)
 try:
 os.mkdir('./Downloaded/')
 except:
 pass
 stream.download(output_path='./Downloaded/')
 return f'./Downloaded/{stream.default_filename}'

def download_videos(urls, resolution):
 for url in urls:
 download_video(url, resolution)

def download_playlist(url, resolution):
 playlist = Playlist(url)
 download_videos(playlist.video_urls, resolution)

def choose_resolution(resolution):
 if resolution in ["low", "360", "360p","0"]:
 itag = 18
 elif resolution in ["medium", "720", "720p", "hd","1"]:
 itag = 22
 elif resolution in ["high", "1080", "1080p", "fullhd", "full_hd", "full hd","2"]:
 itag = 137
 elif resolution in ["very high", "2160", "2160p", "4K", "4k","3"]:
 itag = 313
 else:
 itag = 18
 return itag


def input_links():
 print("Enter the links of the videos (end by entering 'stop' or 0):")

 links = []
 link = ""

 while link != "0" and link.lower() != "stop":
 link = input("video_url or \"stop\": ")
 links.append(link)
 
 if len(links)==1:
 print("No links were inputed")
 exit()

 links.pop()

 return links

def convert_to_mp3(filename):
 clip = VideoFileClip(filename)
 clip.audio.write_audiofile(filename[:-3] + "mp3")
 clip.close()

def convert_to_mp4(filename):
 video_clip = VideoFileClip(filename)
 audio_clip = AudioFileClip(filename)
 final_clip = video_clip.set_audio(audio_clip)
 final_clip.write_videofile(filename[:-3] + "mp4")
 final_clip.close()



Error output


Traceback (most recent call last):
 File "C:\Users\ptcoo\Documents\youtube-downloader-converter\main.py", line 44, in <module>
 convert_to_mp4(filenames)
 File "C:\Users\ptcoo\Documents\youtube-downloader-converter\youtube_downloader.py", line 69, in convert_to_mp4
 video_clip = VideoFileClip(filename)
 ^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\ptcoo\AppData\Roaming\Python\Python312\site-packages\moviepy\video\io\VideoFileClip.py", line 88, in __init__
 self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\ptcoo\AppData\Roaming\Python\Python312\site-packages\moviepy\video\io\ffmpeg_reader.py", line 35, in __init__
 infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\ptcoo\AppData\Roaming\Python\Python312\site-packages\moviepy\video\io\ffmpeg_reader.py", line 244, in ffmpeg_parse_infos
 is_GIF = filename.endswith('.gif')
 ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'endswith'
</module>


-
how to send audio or video by packet though udp
20 janvier 2019, par Wei Wenhow to send part of video and audio from mp4 as packet though udp from server
Client will play the part of packet resevice.import java.awt.Dimension ; import java.awt.image.BufferedImage ; import
java.io.ByteArrayOutputStream ; import java.io.IOException ; import
java.io.ObjectOutputStream ; import java.math.BigInteger ; import
java.net.DatagramPacket ; import java.net.DatagramSocket ; import
java.net.ServerSocket ; import java.net.Socket ; import
java.nio.ByteBuffer ; import java.nio.ShortBuffer ; import
java.util.ArrayList ; import java.util.Arrays ; import
javax.imageio.ImageIO ; import javax.sound.sampled.AudioFileFormat ;
import javax.sound.sampled.AudioFormat ; import javax.swing.JTextArea ;import org.bytedeco.javacv.FFmpegFrameGrabber ; import
org.bytedeco.javacv.Frame ; import
org.bytedeco.javacv.Java2DFrameConverter ;import Enum.EType.ClientState ; import View.SingleDisplayWindow ;
import java.security.InvalidKeyException ; import
java.security.NoSuchAlgorithmException ; import java.util.Timer ; import
java.util.TimerTask ; import java.util.concurrent.CountDownLatch ;
import java.util.concurrent.ExecutionException ;import javax.crypto.BadPaddingException ; import
javax.crypto.IllegalBlockSizeException ; import
javax.crypto.NoSuchPaddingException ; import
org.bytedeco.javacv.FrameGrabber ;public class SCon private final static int PORT = 8888 ;
private final JTextArea TEXT_AREA ; private volatile
SingleDisplayWindow DISPLAY ; /////private final String BD_USER_NAME, DB_PASSWORD ; private Database
database ;private boolean isRunning ;
private RSA serverRSA, clientRSA ;
private int keyIndex, typeID = 0 ; private String mediatype = "" ;
private ArrayList sHandlers ;private FileStreamingThread fileStreamingThread ; private
VideoStreamingThread videoStreamingThread ; private BroadcastThread
broadcastThread ; private ConnectThread connectThread ;private volatile static byte[] currentVideoFrame = new byte[0],
currentAudioFrame = new byte[0] ; // current image musicpublic void run() startServer() ;
isRunning = true; fileStreamingThread = new
FileStreamingThread(videoFile) ; videoStreamingThread = new
VideoStreamingThread(videoFile) ;
//CountDownLatch latch = new CountDownLatch(1) ; fileStreamingThread.start() ; videoStreamingThread.start() ;
//latch.countDown() ;broadcastThread = new BroadcastThread(); broadcastThread.start();
connectThread = new ConnectThread(); connectThread.start(); }public void stop() isRunning = false ;
try { new Socket("localhost", PORT);
} catch (IOException e) { e.printStackTrace(); }
while (fileStreamingThread.isAlive()) {
}
while (broadcastThread.isAlive()) {
}
while (connectThread.isAlive()) {
}
for (SHandler sHandler : sHandlers) { sHandler.connectionClose();
} sHandlers.clear(); DISPLAY.dispose();
TEXT_AREA.append("\nServer stop\n"); }
private class VideoStreamingThread extends Thread { privateFFmpegFrameGrabber grabber ; // Used to extract frames from video file.
private Java2DFrameConverter converter ; // Used to convert frames to
image private int curIndex ; // Current key indexpublic VideoStreamingThread(String video_file) { videoFile =
videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ;
converter = new Java2DFrameConverter() ; try
grabber.restart() ;} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } curIndex = keyIndex; }
public void run() { try {
while (isRunning) {
curIndex = keyIndex;
Frame frame = null;
System.out.println("v1");
if ((frame = grabber.grab()) != null) { // Grab next frame from video file
if (frame.image != null) { // image frame
BufferedImage bi = converter.convert(frame); // convert frame to image
// Convert BufferedImage to byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", baos);
// Encrypt data and store as the current image of byte[] type
currentVideoFrame = ciphers[curIndex].doFinal(baos.toByteArray());
//////////////////
DISPLAY.setSize(new Dimension(bi.getWidth(), bi.getHeight()));
DISPLAY.updateImage(bi); // Display image
// Thread.sleep((long) ( 999 / grabber.getFrameRate()));
///////////////
typeID = 1;
mediatype = grabber.getFormat();
}
} else {
grabber.restart();
} // Restart when reached end of video
}
grabber.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} //catch (InterruptedException e) {e.printStackTrace(); } }
public synchronized int getCurKeyIndex() { return curIndex; }
public synchronized void getVideoFile(String video_file) {
videoFile = video_file; grabber = newFFmpegFrameGrabber(video_file) ; converter = new
Java2DFrameConverter() ;try {
grabber.release();
grabber.restart();
} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } } } private class FileStreamingThread extends Thread { private FFmpegFrameGrabbergrabber ; // Used to extract frames from video file. private int
curIndex ; // Current key indexpublic FileStreamingThread(String video_file) { videoFile =
videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ; try
grabber.restart() ;} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } curIndex = keyIndex; }
public void run() { try {
while (isRunning) {
curIndex = keyIndex;
Frame frame = null;
System.out.println("a2");
if ((frame = grabber.grabSamples()) != null) { // Grab next frame from video file
if (frame.samples != null) { // audio frame
// Encrypt audio
ShortBuffer channelSamplesShortBuffer = (ShortBuffer) frame.samples[0];
channelSamplesShortBuffer.rewind();
ByteBuffer outBuffer = ByteBuffer.allocate(channelSamplesShortBuffer.capacity() * 2);
for (int i = 0; i < channelSamplesShortBuffer.capacity(); i++) {
short val = channelSamplesShortBuffer.get(i);
outBuffer.putShort(val);
}
AudioFileFormat audiofileFormat = new AudioFileFormat(null, null, typeID);
AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, true);
//System.out.println(grabber.getSampleFormat());
// Encrypt data and store as the current audio of byte[] type
currentAudioFrame = ciphers[curIndex].doFinal(outBuffer.array());
DISPLAY.updateAudio(outBuffer.array(), grabber.getFormat()); // Display image audio
// Thread.sleep((long) (1000 / grabber.getSampleRate()));
// Thread.sleep((long) (1000 / grabber.getAudioBitrate()));
// System.out.println(grabber.getFormat());
// System.out.println("audioInputStream.getFormat() = " +grabber.getFormat()) ; // System.out.println("Sample.length
= " + grabber.length) ; // System.out.println("FrameLength :" + grabber.getFrameLength()) ; //
System.out.println("Frame Size :" + grabber.getFrameSize()) ; //
System.out.println("SampleSizeInBits :" +
grabber.getSampleSizeInBits()) ; //
System.out.println("Frame Rate : " + grabber.getFrameRate()) ; //
System.out.println("Sample Rate :" + grabber.getSampleRate()) ; //
System.out.println("Encoding :" + grabber.getEncoding()) ; //
System.out.println("Channels : " + grabber.getChannels()) ;
// AudioFormat audioFormat = new AudioFormat(grabber.getSampleRate(), grabber.getAudioBitrate(),
grabber.getAudioChannels(), true, true) ;
// DISPLAY.updateAudio(outBuffer.array(), audioFormat) ; //
Display image audio
outBuffer.clear() ;typeID = 2;
mediatype = grabber.getFormat();
}
} else {
grabber.restart();
} // Restart when reached end of video
}
grabber.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} }
public synchronized int getCurKeyIndex() { return curIndex; }
public synchronized void getVideoFile(String video_file) {
videoFile = video_file; grabber = newFFmpegFrameGrabber(video_file) ;
try {
grabber.release();
grabber.restart();
} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } } }public void setVideoFile(String videoFile) this.videoFile =
videoFile ;public void setThreadFile(String video_file)
fileStreamingThread.getVideoFile(video_file) ;
videoStreamingThread.getVideoFile(video_file) ;private class BroadcastThread extends Thread public void run()
while (isRunning)
Thread.yield() ;for (int i = 0; i < sHandlers.size(); i++) {
if (sHandlers.get(i).getClientState() == ClientState.R) {
sHandlers.get(i).setClientState(ClientState.W);
BroadcastWorker workerThread = new BroadcastWorker(sHandlers.get(i));
workerThread.start();
}
} } } }private class BroadcastWorker extends Thread SHandler sHandler =
null ;public BroadcastWorker(SHandler sHandler) { this.sHandler =
sHandler ;
public void run() { try {
DatagramSocket out = new DatagramSocket(); // used to send UDP packets
while (sHandler.getClientState() == ClientState.W) {
Thread.yield();
StreamFile s = new StreamFile(typeID, currentVideoFrame, currentAudioFrame, mediatype);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(outputStream);
os.writeObject(s);
byte[] data = outputStream.toByteArray();
// Create and send UDP packet
DatagramPacket videoPacket = new DatagramPacket(data, data.length,
sHandler.getClientSocket().getInetAddress(),
Integer.parseInt(sHandler.getClientPort()));
out.send(videoPacket);
} } catch (IOException e) {
e.printStackTrace(); } } }private class ConnectThread extends Thread public void run()
TEXT_AREA.append("\nWaiting for clients’ connection.....\n") ;try {
ServerSocket serverSocket = new ServerSocket(PORT);
Socket clientSocket = null;
while (isRunning) {
clientSocket = serverSocket.accept();
if (isRunning) {
SHandler sHandler = new SHandler(clientSocket, serverRSA, clientRSA, sessionKeys[keyIndex],
TEXT_AREA);
sHandler.start();
sHandlers.add(sHandler);
}
}
serverSocket.close();
if (clientSocket != null) {
clientSocket.close();
}
} catch (IOException e) {
e.printStackTrace(); } } } }my audio and image not sync.