
Recherche avancée
Médias (91)
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Lights in the Sky
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Head Down
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Echoplex
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Discipline
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Letting You
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (111)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
Utilisation et configuration du script
19 janvier 2011, parInformations spécifiques à la distribution Debian
Si vous utilisez cette distribution, vous devrez activer les dépôts "debian-multimedia" comme expliqué ici :
Depuis la version 0.3.1 du script, le dépôt peut être automatiquement activé à la suite d’une question.
Récupération du script
Le script d’installation peut être récupéré de deux manières différentes.
Via svn en utilisant la commande pour récupérer le code source à jour :
svn co (...)
Sur d’autres sites (4931)
-
How can upload audio on dropbox after converted it from the video format using ffmpeg in nodejs and angular
21 septembre 2021, par Amir Shahzadnodejs server side code


This is my nodejs server side where i want to convert the video into the audio format and then want to upload the converted audio on the dropbox is there any way to do that ??


const express = require('express'),
path = require('path'),
cors = require('cors'),
ffmpeg = require('fluent-ffmpeg'),
fs = require("fs"),
access_token = "My-Access-Token";

ffmpeg.setFfmpegPath('/usr/bin/ffmpeg');

const app = express();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({
 extended: false
}));


app.post('/api/upload', upload.single('mp4'), function (req, res) {
 if (!req.file) {
 console.log("No file is available!");
 return res.send({
 success: false
 });

 } else {
 function convert(input, output, callback) {
 ffmpeg(input)
 .output(output)
 .on('end', function() { 
 console.log('conversion ended');
 callback(null);
 }).on('error', function(err){
 console.log('error: ', err);
 callback(err);
 }).run();
 }
 const filepath = req.file.path;
 var content = fs.readFileSync(filepath);

 options = {
 method: "POST",
 url: 'https://content.dropboxapi.com/2/files/upload',
 headers: {
 "Content-Type": "text/plain; charset=dropbox-cors-hack" ,
 "Authorization": "Bearer " + access_token,
 "Dropbox-API-Arg": "{\"path\": \"/youtube- 
 radio/"+req.file.originalname+"\",\"mode\": \"overwrite\",\"autorename\": 
 true,\"mute\": false}",
 },
 body:content
};
convert(filepath, options+'.mp3', function(err,res, body){
 if(!err) {
 console.log('File Name is',req.file.originalname);
 console.log('File Path Is = ',req.file.path)
 console.log('conversion complete'); 
 console.log('ERR', err);
 }
});
console.log('File is available!');
return res.send({
 success: true
})
}
 });


 const PORT = process.env.PORT || 8080;
 const server = app.listen(PORT, () => {
 console.log('Connected to port ' + PORT)
 })



i have read many documentations of dropbox and ffmpeg and angular file upload but i could not understand Please anyone can resolve my code Thanks in advance


This is my typescript file


import { Component, OnInit } from '@angular/core';
import { FileUploader } from 'ng2-file-upload';
import { ToastrService } from 'ngx-toastr';
import { Track } from 'ngx-audio-player'; 
import { PlayerServiceService } from './services/player-service.service';


const URL = 'http://localhost:8080/api/upload';

@Component({
 selector: 'app-root',
 templateUrl: './app.component.html',
 styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{

public uploader: FileUploader = new FileUploader({
 url: URL,
 itemAlias: 'mp4'
});
 constructor(private toastr: ToastrService,
 private playerService: PlayerServiceService) { }

 ngOnInit(): void {
 this.uploader.onAfterAddingFile = (file) => {
 file.withCredentials = false;
 };
 this.uploader.onCompleteItem = (item: any, status: any) => {
 console.log('Uploaded File Details:', item);
 this.toastr.success('File successfully uploaded!');
 };

}
}



This is html code


<div class="container mt-5">
 <div class="file-upload">
 <input type="file" ng2fileselect="ng2fileselect" />
 <button type="button" class="btn btn-info">
 Upload
 </button>
 </div>
</div>



-
FFMPEG wmv conversion to flv
25 novembre 2012, par Brandon Grossuttianyone using ffmpeg
I have a fairly simple wmv exported by a user from movie maker with standard output and want to convert to .flv using
C :>ffmpeg -i "E :\Jab Core 4 Recounters.wmv" -vcodec flv "C :\Net Projects\SVN\IntegratedAlgorithmics\src\MediaAdmin\MediaAdmin\bin\Debug\Movies\Jab Core 4 Recounters.flv" -ar 44100
the output / error i receive is
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er --enable-avfilter-lavf --enable-pthreads --enable-avisynth --enable-libfaac -
-enable-libfaad --enable-libmp3lame --enable-libspeex --enable-libtheora --enabl
e-libvorbis --enable-libxvid --enable-libx264 --enable-memalign-hack
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Mar 16 2009 16:09:18, gcc: 4.2.4 [Sherpya]
[wmv3 @ 0x1c0d490]Extra data: 8 bits left, value: 0
Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000
/1) -> 30.00 (30/1)
Input #0, asf, from 'E:\Jab Core 4 Recounters.wmv':
Duration: 00:01:55.99, start: 5.000000, bitrate: 813 kb/s
Stream #0.0: Audio: wmav2, 48000 Hz, stereo, s16, 192 kb/s
Stream #0.1: Video: wmv3, yuv420p, 640x480, 586 kb/s, 30 tbr, 1k tbn, 1k tbc
Output #0, flv, to 'C:\Net Projects\SVN\IntegratedAlgorithmics\src\MediaAdmin\Me
diaAdmin\bin\Debug\Movies\Jab Core 4 Recounters.flv':
Stream #0.0: Video: flv, yuv420p, 640x480, q=2-31, 200 kb/s, 90k tbn, 30 tbc
Stream #0.1: Audio: libmp3lame, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Stream #0.0 -> #0.1
[wmv3 @ 0x1c0d490]Extra data: 8 bits left, value: 0
[libmp3lame @ 0x1c0d8d0]flv does not support that sample rate, choose from (4410
0, 22050, 11025).
Could not write header for output file #0 (incorrect codec parameters ?)i added th -ar switch when i got the error the first time
the codec info i have on the file is as follows
General
Complete name : E:\Jab Core 4 Recounters.wmv
Format : Windows Media
File size : 11.3 MiB
Duration : 2mn 0s
Overall bit rate mode : Variable
Overall bit rate : 780 Kbps
Maximum Overall bit rate : 949 Kbps
Encoded date : UTC 2009-03-07 07:02:41.121
Writing application : 6.0.6000.16386 / Windows Movie Maker
Application : Windows Movie Maker 6.0.6000.16386
Video
ID : 2
Format : VC-1
Format profile : MP@ML
Codec ID : WMV3
Codec ID/Info : Windows Media Video 9
Codec ID/Hint : WMV3
Duration : 2mn 0s
Bit rate mode : Variable
Bit rate : 587 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4/3
Frame rate : 30.000 fps
Resolution : 24 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.064
Stream size : 8.46 MiB (75%)
Language : en-us
Audio
ID : 1
Format : WMA2
Format profile : L3
Codec ID : 161
Codec ID/Info : Windows Media Audio 2
Description of the codec : Windows Media Audio 9.2 - VBR Quality 90, 48 kHz, stereo 1-pass VBR
Duration : 2mn 0s
Bit rate mode : Variable
Bit rate : 186 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Resolution : 16 bits
Stream size : 2.68 MiB (24%)
Language : en-usi see alot of people with this issue with so solution or cause
any ideas would be helpful
thanks in advance -
Getting Access Violations Exceptions in FFmpeg when trying to free IO buffer
26 juin 2015, par PatrikI’ve been trying to create an audio stream extractor/demuxer using FFmpeg.AutoGen and C#. While the code actually works (in the sense that it extracts the audio stream correctly), I can’t seem to clean up the resources afterwards. Whenever I try to free my input buffer (allocated using av_malloc) I get an Access Violation Exception, and if I don’t free it, I seem to be leaking memory corresponding to the size of the allocated input buffer.
This is my code (from a console application I used for testing) :
class Program
{
static void Main(string[] args)
{
using (var videoStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FFmpeg.Demux.test.mp4"))
using (MemoryStream output = new MemoryStream())
{
FFmpegAudioExtractor audioExtractor = new FFmpegAudioExtractor();
audioExtractor.Extract(videoStream, output);
Debug.Assert(1331200 == output.Length);
//File.WriteAllBytes(@"c:\temp\out.pcm", output.ToArray());
}
Console.WriteLine("Done");
Console.ReadLine();
}
}
public class FFmpegAudioExtractor
{
public FFmpegAudioExtractor()
{
FFmpegInvoke.av_register_all();
FFmpegInvoke.avcodec_register_all();
}
public unsafe void Extract(Stream input, Stream output)
{
AVFormatContext* inFormatContextPtr = null;
int inFomatContextOpenResult = -1;
byte* inIoBuffer = null;
AVIOContext* inIoContextPtr = null;
SwrContext* swrContextPtr = null;
AVFrame* inFramePtr = null;
AVFrame* outFramePtr = null;
AVCodecContext* inCodecContextPtr = null;
try
{
/* 1 */
inFormatContextPtr = FFmpegInvoke.avformat_alloc_context();
if (inFormatContextPtr == null)
throw new ApplicationException("Failed to allocate the input format context (AVFormatContext).");
// HACK this should alloc a fixed buffer and use callbacks to fill it
if (input.Length > int.MaxValue)
throw new ArgumentException("Data too large.", "input");
// TEST alloc a 10MB buffer to make the memory leak real obvious
int inIoBufferSize = 1024 * 1024 * 10; //(int)input.Length;
/* 2 */
inIoBuffer = (byte*)FFmpegInvoke.av_malloc((uint)inIoBufferSize);
if (inIoBuffer == null)
throw new ApplicationException("Failed to allocate the input IO buffer.");
// HACK continued, fill buffer
IntPtr inIoBufferPtr = new IntPtr(inIoBuffer);
byte[] buffer = new byte[4096];
int read, offset = 0;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
Marshal.Copy(buffer, 0, inIoBufferPtr + offset, read);
offset += read;
}
/* 3 */
inIoContextPtr = FFmpegInvoke.avio_alloc_context((sbyte*)inIoBuffer,
inIoBufferSize,
0 /* writable */,
null,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero);
if (inIoContextPtr == null)
throw new ApplicationException("Failed to allocate the input IO context (AVIOContext).");
// configure the format context to use our custom IO contect
inFormatContextPtr->pb = inIoContextPtr;
inFormatContextPtr->flags = FFmpegInvoke.AVFMT_FLAG_CUSTOM_IO;
/* 35 */
inFomatContextOpenResult = FFmpegInvoke.avformat_open_input(&inFormatContextPtr, "", null, null);
if (inFomatContextOpenResult != 0)
throw new ApplicationException("Could not open input: " + inFomatContextOpenResult.ToString(CultureInfo.InvariantCulture));
// retrieve stream information
int avformatFindStreamInfoResult = FFmpegInvoke.avformat_find_stream_info(inFormatContextPtr, null);
if (avformatFindStreamInfoResult < 0)
throw new ApplicationException("Failed to locate stream info: " + avformatFindStreamInfoResult.ToString(CultureInfo.InvariantCulture));
// find audio stream
int inAudioStreamIndex = FFmpegInvoke.av_find_best_stream(inFormatContextPtr,
AVMediaType.AVMEDIA_TYPE_AUDIO,
-1 /* wanted_stream_nb */,
-1 /* related_stream */,
null /* [out] decoder */,
0 /* flags */);
if (inAudioStreamIndex < 0)
throw new ApplicationException("Failed to find audio stream: " + inAudioStreamIndex.ToString(CultureInfo.InvariantCulture));
// get audio stream pointer
AVStream* inAudioStreamPtr = inFormatContextPtr->streams[inAudioStreamIndex];
Contract.Assume(inAudioStreamPtr != null);
// find the decoder
AVCodec* inCodecPtr = FFmpegInvoke.avcodec_find_decoder(inAudioStreamPtr->codec->codec_id);
if (inCodecPtr == null)
throw new ApplicationException("Failed to find decoder with codec_id: " + inAudioStreamPtr->codec->codec_id.ToString());
/* 36 */
inCodecContextPtr = FFmpegInvoke.avcodec_alloc_context3(inCodecPtr);
if (FFmpegInvoke.avcodec_copy_context(inCodecContextPtr, inAudioStreamPtr->codec) != 0)
throw new ApplicationException("Failed to copy context.");
// open codec
/* 37 */
if (FFmpegInvoke.avcodec_open2(inCodecContextPtr, inCodecPtr, null) < 0)
{
string codecName = Marshal.PtrToStringAuto(new IntPtr(inCodecPtr->name));
throw new Exception("Failed to open codec: " + codecName);
}
// alloc frame
/* 38 */
inFramePtr = FFmpegInvoke.av_frame_alloc();
if (inFramePtr == null)
throw new ApplicationException("Could not allocate frame");
// initialize packet, set data to NULL, let the demuxer fill it
AVPacket packet = new AVPacket();
AVPacket* packetPtr = &packet;
FFmpegInvoke.av_init_packet(packetPtr);
packetPtr->data = null;
packetPtr->size = 0;
// alloc SWR
/* 4 */
swrContextPtr = FFmpegInvoke.swr_alloc();
AVSampleFormat outSampleFormat = AVSampleFormat.AV_SAMPLE_FMT_S16;
long outChannelLayout = FFmpegInvoke.AV_CH_FRONT_LEFT | FFmpegInvoke.AV_CH_FRONT_RIGHT;
// configure SWR
FFmpegInvoke.av_opt_set_sample_fmt(swrContextPtr, "in_sample_fmt", inCodecContextPtr->sample_fmt, 0);
FFmpegInvoke.av_opt_set_sample_fmt(swrContextPtr, "out_sample_fmt", outSampleFormat, 0);
// setting the in_channel_layout seems to break things
//FFmpegInvoke.av_opt_set_channel_layout(swrContextPtr, "in_channel_layout", (long)inCodecContextPtr->channel_layout, 0);
FFmpegInvoke.av_opt_set_channel_layout(swrContextPtr, "out_channel_layout", outChannelLayout, 0);
FFmpegInvoke.av_opt_set_int(swrContextPtr, "in_sample_rate", inCodecContextPtr->sample_rate, 0);
FFmpegInvoke.av_opt_set_int(swrContextPtr, "out_sample_rate", 44100, 0);
// allock output frane
/* 45 */
outFramePtr = FFmpegInvoke.av_frame_alloc();
outFramePtr->channel_layout = (ulong)outChannelLayout;
outFramePtr->sample_rate = 44100;
outFramePtr->format = (int)outSampleFormat;
// config done, init
FFmpegInvoke.swr_init(swrContextPtr);
bool frameFinished;
// read frames from the file
while (FFmpegInvoke.av_read_frame(inFormatContextPtr, packetPtr) >= 0)
{
AVPacket* origPacketPtr = packetPtr;
try
{
if (packetPtr->stream_index != inAudioStreamIndex)
continue;
do
{
byte[] decodedFrame;
int decodedBytes = this.DecodePacket(inCodecContextPtr,
packetPtr,
inFramePtr,
swrContextPtr,
outFramePtr,
out frameFinished,
out decodedFrame);
if (decodedBytes < 0)
break;
output.Write(decodedFrame, 0, decodedFrame.Length);
packetPtr->data += decodedBytes;
packetPtr->size -= decodedBytes;
} while (packetPtr->size > 0);
}
finally
{
FFmpegInvoke.av_free_packet(origPacketPtr);
}
}
// flush cached frames
packetPtr->data = null;
packetPtr->size = 0;
do
{
byte[] decodedFrame;
this.DecodePacket(inCodecContextPtr, packetPtr, inFramePtr, swrContextPtr, outFramePtr, out frameFinished, out decodedFrame);
if (decodedFrame != null)
output.Write(decodedFrame, 0, decodedFrame.Length);
} while (frameFinished);
}
finally
{
/* 45 */
if (outFramePtr != null)
FFmpegInvoke.av_frame_free(&outFramePtr);
/* 4 */
if (swrContextPtr != null)
FFmpegInvoke.swr_free(&swrContextPtr);
/* 38 */
if (inFramePtr != null)
FFmpegInvoke.av_frame_free(&inFramePtr);
/* 37 */
if (inCodecContextPtr != null)
FFmpegInvoke.avcodec_close(inCodecContextPtr);
/* 36 */
if (inCodecContextPtr != null)
FFmpegInvoke.avcodec_free_context(&inCodecContextPtr);
/* 35 */
if (inFomatContextOpenResult == 0)
FFmpegInvoke.avformat_close_input(&inFormatContextPtr);
/* 3 */
if (inIoContextPtr != null)
FFmpegInvoke.av_freep(&inIoContextPtr);
//* 2 */
if (inIoBuffer != null)
FFmpegInvoke.av_freep(&inIoBuffer);
/* 1 */
// This is called by avformat_close_input
if (inFormatContextPtr != null)
FFmpegInvoke.avformat_free_context(inFormatContextPtr);
}
}
private unsafe int DecodePacket(AVCodecContext* audioDecoderContextPtr, AVPacket* packetPtr, AVFrame* inFramePtr, SwrContext* swrContextPtr, AVFrame* outFramePtr, out bool frameDecoded, out byte[] decodedFrame)
{
decodedFrame = null;
/* decode audio frame */
int gotFrame;
int readBytes = FFmpegInvoke.avcodec_decode_audio4(audioDecoderContextPtr, inFramePtr, &gotFrame, packetPtr);
if (readBytes < 0)
throw new ApplicationException("Error decoding audio frame: " + readBytes.ToString(CultureInfo.InvariantCulture));
frameDecoded = gotFrame != 0;
/* Some audio decoders decode only part of the packet, and have to be
* called again with the remainder of the packet data.
* Sample: fate-suite/lossless-audio/luckynight-partial.shn
* Also, some decoders might over-read the packet. */
int decoded = Math.Min(readBytes, packetPtr->size);
if (frameDecoded)
{
if (FFmpegInvoke.swr_convert_frame(swrContextPtr, outFramePtr, inFramePtr) != 0)
throw new ApplicationException("Failed to convert frame.");
long delay;
do
{
int unpaddedLinesize = outFramePtr->nb_samples * outFramePtr->channels * FFmpegInvoke.av_get_bytes_per_sample((AVSampleFormat)outFramePtr->format);
IntPtr dataPtr = new IntPtr(outFramePtr->extended_data[0]);
decodedFrame = new byte[unpaddedLinesize];
Marshal.Copy(dataPtr, decodedFrame, 0, unpaddedLinesize);
// check if we have more samples to convert for this frame
delay = FFmpegInvoke.swr_get_delay(swrContextPtr, 44100);
if (delay > 0)
{
if (FFmpegInvoke.swr_convert_frame(swrContextPtr, outFramePtr, null) != 0)
throw new ApplicationException("Failed to convert frame.");
}
} while (delay > 0);
}
return decoded;
}
}The failing line is :
FFmpegInvoke.av_freep(&inIoBuffer);