小编Moc*_*tan的帖子

使用ffmpeg编码AAC(c ++)

我正在研究将在Unity插件中使用的视频编码.我已经使图像编码工作,但现在我在音频.所以只尝试将音频输入到具有AAC编码的mp4文件中.而且我被困住了.生成的文件不包含任何内容.另外,根据我的理解,ffmpeg中的AAC仅支持AV_SAMPLE_FMT_FLTP,这就是我使用它的原因.这是我的代码:

建立:

int initialize_encoding_audio(const char *filename)
{
    int ret;
    AVCodecID aud_codec_id = AV_CODEC_ID_AAC;
    AVSampleFormat sample_fmt = AV_SAMPLE_FMT_FLTP;

    avcodec_register_all();
    av_register_all();

    aud_codec = avcodec_find_encoder(aud_codec_id);
    avcodec_register(aud_codec);

    if (!aud_codec)
        return COULD_NOT_FIND_AUD_CODEC;

    aud_codec_context = avcodec_alloc_context3(aud_codec);
    if (!aud_codec_context)
        return CONTEXT_CREATION_ERROR;

    aud_codec_context->bit_rate = 192000;
    aud_codec_context->sample_rate = select_sample_rate(aud_codec);
    aud_codec_context->sample_fmt = sample_fmt;
    aud_codec_context->channel_layout = AV_CH_LAYOUT_STEREO;
    aud_codec_context->channels = av_get_channel_layout_nb_channels(aud_codec_context->channel_layout);

    aud_codec_context->codec = aud_codec;
    aud_codec_context->codec_id = aud_codec_id;

    ret = avcodec_open2(aud_codec_context, aud_codec, NULL);

    if (ret < 0)
        return COULD_NOT_OPEN_AUD_CODEC;

    outctx = avformat_alloc_context();
    ret = avformat_alloc_output_context2(&outctx, NULL, "mp4", filename);

    outctx->audio_codec = aud_codec;
    outctx->audio_codec_id = …
Run Code Online (Sandbox Code Playgroud)

c++ ffmpeg aac video-encoding

7
推荐指数
1
解决办法
2225
查看次数

特殊字符在Android手机的POST请求中消失

我已经建立了一个Android应用程序,让你在网站上发布你的名字,虽然我发送一个http POST请求到网站.问题是,我的客户中有90%是瑞典语,并且POST请求似乎会在字符串中包含特殊字符之后切断所有内容,包括特殊字符本身.

所以瑞典姓氏"Börjesson"变成了"B".

我的POST请求代码:

public static String execRequest(String url, Map<String, String> params)
{
    try {
        DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
        HttpPost httpPost = null;
        HttpGet httpGet = null;
        if(params == null || params.size() == 0) {
            httpGet = new HttpGet(url);
            httpGet.setHeader("Accept-Encoding", "UTF-8");
        }
        else {
            httpPost = new HttpPost(url);
            httpPost.setHeader("Accept-Encoding", "UTF-8");
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            for(String key: params.keySet()) {
                nameValuePairs.add(new BasicNameValuePair(key, params.get(key)));
            }
            httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        }
        HttpResponse httpResponse = (HttpResponse)defaultHttpClient.execute(httpPost == null ? httpGet : httpPost);
        HttpEntity httpEntity = …
Run Code Online (Sandbox Code Playgroud)

post android http-post special-characters

5
推荐指数
1
解决办法
3347
查看次数

Entity Framework Core,一对多关系,集合始终为空

我正在尝试在运行时通过 http 请求建立的 InMemory 数据库中建立一个简单的一对多关系。我是 Entity Framework Core 的新手,所以我不确定这是否是使用它的正确方法。

值控制器.cs

[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
    private readonly DataListContext _Context;
    public ValuesController(DataListContext context)
    {
        _Context = context;
    }

    [HttpGet]
    public ActionResult<IEnumerable<DataList>> Get()
    { 
        // Datas keeps is value
        Console.WriteLine("Root Count: " + _Context.RootDatas.Count());
        if (_Context.RootDataLists.Count() > 0)
        {
            // InsideDatas is always 
            Console.WriteLine("Inside Count: " + _Context.RootDataLists.First().InsideDatas.Count);empty next request
        }

        return _Context.RootDataLists.ToList();
    }

    [HttpPost]
    public void Post([FromBody] string value)
    {
        var data = new Data() { Id = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api entity-framework-core .net-core

1
推荐指数
1
解决办法
1155
查看次数