
Recherche avancée
Médias (1)
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (59)
-
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (8789)
-
What should I do to handle audio&video in a radio automation software ?
24 avril 2023, par TheDaChickenI am currently working on a program that can be deemed as a "radio automation software."
Radio automation software focuses on audio. It may split audio frames and crossfade between different audio sources.


I want to continue by adding video support for music videos. This makes it not completely about audio.


There is a problem with this. Having audio porition do it's thing while video can be added along side it is difficult. For example, having access to the previous track to be able to crossfade & preloading the song.


This is what I currently have which is being run in a thread.


int ret;
int tryCounter{0};
int64_t end_pts{AV_NOPTS_VALUE};
int64_t end_duration{AV_NOPTS_VALUE};
while(true) {
 std::shared_ptr<cmessage> message;

 ret = queue.Get(message, MessageQueue::MessageQueueFlags::MSQ_NON_BLOCK);
 if (ret < 0) {
 if(ret == MessageQueue::MessageQueueRET::MSQ_STOPPED)
 break;
 Logger::Log(LOGWARNING, "Playback thread received: {}", ret);
 break;
 }

 if (ret == MessageQueue::MessageQueueRET::MSQ_OK && message) {
 if (message->IsType(CMessage::PLAY_SONG)) {
 /* It was requested for the Player to play a new song */
 std::shared_ptr<cmessageplaysong> songMsg = std::static_pointer_cast<cmessageplaysong>(message);
 // steal session :D
 std::unique_ptr<playersession> playerSession = std::move(songMsg->GetSession());
 if (!playerSession->GetTrack()) {
 Logger::Log(LOGWARNING, "PlaybackThread: Ignoring playback song event due to null track");
 goto SEND_NEXT_SONG;
 }
 if(!playerSession->GetPlaylist())
 playerSession->SetPlaylist(m_player->GetPlaylist());
 if (playerSession->IsPreloaded())
 Logger::Log(LOGDEBUG, "PlaybackThread: Received preloaded track.");

 // load track if not loaded already
 if (!playerSession->Open(playerSession->GetTrack(),
 m_info)) {
 Logger::Log(LOGERROR, "Failed to open input");
 goto SEND_NEXT_SONG;
 }

 preloadRequestSent = false;
 m_nextSession = nullptr;

 std::shared_ptr<track> track = playerSession->GetTrack();
 track->start_sample = m_player->GetMainOutput()->GetWrittenSamples();
 track->played = true;
 // Send current song position to callback thread for the callback function to be run when song starts playing
 m_player->SendSongPosition(playerSession->GetTrack(), playerSession->GetPlaylist(),
 playerSession->GetTrackPosition());

 // Grab the old one
 std::unique_ptr<playersession> oldSession = std::move(m_currentSession);
 // Set current audio instance to this input
 m_currentSession.swap(playerSession);

 // Crossfade :D
 ret = CrossFade(oldSession, m_currentSession);
 if (ret == STREAM_MAX) {
 // when the new song goes brrrrr.
 // this rarely happens anyway SOO
 m_currentSession.swap(oldSession);
 goto SEND_NEXT_SONG;
 }

 end_pts = AV_NOPTS_VALUE;
 end_duration = m_currentSession->GetDuration();
 if(m_currentSession->GetTrack()->info.segue_time != AV_NOPTS_VALUE)
 {
 end_duration = m_currentSession->GetTrack()->info.segue_time;
 // this is end duration for max samples :D
 // this variable is dependent on timebase
 end_pts = av_rescale_q(end_duration, CPPAV_TIME_BASE_Q, m_currentSession->GetTimeBase());
 }
 }
 if (message->IsType(CMessage::NEXT_SONG)) {
 /* request for the thread to play song next */
 std::shared_ptr<cmessagenextsong> messageNextSong = std::static_pointer_cast<cmessagenextsong>(message);
 // steal session :D
 m_nextSession = std::move(messageNextSong->GetSession());
 }
 }

 if (!m_currentSession) {
 /* wait until there is a track that can be played */
 /* during this, portaudio should not be opened */
 m_player->GetMainOutput()->OpenPlayback(false);
 std::this_thread::sleep_for(std::chrono::milliseconds(50));
 continue;
 }
 /* there is input so output should be active */
 if (!m_player->GetMainOutput()->IsActive()) {
 m_player->GetMainOutput()->OpenPlayback(true);
 }

 ret = m_currentSession->Decode(m_frame, end_pts);
 if (ret == STREAM_WAIT) {
 continue;
 } else if (ret == STREAM_EOF || ret == STREAM_MAX) {
 SEND_NEXT_SONG:
 if(m_player->GetCurrentTrack())
 m_player->GetCurrentTrack()->end_sample = m_player->GetMainOutput()->GetWrittenSamples();
 // Wait until the next song is in the queue for playback
 QueueNextSong(false);
 continue;
 }
 else if (ret == STREAM_ERROR) { // check & handle errors
 tryCounter++;
 Logger::Log(LOGERROR, "Decoder replied: Error try counter: {}/{}",
 tryCounter, MAX_ERROR_COUNTER);
 if (tryCounter >= MAX_ERROR_COUNTER) {
 goto SEND_NEXT_SONG;
 }
 continue;
 }
 tryCounter = 0;

 int64_t timestamp = 0;
 if (m_frame->GetPTS() != AV_NOPTS_VALUE) // must convert timestamp to static time base :D makes things easier
 timestamp = av_rescale_q(m_frame->GetPTS(), m_frame->GetTimeBase(), CPPAV_TIME_BASE_Q);

 // Check if track is about to end to preload next track
 // TODO make 3 changeable for preloading :)))
 if (!preloadRequestSent && timestamp >= end_duration - (3 * AV_TIME_BASE)) {
 Logger::Log(LOGDEBUG, "Sending next track to preload thread");
 if (QueueNextSong(true))
 preloadRequestSent = true;
 }

 // Write frame into ringbuffer
 ret = m_player->WriteFrame(m_frame);
 assert(ret != STREAM_EOF);
 // Clean out frame :)
 m_frame->Reset();
 }
</cmessagenextsong></cmessagenextsong></playersession></track></playersession></cmessageplaysong></cmessageplaysong></cmessage>


It seems awkward already. I have a huge amount of code for preparing the song. I have to keep track of the end duration and the next song. I have to keep track of the playlist. I am using PlayerSession to grab audio frames, handle all audio packet decoding, resampling to a constant sample rate. I don't think that is going to be viable to keep.


-
how spotify and other music players implement cross fading between music
11 janvier 2023, par Arihant JainI was working on a media streaming project and thought of implementing a cross fade between the next and current playing song.


HLS is used for streaming music and .m3u8 file is presigned by cloudfront.


Any help will be appreciated.


-
FileNotFoundError : [Errno 2] No such file or directory : 'ffmpeg'
9 février 2021, par stackoverflowI'm new in python and i'm using
pydub
modules to play mp3 track.


Here is my simple code to play mp3 :



#Let's play some mp3 files using python!

from pydub import AudioSegment
from pydub.playback import play

song = AudioSegment.from_mp3("/media/rajendra/0C86E11786E10256/05_I_Like_It_Rough.mp3")
play(song)




When i run this program, it says :



*/usr/bin/python3.4 /home/rajendra/PycharmProjects/pythonProject5/myProgram.py
/usr/local/lib/python3.4/dist-packages/pydub/utils.py:161: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
 warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
/usr/local/lib/python3.4/dist-packages/pydub/utils.py:174: RuntimeWarning: Couldn't find ffplay or avplay - defaulting to ffplay, but may not work
 warn("Couldn't find ffplay or avplay - defaulting to ffplay, but may not work", RuntimeWarning)
Traceback (most recent call last):
 File "/home/rajendra/PycharmProjects/pythonProject5/myProgram.py", line 11, in <module>
 song = AudioSegment.from_mp3("/media/rajendra/0C86E11786E10256/05_I_Like_It_Rough.mp3")
 File "/usr/local/lib/python3.4/dist-packages/pydub/audio_segment.py", line 355, in from_mp3
 return cls.from_file(file, 'mp3')
 File "/usr/local/lib/python3.4/dist-packages/pydub/audio_segment.py", line 339, in from_file
 retcode = subprocess.call(convertion_command, stderr=open(os.devnull))
 File "/usr/lib/python3.4/subprocess.py", line 533, in call
 with Popen(*popenargs, **kwargs) as p:
 File "/usr/lib/python3.4/subprocess.py", line 848, in __init__
 restore_signals, start_new_session)
 File "/usr/lib/python3.4/subprocess.py", line 1446, in _execute_child
 raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

Process finished with exit code 1*
</module>



Please help me ! I've checked everything path but it's not working. I'm currently using Ubuntu.



Help would be appreciated !