fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.97k stars 881 forks source link

no sound h265 to mp4. video by ip web cam #1244

Open Shablykinm opened 10 months ago

Shablykinm commented 10 months ago

Version information

Code to reproduce


const ffmpeg = require('fluent-ffmpeg');
const stream = require('stream');
const MemoryStream = require('memory-stream');
const Writable = require('stream').Writable;

class Converter {
    async wcam265ToMp4(buffer, filename) {
        const fs = require('fs')
        let outStream = new MemoryStream();
        //var outStream = fs.createWriteStream('output.mp4');
        //let bufferStream = new stream.PassThrough();
        return new Promise((resolve, reject) => {
            //console.log(buffer);
            console.log(filename);
            ffmpeg({
                source: stream.Readable.from(buffer, { objectMode: false })
              })
              .addOption('-c:v', 'libx265')
              .addOption('-movflags', 'faststart')
              .addOption('-movflags', 'frag_keyframe+empty_moov')
              .addOption('-f', 'mp4')
              .output(outStream, { end: true })
              .on('error', function (err, stdout, stderr) {
                console.log('Ошибка:', err);
                console.log('Стандартный вывод:', stdout);
                console.log('Стандартный поток ошибок:', stderr);
              })
              .on('end', function () {
                console.log('Закончено!');
                resolve(outStream.toBuffer());
              })
              .run();
        });
    }
}

module.exports = Converter;

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

I want to automate the conversion of video from .h265 to mp4 with sound, because the native converter only offers the possibility of individual conversion in manual mode. At the moment, ffmpeg converts without sound.

i have a ip cam. (​http://www.ipcam.xin/). The camera saves files with the n265 codec to FTP.(format *.265; filename A231210_161400_161414.265) If you open this file in any of the players, there is no sound. If you download the Chinese HIPLAYER(​http://www.ipcam.xin/), the video is played with sound.

Response from ffmpeg developers:

They put AAC into H265 SEI, and use invalid temporal_id.
you can:
1、Don't skip those data
2、Add something to ff_h2645_sei_message_decode to extract AAC.
FFmpeg support output multiple kinds of SEI along with AVFrame sidedata after decoding.
It can be a little too late to output AAC after video decoding, if the goal is to do A-V sync. There are other hacking methods to solve it.

Observed results

no sound in video h265 by ip web camera. is it possible to convert such files using your library?

link to my ticket with video in ffmpeg bug track https://trac.ffmpeg.org/ticket/10791

thank you!

Shablykinm commented 10 months ago

videoh265.zip player and converter.zip