
Recherche avancée
Médias (91)
-
Spoon - Revenge !
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
My Morning Jacket - One Big Holiday
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Zap Mama - Wadidyusay ?
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
David Byrne - My Fair Lady
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Beastie Boys - Now Get Busy
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Granite de l’Aber Ildut
9 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
Autres articles (82)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Mise à disposition des fichiers
14 avril 2011, parPar défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...) -
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)
Sur d’autres sites (6066)
-
exo player mp2, aac audio format and avi video format [closed]
27 mai 2020, par Muhammet

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.android.exoplayer2.ext.ffmpeg;

import android.os.Handler;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.audio.DefaultAudioSink;
import com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes;
import java.util.Collections;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;

/**
 * Decodes and renders audio using FFmpeg.
 */
public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {

 /** The number of input and output buffers. */
 private static final int NUM_BUFFERS = 16;
 /** The default input buffer size. */
 private static final int DEFAULT_INPUT_BUFFER_SIZE = 960 * 6;

 private final boolean enableFloatOutput;

 private @MonotonicNonNull FfmpegDecoder decoder;

 public FfmpegAudioRenderer() {
 this(/* eventHandler= */ null, /* eventListener= */ null);
 }

 /**
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 * null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
 */
 public FfmpegAudioRenderer(
 @Nullable Handler eventHandler,
 @Nullable AudioRendererEventListener eventListener,
 AudioProcessor... audioProcessors) {
 this(
 eventHandler,
 eventListener,
 new DefaultAudioSink(/* audioCapabilities= */ null, audioProcessors),
 /* enableFloatOutput= */ false);
 }

 /**
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 * null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param audioSink The sink to which audio will be output.
 * @param enableFloatOutput Whether to enable 32-bit float audio format, if supported on the
 * device/build and if the input format may have bit depth higher than 16-bit. When using
 * 32-bit float output, any audio processing will be disabled, including playback speed/pitch
 * adjustment.
 */
 public FfmpegAudioRenderer(
 @Nullable Handler eventHandler,
 @Nullable AudioRendererEventListener eventListener,
 AudioSink audioSink,
 boolean enableFloatOutput) {
 super(
 eventHandler,
 eventListener,
 /* drmSessionManager= */ null,
 /* playClearSamplesWithoutKeys= */ false,
 audioSink);
 this.enableFloatOutput = enableFloatOutput;
 }

 @Override
 @FormatSupport
 protected int supportsFormatInternal(
 @Nullable DrmSessionManager<exomediacrypto> drmSessionManager, Format format) {
 Assertions.checkNotNull(format.sampleMimeType);
 if (!FfmpegLibrary.isAvailable()) {
 return FORMAT_UNSUPPORTED_TYPE;
 } else if (!FfmpegLibrary.supportsFormat(format.sampleMimeType) || !isOutputSupported(format)) {
 return FORMAT_UNSUPPORTED_SUBTYPE;
 } else if (!supportsFormatDrm(drmSessionManager, format.drmInitData)) {
 return FORMAT_UNSUPPORTED_DRM;
 } else {
 return FORMAT_HANDLED;
 }
 }

 @Override
 @AdaptiveSupport
 public final int supportsMixedMimeTypeAdaptation() throws ExoPlaybackException {
 return ADAPTIVE_NOT_SEAMLESS;
 }

 @Override
 protected FfmpegDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
 throws FfmpegDecoderException {
 int initialInputBufferSize =
 format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
 decoder =
 new FfmpegDecoder(
 NUM_BUFFERS, NUM_BUFFERS, initialInputBufferSize, format, shouldUseFloatOutput(format));
 return decoder;
 }

 @Override
 public Format getOutputFormat() {
 Assertions.checkNotNull(decoder);
 int channelCount = decoder.getChannelCount();
 int sampleRate = decoder.getSampleRate();
 @C.PcmEncoding int encoding = decoder.getEncoding();
 return Format.createAudioSampleFormat(
 /* id= */ null,
 MimeTypes.AUDIO_RAW,
 /* codecs= */ null,
 Format.NO_VALUE,
 Format.NO_VALUE,
 channelCount,
 sampleRate,
 encoding,
 Collections.emptyList(),
 /* drmInitData= */ null,
 /* selectionFlags= */ 0,
 /* language= */ null);
 }

 private boolean isOutputSupported(Format inputFormat) {
 return shouldUseFloatOutput(inputFormat)
 || supportsOutput(inputFormat.channelCount, C.ENCODING_PCM_16BIT);
 }

 private boolean shouldUseFloatOutput(Format inputFormat) {
 Assertions.checkNotNull(inputFormat.sampleMimeType);
 if (!enableFloatOutput || !supportsOutput(inputFormat.channelCount, C.ENCODING_PCM_FLOAT)) {
 return false;
 }
 switch (inputFormat.sampleMimeType) {
 case MimeTypes.AUDIO_RAW:
 // For raw audio, output in 32-bit float encoding if the bit depth is > 16-bit.
 return inputFormat.pcmEncoding == C.ENCODING_PCM_24BIT
 || inputFormat.pcmEncoding == C.ENCODING_PCM_32BIT
 || inputFormat.pcmEncoding == C.ENCODING_PCM_FLOAT;
 case MimeTypes.AUDIO_AC3:
 // AC-3 is always 16-bit, so there is no point outputting in 32-bit float encoding.
 return false;
 default:
 // For all other formats, assume that it's worth using 32-bit float encoding.
 return true;
 }
 }

}</exomediacrypto>








I use exoplayer but no sound from mp2 and aac audio formats in android application.



I get this error when I open mp2 and aac audio format videos "media includes audio tracks but none



are playable by this device"and some are not working in .avi format, some are working please can you help me





/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.android.exoplayer2.ext.ffmpeg;

import androidx.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.util.LibraryLoader;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.MimeTypes;

/**
 * Configures and queries the underlying native library.
 */
public final class FfmpegLibrary {

 static {
 ExoPlayerLibraryInfo.registerModule("goog.exo.ffmpeg");
 }

 private static final String TAG = "FfmpegLibrary";

 private static final LibraryLoader LOADER =
 new LibraryLoader("avutil", "swresample", "avcodec", "ffmpeg");

 private FfmpegLibrary() {}

 /**
 * Override the names of the FFmpeg native libraries. If an application wishes to call this
 * method, it must do so before calling any other method defined by this class, and before
 * instantiating a {@link FfmpegAudioRenderer} instance.
 *
 * @param libraries The names of the FFmpeg native libraries.
 */
 public static void setLibraries(String... libraries) {
 LOADER.setLibraries(libraries);
 }

 /**
 * Returns whether the underlying library is available, loading it if necessary.
 */
 public static boolean isAvailable() {
 return LOADER.isAvailable();
 }

 /** Returns the version of the underlying library if available, or null otherwise. */
 public static @Nullable String getVersion() {
 return isAvailable() ? ffmpegGetVersion() : null;
 }

 /**
 * Returns whether the underlying library supports the specified MIME type.
 *
 * @param mimeType The MIME type to check.
 */
 public static boolean supportsFormat(String mimeType) {
 if (!isAvailable()) {
 return false;
 }
 String codecName = getCodecName(mimeType);
 if (codecName == null) {
 return false;
 }
 if (!ffmpegHasDecoder(codecName)) {
 Log.w(TAG, "No " + codecName + " decoder available. Check the FFmpeg build configuration.");
 return false;
 }
 return true;
 }

 /**
 * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null}
 * if it's unsupported.
 */
 /* package */ static @Nullable String getCodecName(String mimeType) {
 switch (mimeType) {
 case MimeTypes.AUDIO_AAC:
 return "aac";
 case MimeTypes.AUDIO_MPEG:
 case MimeTypes.AUDIO_MPEG_L1:
 case MimeTypes.AUDIO_MPEG_L2:
 return "mp3";
 case MimeTypes.AUDIO_AC3:
 return "ac3";
 case MimeTypes.AUDIO_E_AC3:
 case MimeTypes.AUDIO_E_AC3_JOC:
 return "eac3";
 case MimeTypes.AUDIO_TRUEHD:
 return "truehd";
 case MimeTypes.AUDIO_DTS:
 case MimeTypes.AUDIO_DTS_HD:
 return "dca";
 case MimeTypes.AUDIO_VORBIS:
 return "vorbis";
 case MimeTypes.AUDIO_OPUS:
 return "opus";
 case MimeTypes.AUDIO_AMR_NB:
 return "amrnb";
 case MimeTypes.AUDIO_AMR_WB:
 return "amrwb";
 case MimeTypes.AUDIO_FLAC:
 return "flac";
 case MimeTypes.AUDIO_ALAC:
 return "alac";
 case MimeTypes.AUDIO_MLAW:
 return "pcm_mulaw";
 case MimeTypes.AUDIO_ALAW:
 return "pcm_alaw";
 default:
 return null;
 }
 }

 private static native String ffmpegGetVersion();
 private static native boolean ffmpegHasDecoder(String codecName);

}








[enter image description here][1]
[enter image description here][2]


-
How to Stream Audio from Google Cloud Storage in Chunks and Convert Each Chunk to WAV for Whisper Transcription
14 novembre 2024, par Douglas LandvikI'm working on a project where I need to transcribe audio stored in a Google Cloud Storage bucket using OpenAI's Whisper model. The audio is stored in WebM format with Opus encoding, and due to the file size, I'm streaming the audio in 30-second chunks.


To convert each chunk to WAV (16 kHz, mono, 16-bit PCM) compatible with Whisper, I'm using FFmpeg. The first chunk converts successfully, but subsequent chunks fail to convert. I suspect this is because each chunk lacks the WebM container's header, which FFmpeg needs to interpret the Opus codec correctly.


Here’s a simplified version of my approach :


Download Chunk : I download each chunk from GCS as bytes.
Convert with FFmpeg : I pass the bytes to FFmpeg to convert each chunk from WebM/Opus to WAV.


async def handle_transcription_and_notify(
 consultation_service: ConsultationService,
 consultation_processor: ConsultationProcessor,
 consultation: Consultation,
 language: str,
 notes: str,
 clinic_id: str,
 vet_email: str,
 trace_id: str,
 blob_path: str,
 max_retries: int = 3,
 retry_delay: int = 5,
 max_concurrent_tasks: int = 3
):
 """
 Handles the transcription process by streaming the file from GCS, converting to a compatible format, 
 and notifying the client via WebSocket.
 """
 chunk_duration_sec = 30 # 30 seconds per chunk
 logger.info(f"Starting transcription process for consultation {consultation.consultation_id}",
 extra={'trace_id': trace_id})

 # Initialize GCS client
 service_account_key = os.environ.get('SERVICE_ACCOUNT_KEY_BACKEND')
 if not service_account_key:
 logger.error("Service account key not found in environment variables", extra={'trace_id': trace_id})
 await send_discord_alert(
 f"Service account key not found for consultation {consultation.consultation_id}.\nTrace ID: {trace_id}"
 )
 return

 try:
 service_account_info = json.loads(service_account_key)
 credentials = service_account.Credentials.from_service_account_info(service_account_info)
 except Exception as e:
 logger.error(f"Error loading service account credentials: {str(e)}", extra={'trace_id': trace_id})
 await send_discord_alert(
 f"Error loading service account credentials for consultation {consultation.consultation_id}.\nError: {str(e)}\nTrace ID: {trace_id}"
 )
 return

 # Initialize GCS client
 service_account_key = os.environ.get('SERVICE_ACCOUNT_KEY_BACKEND')
 if not service_account_key:
 logger.error("Service account key not found in environment variables", extra={'trace_id': trace_id})
 await send_discord_alert(
 f"Service account key not found for consultation {consultation.consultation_id}.\nTrace ID: {trace_id}"
 )
 return

 try:
 service_account_info = json.loads(service_account_key)
 credentials = service_account.Credentials.from_service_account_info(service_account_info)
 except Exception as e:
 logger.error(f"Error loading service account credentials: {str(e)}", extra={'trace_id': trace_id})
 await send_discord_alert(
 f"Error loading service account credentials for consultation {consultation.consultation_id}.\nError: {str(e)}\nTrace ID: {trace_id}"
 )
 return

 storage_client = storage.Client(credentials=credentials)
 bucket_name = 'vetz_consultations'
 blob = storage_client.bucket(bucket_name).get_blob(blob_path)
 bytes_per_second = 16000 * 2 # 32,000 bytes per second
 chunk_size_bytes = 30 * bytes_per_second
 size = blob.size

 async def stream_blob_in_chunks(blob, chunk_size):
 loop = asyncio.get_running_loop()
 start = 0
 size = blob.size
 while start < size:
 end = min(start + chunk_size - 1, size - 1)
 try:
 logger.info(f"Requesting chunk from {start} to {end}", extra={'trace_id': trace_id})
 chunk = await loop.run_in_executor(
 None, lambda: blob.download_as_bytes(start=start, end=end)
 )
 if not chunk:
 break
 logger.info(f"Yielding chunk from {start} to {end}, size: {len(chunk)} bytes",
 extra={'trace_id': trace_id})
 yield chunk
 start += chunk_size
 except Exception as e:
 logger.error(f"Error downloading chunk from {start} to {end}: {str(e)}", exc_info=True,
 extra={'trace_id': trace_id})
 raise e

 async def convert_to_wav(chunk_bytes, chunk_idx):
 """
 Convert audio chunk to WAV format compatible with Whisper, ensuring it's 16 kHz, mono, and 16-bit PCM.
 """
 try:
 logger.debug(f"Processing chunk {chunk_idx}: size = {len(chunk_bytes)} bytes")

 detected_format = await detect_audio_format(chunk_bytes)
 logger.info(f"Detected audio format for chunk {chunk_idx}: {detected_format}")
 input_io = io.BytesIO(chunk_bytes)
 output_io = io.BytesIO()

 # ffmpeg command to convert webm/opus to WAV with 16 kHz, mono, and 16-bit PCM

 # ffmpeg command with debug information
 ffmpeg_command = [
 "ffmpeg",
 "-loglevel", "debug",
 "-f", "s16le", # Treat input as raw PCM data
 "-ar", "48000", # Set input sample rate
 "-ac", "1", # Set input to mono
 "-i", "pipe:0",
 "-ar", "16000", # Set output sample rate to 16 kHz
 "-ac", "1", # Ensure mono output
 "-sample_fmt", "s16", # Set output format to 16-bit PCM
 "-f", "wav", # Output as WAV format
 "pipe:1"
 ]

 process = subprocess.Popen(
 ffmpeg_command,
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE
 )

 stdout, stderr = process.communicate(input=input_io.read())

 if process.returncode == 0:
 logger.info(f"FFmpeg conversion completed successfully for chunk {chunk_idx}")
 output_io.write(stdout)
 output_io.seek(0)

 # Save the WAV file locally for listening
 output_dir = "converted_chunks"
 os.makedirs(output_dir, exist_ok=True)
 file_path = os.path.join(output_dir, f"chunk_{chunk_idx}.wav")

 with open(file_path, "wb") as f:
 f.write(stdout)
 logger.info(f"Chunk {chunk_idx} saved to {file_path}")

 return output_io
 else:
 logger.error(f"FFmpeg failed for chunk {chunk_idx} with return code {process.returncode}")
 logger.error(f"Chunk {chunk_idx} - FFmpeg stderr: {stderr.decode()}")
 return None

 except Exception as e:
 logger.error(f"Unexpected error in FFmpeg conversion for chunk {chunk_idx}: {str(e)}")
 return None

 async def transcribe_chunk(idx, chunk_bytes):
 for attempt in range(1, max_retries + 1):
 try:
 logger.info(f"Transcribing chunk {idx + 1} (attempt {attempt}).", extra={'trace_id': trace_id})

 # Convert to WAV format
 wav_io = await convert_to_wav(chunk_bytes, idx)
 if not wav_io:
 logger.error(f"Failed to convert chunk {idx + 1} to WAV format.")
 return ""

 wav_io.name = "chunk.wav"
 chunk_transcription = await consultation_processor.transcribe_audio_whisper(wav_io)
 logger.info(f"Chunk {idx + 1} transcribed successfully.", extra={'trace_id': trace_id})
 return chunk_transcription
 except Exception as e:
 logger.error(f"Error transcribing chunk {idx + 1} (attempt {attempt}): {str(e)}", exc_info=True,
 extra={'trace_id': trace_id})
 if attempt < max_retries:
 await asyncio.sleep(retry_delay)
 else:
 await send_discord_alert(
 f"Max retries reached for chunk {idx + 1} in consultation {consultation.consultation_id}.\nError: {str(e)}\nTrace ID: {trace_id}"
 )
 return "" # Return empty string for failed chunk

 await notification_manager.send_personal_message(
 f"Consultation {consultation.consultation_id} is being transcribed.", vet_email
 )

 try:
 idx = 0
 full_transcription = []
 async for chunk in stream_blob_in_chunks(blob, chunk_size_bytes):
 transcription = await transcribe_chunk(idx, chunk)
 if transcription:
 full_transcription.append(transcription)
 idx += 1

 combined_transcription = " ".join(full_transcription)
 consultation.full_transcript = (consultation.full_transcript or "") + " " + combined_transcription
 consultation_service.save_consultation(clinic_id, vet_email, consultation)
 logger.info(f"Transcription saved for consultation {consultation.consultation_id}.",
 extra={'trace_id': trace_id})

 except Exception as e:
 logger.error(f"Error during transcription process: {str(e)}", exc_info=True, extra={'trace_id': trace_id})
 await send_discord_alert(
 f"Error during transcription process for consultation {consultation.consultation_id}.\nError: {str(e)}\nTrace ID: {trace_id}"
 )
 return

 await notification_manager.send_personal_message(
 f"Consultation {consultation.consultation_id} has been transcribed.", vet_email
 )

 try:
 template_service = TemplateService()
 medical_record_template = template_service.get_template_by_name(
 consultation.medical_record_template_id).sections

 sections = await consultation_processor.extract_structured_sections(
 transcription=consultation.full_transcript,
 notes=notes,
 language=language,
 template=medical_record_template,
 )
 consultation.sections = sections
 consultation_service.save_consultation(clinic_id, vet_email, consultation)
 logger.info(f"Sections processed for consultation {consultation.consultation_id}.",
 extra={'trace_id': trace_id})
 except Exception as e:
 logger.error(f"Error processing sections for consultation {consultation.consultation_id}: {str(e)}",
 exc_info=True, extra={'trace_id': trace_id})
 await send_discord_alert(
 f"Error processing sections for consultation {consultation.consultation_id}.\nError: {str(e)}\nTrace ID: {trace_id}"
 )
 raise e

 await notification_manager.send_personal_message(
 f"Consultation {consultation.consultation_id} is fully processed.", vet_email
 )
 logger.info(f"Successfully processed consultation {consultation.consultation_id}.",
 extra={'trace_id': trace_id})




-
Can I make calls to APIs such as youtube-dl and ffmpeg from a chrome-app ?
8 janvier 2015, par ErickRFirst of all, I haven’t started the implementation of the system I’m about to describe, as I didn’t want to commit on implementing something I did not know if was possible.
So, what I’m trying to achieve is to build a chrome-app to download the audio from certain websites (e.g. youtube and soundcloud) using youtube-dl, post process it using ffmpeg and then upload it to a cloud service via some api. The reason I want to do it via a chrome-app is because I could do all the work on the client side (no need for servers) and I’d have the ability to insert javascript into the pages using content scripts, which would make the app pretty simple to use (I could create buttons such as ’download song’ and stuff like that).
Although I have already read the documentation explaining the NaCl Technical Overview and some of the Application Structure, I still am not sure as to whether I would be able to make these calls via some C/C++ module or if I would get denied due to security reasons.
To summarize : considering that the user has the needed dependencies in his system (youtube-dl, python, ffmpeg and etc.), is it possible to make calls to third party APIs such as the ones described before via a chrome-app using NaCl ?
Thank you all in advance,