
Recherche avancée
Autres articles (61)
-
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Sélection de projets utilisant MediaSPIP
29 avril 2011, parLes exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
Ferme MediaSPIP @ Infini
L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)
Sur d’autres sites (4530)
-
How to send libmmpeg AVPacket through WebRTC (using libdatachannel)
29 mars 2022, par mikeI'm encoding a video frame with the
ffmpeg
libraries, generating anAVPacket
with compressed data.

Thanks to some recent advice here on S/O, I am trying to send that frame over a network using the
WebRTC
librarylibdatachannel
, specifically by adapting the example here :

https://github.com/paullouisageneau/libdatachannel/tree/master/examples/streamer


I am seeing problems inside
h264rtppacketizer.cpp
(part of the library, not the example) which are almost certainly to do with how I'm providing the sample data.
(I don't think that this is anything to do with libdatachannel specifically, it will be an issue with what I'm sending)

The example code reads each encoded frame from a file, and populates a
sample
by setting the content of the file to the contents of the file :

sample = *reinterpret_cast *>(&fileContents);


sample
is just astd::vector<byte>;</byte>


I have naively copied the contents of an
AVPacket->data
pointer into thesample
vector :

sample.resize(pkt->size);
memcpy(sample.data(), pkt->data, pkt->size * sizeof(std::byte)); 



but the packetizer is falling over when trying to get length values out of that data.
Specifically, in the following code, the first iteration gets a length of 1, but the second, looking up index 5, gives 1119887324. This is way too big for my data, which is only 3526 bytes (the whole frame is a single colour so likely to be small once encoded) :


while (index < message->size()) {
assert(index + 4 < message->size());
auto lengthPtr = (uint32_t *)(message->data() + index);
uint32_t length = ntohl(*lengthPtr);
auto naluStartIndex = index + 4;
auto naluEndIndex = naluStartIndex + length;
assert(naluEndIndex <= message->size()); 
 
auto begin = message->begin() + naluStartIndex;
auto end = message->begin() + naluEndIndex;
nalus->push_back(std::make_shared<nalunit>(begin, end));
index = naluEndIndex;
}
</nalunit>


Here is a dump of


uint32_t length = ntohl(*lengthPtr);



for the first few elements of the message (
*lengthPtr
in parentheses) :

[2022-03-29 15:12:01.182] [info] index 0: 1 (16777216)
[2022-03-29 15:12:01.183] [info] index 1: 359 (1728118784)
[2022-03-29 15:12:01.184] [info] index 2: 91970 (1114046720)
[2022-03-29 15:12:01.186] [info] index 3: 23544512 (3225577217)
[2022-03-29 15:12:01.186] [info] index 4: 1732427807 (532693607)
[2022-03-29 15:12:01.187] [info] index 5: 1119887324 (3693068354)
[2022-03-29 15:12:01.188] [info] index 6: 3223313413 (98312128)
[2022-03-29 15:12:01.188] [info] index 7: 534512896 (384031)
[2022-03-29 15:12:01.188] [info] index 8: 3691315291 (1526728156)
[2022-03-29 15:12:01.189] [info] index 9: 83909537 (2707095557)
[2022-03-29 15:12:01.189] [info] index 10: 6004992 (10574592)
[2022-03-29 15:12:01.190] [info] index 11: 1537277952 (41307)
[2022-03-29 15:12:01.190] [info] index 12: 2701131779 (50331809)
[2022-03-29 15:12:01.192] [info] index 13: 768 (196608)



(I know I should post a complete sample, I am working on it)


- 

-
I am fairly sure I am just missing something basic. E.g. am I supposed to do something with the
AVPacket
side_data
, does AVPacket have or miss some header info ?

-
If I just fwrite the
pkt->data
for a single frame to disk, I can read the codec information with ffprobe :







Input #0, h264, from 'encodedOut.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1280x720, 30 tbr, 1200k tbn



- 

- whereas the same for the example input files (again a single frame) gives the following :




[h264 @ 000001c88d1135c0] Format h264 detected only with low score of 1, misdetection possible!
[h264 @ 000001c88f337400] missing picture in access unit with size 85306
[extract_extradata @ 000001c88d11ee40] No start code is found.
sample-0.h264: Invalid data found when processing input



-
-
FFMPEG audio not delaying properly
1er avril 2022, par Spartan 117I am trying to mix two audio files together, with one audio being delayed. Here are the file details


Audio 1 - https://pastebin.com/vkYsH88e, "startTime" : "03/23/2022 21:20:27", "endTime" : "03/24/2022 01:06:11"


Audio 2 - https://pastebin.com/Gs4V96GQ, "startTime" : "03/24/2022 01:05:30", "endTime" : "03/24/2022 04:21:41"


As you can see from the paste bin and the json property, Audio two starts about 3 hours and 45 minutes after Audio one, here is how i am trying to mix them


ffmpeg -i RTb295d0534191e1acb22a45bb971a12e6.mka -i RT103bfe5f4b129860f69cd8e820f3a10b.mka -filter_complex "[1:a]adelay=13500s:all=1[apad]; [0:a][apad]amix=inputs=2:weights=1|1[aout]" -map [aout] combined_audio.mka



Here is the output of that mixture - https://pastebin.com/KAsw0905


Files have been uploaded here, if anyone wants to test - https://easyupload.io/m/xveng4


The issue i'm having ? Based on the parameters provided, the 2nd audio file should start playing after 3 hours and 45 minutes. Instead, it plays after 5 hours and 45 minutes. I'm new to FFMPEG and have been having trouble figuring this out. Any ideas ?


-
How to get the first audio channel from a video with ffmpeg-python ?
31 mai 2022, par giskI would like to get the very first audio channel from a video using ffmpeg-python.


I tried with this :


out, _ = (
 ffmpeg
 .input(filename)
 .output('pipe:', loglevel=0, format='s16le', acodec='pcm_s16le', ac=1, ar='8k')
 .run(capture_stdout=True)
 )
 """ extract audio signal """
 self.signal = (
 np
 .frombuffer(out, np.int16) 
 )



but I am not sure whether this is correct.


I had a look here, but I could not find a solution : https://trac.ffmpeg.org/wiki/AudioChannelManipulation


Any suggestion ? Thanks !


EDIT :


I tried @rotem solution and it seems to work. However, I have another issue which seems related to the -ac flag. For some videos, the numpy output has the right length (i.e., it matches the original audio length). For others, I get a wrong one. However, if I set -ac to 2 for these videos, I get the correct signal length. Do you know why is this happening ?


This is the metadata of the video (duration : 2 minutes and 11 seconds) which outputs the correct numpy array size with setting -ac to 2


'streams' : ['index' : 0, 'codec_name' : 'h264', 'codec_long_name' : 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'profile' : 'High', 'codec_type' : 'video', 'codec_tag_string' : 'avc1', 'codec_tag' : '0x31637661', 'width' : 1920, 'height' : 1080, 'coded_width' : 1920, 'coded_height' : 1080, 'closed_captions' : 0, 'film_grain' : 0, 'has_b_frames' : 0, 'pix_fmt' : 'yuv420p', 'level' : 40, 'color_range' : 'tv', 'color_space' : 'bt709', 'color_transfer' : 'bt709', 'color_primaries' : 'bt709', 'chroma_location' : 'left', 'field_order' : 'progressive', 'refs' : 1, 'is_avc' : 'true', 'nal_length_size' : '4', 'id' : '0x1', 'r_frame_rate' : '30/1', 'avg_frame_rate' : '176805000/5894849', 'time_base' : '1/90000', 'start_pts' : 0, 'start_time' : '0.000000', 'duration_ts' : 11789698, 'duration' : '130.996644', 'bit_rate' : '16999840', 'bits_per_raw_sample' : '8', 'nb_frames' : '3929', 'extradata_size' : 34, 'disposition' : 'default' : 1, 'dub' : 0, 'original' : 0, 'comment' : 0, 'lyrics' : 0, 'karaoke' : 0, 'forced' : 0, 'hearing_impaired' : 0, 'visual_impaired' : 0, 'clean_effects' : 0, 'attached_pic' : 0, 'timed_thumbnails' : 0, 'captions' : 0, 'descriptions' : 0, 'metadata' : 0, 'dependent' : 0, 'still_image' : 0, 'tags' : 'creation_time' : '2022-05-30T15:00:39.000000Z', 'language' : 'eng', 'handler_name' : 'VideoHandle', 'vendor_id' : '[0][0][0][0]', 'index' : 1, 'codec_name' : 'aac', 'codec_long_name' : 'AAC (Advanced Audio Coding)', 'profile' : 'LC', 'codec_type' : 'audio', 'codec_tag_string' : 'mp4a', 'codec_tag' : '0x6134706d', 'sample_fmt' : 'fltp', 'sample_rate' : '48000', 'channels' : 2, 'channel_layout' : 'stereo', 'bits_per_sample' : 0, 'id' : '0x2', 'r_frame_rate' : '0/0', 'avg_frame_rate' : '0/0', 'time_base' : '1/48000', 'start_pts' : 696, 'start_time' : '0.014500', 'duration_ts' : 6285214, 'duration' : '130.941958', 'bit_rate' : '256004', 'nb_frames' : '6138', 'extradata_size' : 2, 'disposition' : 'default' : 1, 'dub' : 0, 'original' : 0, 'comment' : 0, 'lyrics' : 0, 'karaoke' : 0, 'forced' : 0, 'hearing_impaired' : 0, 'visual_impaired' : 0, 'clean_effects' : 0, 'attached_pic' : 0, 'timed_thumbnails' : 0, 'captions' : 0, 'descriptions' : 0, 'metadata' : 0, 'dependent' : 0, 'still_image' : 0, 'tags' : 'creation_time' : '2022-05-30T15:00:39.000000Z', 'language' : 'eng', 'handler_name' : 'SoundHandle', 'vendor_id' : '[0][0][0][0]'], 'format' : 'filename' : 'videos4/test_01.mp4', 'nb_streams' : 2, 'nb_programs' : 0, 'format_name' : 'mov,mp4,m4a,3gp,3g2,mj2', 'format_long_name' : 'QuickTime / MOV', 'start_time' : '0.000000', 'duration' : '130.996600', 'size' : '282621379', 'bit_rate' : '17259768', 'probe_score' : 100, 'tags' : 'major_brand' : 'mp42', 'minor_version' : '0', 'compatible_brands' : 'isommp42', 'creation_time' : '2022-05-30T15:00:39.000000Z', 'com.android.version' : '12', 'com.android.capture.fps' : '30.000000'.


This is instead, the metadata of the video (duration 5 minutes) which gives the right result length with setting -ac to 1 :


'streams' : ['index' : 0, 'codec_name' : 'h264', 'codec_long_name' : 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'profile' : 'High', 'codec_type' : 'video', 'codec_tag_string' : 'avc1', 'codec_tag' : '0x31637661', 'width' : 1920, 'height' : 1080, 'coded_width' : 1920, 'coded_height' : 1080, 'closed_captions' : 0, 'film_grain' : 0, 'has_b_frames' : 0, 'sample_aspect_ratio' : '1:1', 'display_aspect_ratio' : '16:9', 'pix_fmt' : 'yuv420p', 'level' : 40, 'field_order' : 'progressive', 'refs' : 1, 'is_avc' : 'true', 'nal_length_size' : '4', 'id' : '0x1', 'r_frame_rate' : '30/1', 'avg_frame_rate' : '33862500/1128779', 'time_base' : '1/90000', 'start_pts' : 0, 'start_time' : '0.000000', 'duration_ts' : 27090696, 'duration' : '301.007733', 'bit_rate' : '16999542', 'bits_per_raw_sample' : '8', 'nb_frames' : '9030', 'extradata_size' : 26, 'disposition' : 'default' : 1, 'dub' : 0, 'original' : 0, 'comment' : 0, 'lyrics' : 0, 'karaoke' : 0, 'forced' : 0, 'hearing_impaired' : 0, 'visual_impaired' : 0, 'clean_effects' : 0, 'attached_pic' : 0, 'timed_thumbnails' : 0, 'captions' : 0, 'descriptions' : 0, 'metadata' : 0, 'dependent' : 0, 'still_image' : 0, 'tags' : 'language' : 'und', 'handler_name' : 'VideoHandler', 'vendor_id' : '[0][0][0][0]', 'side_data_list' : ['side_data_type' : 'Display Matrix', 'displaymatrix' : '\n00000000 : 0 65536 0\n00000001 : -65536 0 0\n00000002 : 0 0 1073741824\n', 'rotation' : -90], 'index' : 1, 'codec_name' : 'aac', 'codec_long_name' : 'AAC (Advanced Audio Coding)', 'profile' : 'LC', 'codec_type' : 'audio', 'codec_tag_string' : 'mp4a', 'codec_tag' : '0x6134706d', 'sample_fmt' : 'fltp', 'sample_rate' : '48000', 'channels' : 2, 'channel_layout' : 'stereo', 'bits_per_sample' : 0, 'id' : '0x2', 'r_frame_rate' : '0/0', 'avg_frame_rate' : '0/0', 'time_base' : '1/48000', 'start_pts' : 0, 'start_time' : '0.000000', 'duration_ts' : 14448640, 'duration' : '301.013333', 'bit_rate' : '256000', 'nb_frames' : '14110', 'extradata_size' : 2, 'disposition' : 'default' : 1, 'dub' : 0, 'original' : 0, 'comment' : 0, 'lyrics' : 0, 'karaoke' : 0, 'forced' : 0, 'hearing_impaired' : 0, 'visual_impaired' : 0, 'clean_effects' : 0, 'attached_pic' : 0, 'timed_thumbnails' : 0, 'captions' : 0, 'descriptions' : 0, 'metadata' : 0, 'dependent' : 0, 'still_image' : 0, 'tags' : 'language' : 'und', 'handler_name' : 'SoundHandler', 'vendor_id' : '[0][0][0][0]'], 'format' : 'filename' : 'videos4/video_02.mp4', 'nb_streams' : 2, 'nb_programs' : 0, 'format_name' : 'mov,mp4,m4a,3gp,3g2,mj2', 'format_long_name' : 'QuickTime / MOV', 'start_time' : '0.000000', 'duration' : '301.014000', 'size' : '649577064', 'bit_rate' : '17263703', 'probe_score' : 100, 'tags' : 'major_brand' : 'isom', 'minor_version' : '512', 'compatible_brands' : 'isomiso2avc1mp41', 'encoder' : 'Lavf58.27.103'