Extracting values from a char variable
Afficher commentaires plus anciens
I am running FFmpeg through the system() function and the output is being stored within a char variable cmdout. I have added minimal reproducible code.
cmdout = "Guessed Channel Layout for Input Stream #0.0 : monoInput #0, wav, from 'testwav.wav': Duration: 00:00:02.92, bitrate: 256 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/sStream mapping: Stream #0:0 -> #0:0 (pcm_s16le (native) -> opus (libopus))Press [q] to stop, [?] for helpOutput #0, opus, to 'test.opus': Metadata: encoder : Lavf59.27.100 Stream #0:0: Audio: opus, 16000 Hz, mono, s16, 8 kb/s Metadata: encoder : Lavc59.37.100 libopussize= 0kB time=00:00:00.12 bitrate= 8.8kbits/s speed=N/A size= 13kB time=00:00:02.92 bitrate= 35.8kbits/s speed= 241x video:0kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.397972%bench: utime=0.000s stime=0.016s rtime=0.012sbench: maxrss=14764kB";
This is how it displayed on the command window (without the %).
%Guessed Channel Layout for Input Stream #0.0 : mono
%Input #0, wav, from 'testwav.wav':
% Duration: 00:00:02.92, bitrate: 256 kb/s
% Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
%Stream mapping:
% Stream #0:0 -> #0:0 (pcm_s16le (native) -> opus (libopus))
%Press [q] to stop, [?] for help
%Output #0, opus, to 'test.opus':
% Metadata:
% encoder : Lavf59.27.100
% Stream #0:0: Audio: opus, 16000 Hz, mono, s16, 8 kb/s
% Metadata:
% encoder : Lavc59.37.100 libopus
%size= 0kB time=00:00:00.12 bitrate= 8.8kbits/s speed=N/A
%size= 13kB time=00:00:02.92 bitrate= 35.8kbits/s speed= 241x
%video:0kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.397972%
%bench: utime=0.000s stime=0.016s rtime=0.012s
%bench: maxrss=14764kB
I am trying to extract out the values of the following
- 'Duration: 00:00:02.92'
- 'bitrate: 256'
- 'Stream #0:0: Audio: opus, 16000 Hz, mono, s16, 8 kb/s'
- 'encoder : Lavc59.37.100 libopus'
- 'utime=0.000'
- 'stime=0.016'
- 'rtime=0.012'
So far I have I am currently using the regexp() function to extract out the values into a struct.
Values = regexp(cmdout,'(?<utime>utime=.{5})','names'); % Only one working so far
for k = 1:length(Values)
disp(Values(k))
end
I have been unable to add multiple regex statements without it failing to find anything. I was also not sure if it was possible to have the struct just store the actual value e.g. utime: '0.000' rather than how it currently also contains the text.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Audio and Video Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!