decode

ffmpeg decoding slow calling without avformat_find_stream_info

蹲街弑〆低调 提交于 2021-02-08 00:19:43
问题 I am decoding h264 rtp stream with ffmpeg on android. I found a strange problem: if I don't call avformat_find_stream_info ,decoding P frame takes tens of micro seconds, by contrast, calling avformat_find_stream_info before decoding will reduce P frame decoding time to less than 1 ms on average. However, avformat_find_stream_info itself is time consuming on network streams. Are there anything I can do to make decoding fast without calling avformat_find_stream_info ? 回答1: When avformat_find

h264 ffmpeg: How to initialize ffmpeg to decode NALs created with x264

笑着哭i 提交于 2021-02-07 10:58:58
问题 I have encoded some frames using x264, using x264_encoder_encode and after that I have created AVPackets using a function like this: bool PacketizeNals( uint8_t* a_pNalBuffer, int a_nNalBufferSize, AVPacket* a_pPacket ) { if ( !a_pPacket ) return false; a_pPacket->data = a_pNalBuffer; a_pPacket->size = a_nNalBufferSize; a_pPacket->stream_index = 0; a_pPacket->flags = AV_PKT_FLAG_KEY; a_pPacket->pts = int64_t(0x8000000000000000); a_pPacket->dts = int64_t(0x8000000000000000); } I call this

How to decode base64 String directly to binary audio format

旧时模样 提交于 2021-02-07 05:51:07
问题 Audio file is sent to us via API which is Base64 encoded PCM format. I need to convert it to PCM and then WAV for processing. I was able to decode -> save to pcm -> read from pcm -> save as wav using the following code. decoded_data = base64.b64decode(data, ' /') with open(pcmfile, 'wb') as pcm: pcm.write(decoded_data) with open(pcmfile, 'rb') as pcm: pcmdata = pcm.read() with wave.open(wavfile, 'wb') as wav: wav.setparams((1, 2, 16000, 0, 'NONE', 'NONE')) wav.writeframes(pcmdata) It'd be a

Swift: casting un-constrained generic type to generic type that confirms to Decodable

淺唱寂寞╮ 提交于 2021-01-29 11:08:10
问题 Situation I have a two generic classes which will fetch data either from api and database, lets say APIDataSource<I, O> and DBDataSource<I, O> respectively I will inject any of two class in view-model when creating it and view-model will use that class to fetch data it needed. I want view-model to work exactly same with both class. So I don't want different generic constraints for the classes // sudo code ViewModel(APIDataSource <InputModel, ResponseModel>(...)) // I want to change the

Creating Decode Path from JSON Data in Swift that Includes Numbers and Hyphens?

与世无争的帅哥 提交于 2021-01-29 09:32:13
问题 this is relatively new to me and I've searched high and low but have been unsuccessful in finding a similar scenario. I have retrieved some JSON Data from an API URL and have successfully decoded and output various values from this data as strings by parsing the data to a separate sheet and using structs and constants with the 'Decodable' value set. The problem I have is that one of the containers in the Json data is a hyphenated date in this format dates['2020-11-04'] so swift will not let

How to read (decode) .tfrecords file, see the images inside and do augmentation?

孤人 提交于 2021-01-29 02:40:22
问题 I have a .tfrecords file and I want to extract, see the images in the file and augment them. I am using https://colab.research.google.com TensorFlow version: 2.3.0 And for the following code raw_dataset = tf.data.TFRecordDataset("*path.tfrecords") for raw_record in raw_dataset.take(1): example = tf.train.Example() example.ParseFromString(raw_record.numpy()) print(example) I am facing the following output: features { feature { key: "depth" value { int64_list { value: 3 } } } feature { key:

get String from nested Map in dart

别来无恙 提交于 2021-01-28 04:10:21
问题 My Map: {Info: {name: Austin, Username: austinr}} I'm using this line to get the myName variable to be set as "Austin" String myName = map["name"] as String; However.. this line seems to set the string "myName" to null. just looking for a way to extract my name and Username from the map Thanks 回答1: I am able to run the following code successfully. var map = {"Info":{"name": "Austin", "Username": "austinr"}}; String myString = map["Info"]["name"] as String; print(myString); The output is

How to parse out unescaped single quote ' from json string in javascript Google Translate

為{幸葍}努か 提交于 2021-01-27 19:13:31
问题 I am calling google translate api and getting back strings that are not fully decoded. In particular, I am seeing ' where single quotes should be. For example: { "q": "det är fullt", "target": "en" } Returns { "data": { "translations": [ { "translatedText": "It&\#39;s full", "detectedSourceLanguage": "sv" } ] } } I would have expected JSON.parse to take care of this, but it does not. Is there some other native function I need to be calling? My current fix is to fix this using a regex .replace

How to decode a Gzip Http Response in Flutter?

倖福魔咒の 提交于 2021-01-23 02:00:19
问题 I am new to Flutter. I am making a Network Request and I am getting the correct response, but the data is Gzipped. I have decompressed the same in Swift, but with Flutter, I am unable to do that. Can anyone please help? Here's what I have tried: import 'dart:convert'; import 'package:http/http.dart'; import 'package:archive/archive.dart'; import 'package:flutter_app/Constants/constants.dart'; class ServiceHelper { static final sharedInstance = ServiceHelper(); Future<Response> sendRequest(

How to decode a Gzip Http Response in Flutter?

柔情痞子 提交于 2021-01-23 02:00:08
问题 I am new to Flutter. I am making a Network Request and I am getting the correct response, but the data is Gzipped. I have decompressed the same in Swift, but with Flutter, I am unable to do that. Can anyone please help? Here's what I have tried: import 'dart:convert'; import 'package:http/http.dart'; import 'package:archive/archive.dart'; import 'package:flutter_app/Constants/constants.dart'; class ServiceHelper { static final sharedInstance = ServiceHelper(); Future<Response> sendRequest(