
Recherche avancée
Médias (1)
-
DJ Dolores - Oslodum 2004 (includes (cc) sample of “Oslodum” by Gilberto Gil)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (51)
-
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 (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (8842)
-
How to simultaneously capture mic, stream it to RTSP server and play it on iPhone's speaker ?
24 août 2021, par Norbert TowiańskiI want to capture sound from mic, stream it to RTSP server and play it simultaneously on iPhone's speaker after getting samples from RTSP server. I mean such kind of loop. I use FFMPEGKit and I want to use MobileVLCKit, but unfortunately microphone is off when I start play stream.
I think I've done first step (capturing from microphone and send OutputStream to RTSP server) :


@IBAction func transmitBtnPressed(_ sender: Any) {
 ffmpeg_transmit()
}

@IBAction func recordBtnPressed(_ sender: Any) {
 switch recordingState {
 case .idle:
 recordingState = .start
 startRecording()
 recordBtn.setTitle("Started", for: .normal)
 let urlToFile = URL(fileURLWithPath: outPipePath!)
 outputStream = OutputStream(url: urlToFile, append: false)
 outputStream!.open()
 case .capturing:
 recordingState = .end
 stopRecording()
 recordBtn.setTitle("End", for: .normal)
 default:
 break
 }
}

override func viewDidLoad() {
 super.viewDidLoad()
 outPipePath = FFmpegKitConfig.registerNewFFmpegPipe()
 self.setup()
}

override func viewDidAppear(_ animated: Bool) {
 super.viewDidAppear(animated)
 setUpAuthStatus()
}

func setUpAuthStatus() {
 if AVCaptureDevice.authorizationStatus(for: AVMediaType.audio) != .authorized {
 AVCaptureDevice.requestAccess(for: AVMediaType.audio, completionHandler: { (authorized) in
 DispatchQueue.main.async {
 if authorized {
 self.setup()
 }
 }
 })
 }
}

func setup() {
 self.session.sessionPreset = AVCaptureSession.Preset.high
 
 self.recordingURL = URL(fileURLWithPath: "\(NSTemporaryDirectory() as String)/file.m4a")
 if self.fileManager.isDeletableFile(atPath: self.recordingURL!.path) {
 _ = try? self.fileManager.removeItem(atPath: self.recordingURL!.path)
 }
 
 self.assetWriter = try? AVAssetWriter(outputURL: self.recordingURL!,
 fileType: AVFileType.m4a)
 self.assetWriter!.movieFragmentInterval = CMTime.invalid
 self.assetWriter!.shouldOptimizeForNetworkUse = true
 
 let audioSettings = [
 AVFormatIDKey: kAudioFormatLinearPCM,
 AVSampleRateKey: 48000.0,
 AVNumberOfChannelsKey: 1,
 AVLinearPCMIsFloatKey: false,
 AVLinearPCMBitDepthKey: 16,
 AVLinearPCMIsBigEndianKey: false,
 AVLinearPCMIsNonInterleaved: false,
 
 ] as [String : Any]
 
 
 self.audioInput = AVAssetWriterInput(mediaType: AVMediaType.audio,
 outputSettings: audioSettings)
 
 self.audioInput?.expectsMediaDataInRealTime = true
 
 if self.assetWriter!.canAdd(self.audioInput!) {
 self.assetWriter?.add(self.audioInput!)
 }
 
 self.session.startRunning()
 
 DispatchQueue.main.async {
 self.session.beginConfiguration()
 
 self.session.commitConfiguration()
 
 let audioDevice = AVCaptureDevice.default(for: AVMediaType.audio)
 let audioIn = try? AVCaptureDeviceInput(device: audioDevice!)
 
 if self.session.canAddInput(audioIn!) {
 self.session.addInput(audioIn!)
 }
 
 if self.session.canAddOutput(self.audioOutput) {
 self.session.addOutput(self.audioOutput)
 }
 
 self.audioConnection = self.audioOutput.connection(with: AVMediaType.audio)
 }
}

func startRecording() {
 if self.assetWriter?.startWriting() != true {
 print("error: \(self.assetWriter?.error.debugDescription ?? "")")
 }
 
 self.audioOutput.setSampleBufferDelegate(self, queue: self.recordingQueue)
}

func stopRecording() {
 self.audioOutput.setSampleBufferDelegate(nil, queue: nil)
 
 self.assetWriter?.finishWriting {
 print("Saved in folder \(self.recordingURL!)")
 }
}
func captureOutput(_ captureOutput: AVCaptureOutput, didOutput
 sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
 
 if !self.isRecordingSessionStarted {
 let presentationTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
 self.assetWriter?.startSession(atSourceTime: presentationTime)
 self.isRecordingSessionStarted = true
 recordingState = .capturing
 }
 
 var blockBuffer: CMBlockBuffer?
 var audioBufferList: AudioBufferList = AudioBufferList.init()
 
 CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, bufferListSizeNeededOut: nil, bufferListOut: &audioBufferList, bufferListSize: MemoryLayout<audiobufferlist>.size, blockBufferAllocator: nil, blockBufferMemoryAllocator: nil, flags: kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment, blockBufferOut: &blockBuffer)
 let buffers = UnsafeMutableAudioBufferListPointer(&audioBufferList)
 
 for buffer in buffers {
 let u8ptr = buffer.mData!.assumingMemoryBound(to: UInt8.self)
 let output = outputStream!.write(u8ptr, maxLength: Int(buffer.mDataByteSize))
 
 if (output == -1) {
 let error = outputStream?.streamError
 print("\(#file) > \(#function) > Error on outputStream: \(error!.localizedDescription)")
 }
 else {
 print("\(#file) > \(#function) > Data sent")
 }
 }
}

func ffmpeg_transmit() {
 
 let cmd1: String = "-f s16le -ar 48000 -ac 1 -i "
 let cmd2: String = " -probesize 32 -analyzeduration 0 -c:a libopus -application lowdelay -ac 1 -ar 48000 -f rtsp -rtsp_transport udp rtsp://localhost:18556/mystream"
 let cmd = cmd1 + outPipePath! + cmd2
 
 print(cmd)
 
 ffmpegSession = FFmpegKit.executeAsync(cmd, withExecuteCallback: { ffmpegSession in
 
 let state = ffmpegSession?.getState()
 let returnCode = ffmpegSession?.getReturnCode()
 if let returnCode = returnCode, let get = ffmpegSession?.getFailStackTrace() {
 print("FFmpeg process exited with state \(String(describing: FFmpegKitConfig.sessionState(toString: state!))) and rc \(returnCode).\(get)")
 }
 }, withLogCallback: { log in
 
 }, withStatisticsCallback: { statistics in
 
 })
}
</audiobufferlist>


I want to use MobileVLCKit in that way :


func startStream(){
 guard let url = URL(string: "rtsp://localhost:18556/mystream") else {return}
 audioPlayer!.media = VLCMedia(url: url)

 audioPlayer!.media.addOption( "-vv")
 audioPlayer!.media.addOption( "--network-caching=10000")

 audioPlayer!.delegate = self
 audioPlayer!.audio.volume = 100

 audioPlayer!.play()

}



Could you give me some hints how to implement that ?


-
Why does File upload for moving image and Audio to tmp PHP folder work on Windows but only image upload portion works on Mac using MAMP ?
31 mai 2021, par YazdanSo according to my colleague who tested this on Windows says it works perfectly fine , but in my case when I use it on a Mac with MAMP for Moodle , the image files get uploaded to the correct destination folder without an issue whereas the audio files don't move from the tmp folder to the actual destination folder and to check if this was the case ... I just changed and gave a fixed path instead of
$fileTmpLoc
and the file made it to the correct destination. Sorry I know the first half of the code isn't the main issue but I still wanted to post the whole code so one could understand it easily, moreover I am just beginning to code so please "have a bit of patience with me" . Thanks in advance


// this file contains upload function 
// checks if the file exists in server
include("../db/database.php");
require_once(dirname(__FILE__) . '/../../../config.php');
global $IP;

$ajaxdata = $_POST['mediaUpload'];

$FILENAME = $ajaxdata[1];
$IMAGE=$ajaxdata[0];
// an array to check which category the media belongs too
$animal= array("bird","cat","dog","horse","sheep","cow","elephant","bear","giraffe","zebra");
$allowedExts = array("mp3","wav");
$temp = explode(".", $_FILES["audio"]["name"]);
$extension = end($temp);



$test = $_FILES["audio"]["type"]; 


if (
 $_FILES["audio"]["type"] == "audio/wav"||
 $_FILES["audio"]["type"] == "audio/mp3"||
 $_FILES["audio"]["type"] == "audio/mpeg"
 &&
 in_array($extension, $allowedExts)
 )
 {

 // if the name detected by object detection is present in the animal array
 // then initialize target path to animal database or to others
 if (in_array($FILENAME, $animal)) 
 { 
 $image_target_dir = "image_dir/";
 $audio_target_dir = "audio_dir/";
 } 
 else
 { 
 $image_target_dir = "other_image_dir/";
 $audio_target_dir = "other_audio_dir/";
 } 
 // Get file path
 
 $img = $IMAGE;
 // decode base64 image
 $img = str_replace('data:image/png;base64,', '', $img);
 $img = str_replace(' ', '+', $img);
 $image_data = base64_decode($img);

 //$extension = pathinfo( $_FILES["fileUpload"]["name"], PATHINFO_EXTENSION ); // jpg
 $image_extension = "png";
 $image_target_file =$image_target_dir . basename($FILENAME . "." . $image_extension);
 $image_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$image_target_file;
 
 
 $audio_extension ="mp3";
 $audio_target_file= $audio_target_dir . basename($FILENAME. "." . $audio_extension) ;
 $audio_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$audio_target_file;

 // file size limit
 if(($_FILES["audio"]["size"])<=51242880)
 {

 $fileName = $_FILES["audio"]["name"]; // The file name
 $fileTmpLoc = $_FILES["audio"]["tmp_name"]; // File in the PHP tmp folder
 $fileType = $_FILES["audio"]["type"]; // The type of file it is
 $fileSize = $_FILES["audio"]["size"]; // File size in bytes
 $fileErrorMsg = $_FILES["audio"]["error"]; // 0 for false... and 1 for true
 
 if (in_array($FILENAME, $animal)) 
 { 
 $sql = "INSERT INTO mdl_media_animal (animal_image_path,animal_name,animal_audio_path) VALUES ('$image_file_upload','$FILENAME','$audio_file_upload')";
 } else {
 $sql = "INSERT INTO mdl_media_others (others_image_path,others_name,others_audio_path) VALUES ('$image_file_upload','$FILENAME','$audio_file_upload')";
 }

 // if file exists
 if (file_exists($audio_target_file) || file_exists($image_target_file)) {
 echo "alert";
 } else {
 // write image file
 if (file_put_contents($image_target_file, $image_data) ) {
 // ffmpeg to write audio file
 $output = shell_exec("ffmpeg -i $fileTmpLoc -ab 160k -ac 2 -ar 44100 -vn $audio_target_file");
 echo $output;
 
 // $stmt = $conn->prepare($sql);
 $db = mysqli_connect("localhost", "root", "root", "moodle310"); 
 // echo $sql;
 if (!$db) {
 echo "nodb";
 die("Connection failed: " . mysqli_connect_error());
 }
 // echo"sucess";
 if(mysqli_query($db, $sql)){
 // if($stmt->execute()){
 echo $fileTmpLoc;
 echo "sucess"; 
 echo $output;
 }
 else {
 // echo "Error: " . $sql . "<br />" . mysqli_error($conn);
 echo "failed";
 }

 }else {
 echo "failed";
 }

 
 
 
 }
 
 // $test = "ffmpeg -i $outputfile -ab 160k -ac 2 -ar 44100 -vn bub.wav";
 } else
 {
 echo "File size exceeds 5 MB! Please try again!";
 }
}
else
{
 echo "PHP! Not a video! ";//.$extension." ".$_FILES["uploadimage"]["type"];
 }

?>



I am a student learning frontend but a project of mine requires a fair bit of backend. So forgive me if my question sounds silly.


What I meant by manually overriding it was creating another folder and a index.php file with
echo "hello"; $output = shell_exec("ffmpeg -i Elephant.mp3 -ab 160k -ac 2 -ar 44100 -vn bub.mp3"); echo $output;
so only yes in this caseElephant.mp3
was changed as the initial tmp path so in this case as suggested by Mr.CBroe the permissons shouldn't be an issue.

Okay I checked my
Apache_error.log
only to find out ffmpeg is indeed the culprit ... I had installedffmpeg
globally so I am not sure if it is an access problem but here is a snippet of the log

I checked my php logs and found out that
FFmpeg
is the culprit.
Attached is a short log file

[Mon May 31 18:11:33 2021] [notice] caught SIGTERM, shutting down
[Mon May 31 18:11:40 2021] [notice] Digest: generating secret for digest authentication ...
[Mon May 31 18:11:40 2021] [notice] Digest: done
[Mon May 31 18:11:40 2021] [notice] Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/1.0.2o PHP/7.2.10 configured -- resuming normal operations
sh: ffmpeg: command not found
sh: ffmpeg: command not found
sh: ffmpeg: command not found



-
Frames and Size Increase as Speed Reduces When Ffmpeg Converts HLS to MPEGTS
28 juillet 2021, par Mikeyy10I've been trying my hands on programmatically using ffmpeg to convert HTTP live streams to mpegts. All of the HLS I've tried have been on remote servers and everything worked fine until this particular feed. As you can see in the logs, the number of frames keeps increasing by 150 and the size increases as a result. At the same time, the speed reduces. This is the code I used :
ffmpeg -i http://xxxxxxxx-xxxxxxx-xx.m3u8 -y -r 100 -vcodec libx264 -f mpegts -preset ultrafast -tune zerolatency -t 00:10:00.500 /home/xxxx-xxxxxx/app/backend/queues/../files/output.mpegts

I have tried different fps starting with 30 and upward to 100. I noticed that the number of frames and the size continue to increase in direct proportion to the fps. Is there a better way to reencode this sort of stream. I'm using fluent-ffmpeg and I stiil haven't figured out how to apply thenobuffer
option but I'm not sure that'll solve the problem anyway.

[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxx-xxx99.ts' for reading
Input #0, hls,applehttp, from 'http://xxxxxxxxxxxxxxxx-xxxxxxxx.m3u8':
 Duration: N/A, start: 28505.278111, bitrate: N/A
 Program 0 
 Metadata:
 variant_bitrate : 0
 Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Metadata:
 variant_bitrate : 0
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x1dc0ea0] using SAR=1/1
[libx264 @ 0x1dc0ea0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x1dc0ea0] profile Constrained Baseline, level 3.0
Output #0, mpegts, to '/home/xxxxx-xxxxxx-xxx/app/backend/queues/../files/output.mpegts':
 Metadata:
 encoder : Lavf57.83.100
 Stream #0:0: Video: h264 (libx264), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 100 fps, 90k tbn, 100 tbc
 Metadata:
 variant_bitrate : 0
 encoder : Lavc57.107.100 libx264
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx100.ts' for reading
frame= 149 fps=0.0 q=24.0 size= 239kB time=00:00:05.92 bitrate= 331.0kbits/s speed=9.52x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx101.ts' for reading
frame= 299 fps= 59 q=25.0 size= 256kB time=00:00:11.92 bitrate= 175.9kbits/s speed=2.35x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx102.ts' for reading
frame= 449 fps= 43 q=24.0 size= 512kB time=00:00:17.92 bitrate= 234.1kbits/s speed=1.72x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx103.ts' for reading
frame= 599 fps= 38 q=22.0 size= 768kB time=00:00:23.92 bitrate= 263.0kbits/s speed=1.52x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx104.ts' for reading
frame= 749 fps= 35 q=22.0 size= 1024kB time=00:00:29.92 bitrate= 280.4kbits/s speed=1.42x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx105.ts' for reading
frame= 899 fps= 28 q=23.0 size= 1280kB time=00:00:35.92 bitrate= 291.9kbits/s speed=1.12x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx106.ts' for reading
frame= 1049 fps= 25 q=23.0 size= 1536kB time=00:00:41.92 bitrate= 300.2kbits/s speed=0.998x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx107.ts' for reading
frame= 1199 fps= 28 q=24.0 size= 1792kB time=00:00:47.92 bitrate= 306.3kbits/s speed=1.11x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx108.ts' for reading
frame= 1349 fps= 28 q=25.0 size= 2048kB time=00:00:53.92 bitrate= 311.2kbits/s speed=1.11x 
Past duration 0.999992 too large
 Last message repeated 6 times
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx109.ts' for reading
frame= 1499 fps= 28 q=23.0 size= 2048kB time=00:00:59.64 bitrate= 281.3kbits/s speed=1.11x 
[hls,applehttp @ 0x1d97f60] Opening 'http://xxxxxxxxxxxxxxxx-xxxxx110.ts' for reading
frame= 1649 fps= 28 q=24.0 size= 2304kB time=00:01:05.64 bitrate= 287.5kbits/s speed=1.11x 
[http @ 0x23b86e0] HTTP error 404 Not Found
[hls,applehttp @ 0x1d97f60] Failed to reload playlist 0
[http @ 0x23b86e0] HTTP error 404 Not Found
[hls,applehttp @ 0x1d97f60] Failed to reload playlist 0
frame= 1799 fps= 13 q=24.0 size= 2560kB time=00:01:11.64 bitrate= 292.7kbits/s speed=0.523x 
[http @ 0x23b86e0] HTTP error 404 Not Found
[hls,applehttp @ 0x1d97f60] Failed to reload playlist 0
frame= 1800 fps= 13 q=24.0 size= 2560kB time=00:01:11.68 bitrate= 292.6kbits/s speed=0.514x 
[http @ 0x1e34ea0] HTTP error 404 Not Found
[hls,applehttp @ 0x1d97f60] Failed to reload playlist 0
frame= 1800 fps= 13 q=24.0 size= 2560kB time=00:01:11.68 bitrate= 292.6kbits/s speed=0.512x 
frame= 1800 fps= 13 q=24.0 Lsize= 2756kB time=00:01:11.68 bitrate= 315.0kbits/s speed=0.512x 
video:2359kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 16.855715%
[libx264 @ 0x1dc0ea0] frame I:8 Avg QP:20.62 size: 21713
[libx264 @ 0x1dc0ea0] frame P:1792 Avg QP:23.84 size: 1251
[libx264 @ 0x1dc0ea0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x1dc0ea0] mb P I16..4: 0.2% 0.0% 0.0% P16..4: 32.8% 0.0% 0.0% 0.0% 0.0% skip:67.0%
[libx264 @ 0x1dc0ea0] coded y,uvDC,uvAC intra: 83.7% 62.6% 40.9% inter: 12.7% 15.3% 7.9%
[libx264 @ 0x1dc0ea0] i16 v,h,dc,p: 26% 29% 31% 14%
[libx264 @ 0x1dc0ea0] i8c dc,h,v,p: 58% 20% 14% 8%
[libx264 @ 0x1dc0ea0] kb/s:1073.41