question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Record to MP4 doesn't work

See original GitHub issue

Output:

2018-11-12 01:46:26 3108 [INFO] Node Media Server v1.4.7
2018-11-12 01:46:26 3108 [INFO] Node Media Rtmp Server started on port: 1935
2018-11-12 01:46:26 3108 [INFO] Node Media Http Server started on port: 8080
2018-11-12 01:46:26 3108 [INFO] Node Media WebSocket Server started on port: 8080
2018-11-12 01:46:26 3108 [INFO] Node Media Trans Server started for apps: [ vod ] , MediaRoot: ./media, ffmpeg version: 4.0.2
2018-11-12 01:46:29 3108 [INFO] [rtmp connect] id=P6UP2LJK ip=::1 app=vod args={"app":"vod","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf58.12.100)","tcUrl":"rtmp://localhost:1935/vod"}
2018-11-12 01:46:29 3108 [INFO] [rtmp publish] New stream. id=P6UP2LJK streamPath=/vod/STREAM_NAME streamId=1
2018-11-12 01:46:29 3108 [INFO] [Transmuxing MP4] /vod/STREAM_NAME to ./media/vod/STREAM_NAME/2018-11-12-01-46.mp4
2018-11-12 01:46:29 3108 [FFDEBUG] -y,-fflags,nobuffer,-analyzeduration,1000000,-i,rtmp://127.0.0.1:1935/vod/STREAM_NAME,-c:v,libx264,-c:a,aac,-f,tee,-map,0:a?,-map,0:v?,[movflags=faststart]./media/vod/STREAM_NAME/2018-11-12-01-46.mp4|
2018-11-12 01:46:29 3108 [FFDEBUG] FF输出:ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722

2018-11-12 01:46:29 3108 [FFDEBUG] FF输出:  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100

2018-11-12 01:46:29 3108 [INFO] [rtmp connect] id=PGESY7PL ip=::ffff:127.0.0.1 app=vod args={"app":"vod","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:1935/vod","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
2018-11-12 01:46:29 3108 [INFO] [rtmp play] Join stream. id=PGESY7PL streamPath=/vod/STREAM_NAME  streamId=1 
2018-11-12 01:46:30 3108 [INFO] [rtmp publish] Handle video. id=P6UP2LJK streamPath=/vod/STREAM_NAME frame_type=1 codec_id=7 codec_name=H264 512x288
2018-11-12 01:46:30 3108 [INFO] [rtmp publish] Handle audio. id=P6UP2LJK streamPath=/vod/STREAM_NAME sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
2018-11-12 01:46:31 3108 [FFDEBUG] FF输出:Input #0, flv, from 'rtmp://127.0.0.1:1935/vod/STREAM_NAME':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: 
2018-11-12 01:46:31 3108 [FFDEBUG] FF输出:isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    genre           : Animation
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    encoder         : Lavf58.12.100
  Duration: 00:00:00.00, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 512x288 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s

2018-11-12 01:46:31 3108 [FFDEBUG] FF输出:Stream mapping:
  Stream #0:1 -> #0:0 (aac (native) -> aac (native))
  Stream #0:0 -> #0:1 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help

2018-11-12 01:46:31 3108 [FFDEBUG] FF输出:frame=    0 fps=0.0 q=0.0 size=N/A time=-577014:32:22.77 bitrate=N/A speed=N/A    
2018-11-12 01:46:32 3108 [FFDEBUG] FF输出:frame=    0 fps=0.0 q=0.0 size=N/A time=-577014:32:22.77 bitrate=N/A speed=N/A    
2018-11-12 01:46:32 3108 [FFDEBUG] FF输出:frame=    0 fps=0.0 q=0.0 size=N/A time=-577014:32:22.77 bitrate=N/A speed=N/A    
2018-11-12 01:46:33 3108 [FFDEBUG] FF输出:frame=    0 fps=0.0 q=0.0 size=N/A time=-577014:32:22.77 bitrate=N/A speed=N/A    
2018-11-12 01:46:33 3108 [FFDEBUG] FF输出:frame=    0 fps=0.0 q=0.0 size=N/A time=-577014:32:22.77 bitrate=N/A speed=N/A    
2018-11-12 01:46:34 3108 [FFDEBUG] FF输出:Too many packets buffered for output stream 0:0.

2018-11-12 01:46:34 3108 [FFDEBUG] FF输出:[aac @ 000001bca9c9eac0] Qavg: 753.109
[aac @ 000001bca9c9eac0] 2 frames left in the queue on closing

2018-11-12 01:46:34 3108 [INFO] [rtmp play] Close stream. id=PGESY7PL streamPath=/vod/STREAM_NAME streamId=1
2018-11-12 01:46:34 3108 [INFO] [rtmp disconnect] id=PGESY7PL
2018-11-12 01:46:34 3108 [FFDEBUG] FF输出:Conversion failed!

2018-11-12 01:46:34 3108 [INFO] [Transmuxing end] /vod/STREAM_NAME

Configuration:

ffmpeg -re -i data/sample.mp4 -c:v libx264 -preset superfast -tune zerolatency -c:a aac -ar 44100 -f flv rtmp://localhost/vod/STREAM_NAME
const { NodeMediaServer } = require('node-media-server');

const config = {
    logType: 4,
    rtmp: {
        port: 1935,
        chunk_size: 60000,
        gop_cache: true,
        ping: 60,
        ping_timeout: 30
    },
    http: {
        port: 8080,
        mediaroot: './media',
        allow_origin: '*'
    },
    trans: {
        ffmpeg: 'D:\\ffmpeg\\ffmpeg.exe',
        tasks: [
            {
                app: 'vod',
                mp4: true,
                mp4Flags: '[movflags=faststart]',
            }
        ]
    }
};

const nms = new NodeMediaServer(config);
nms.run();

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

7reactions
Spo-okycommented, Jun 11, 2019

I’ve changed to this.ffmpeg_exec.stdin.write(‘q’) instead of ‘this.ffmpeg_exec.kill();’ as I’ve seen it on internet on “how to quit ffmpeg from nodejs”. It works for me… Hope it helps you.

0reactions
lonasozocommented, Nov 2, 2022

P.s. I’ve made the changes suggested in this issue, still have problems on bigger files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MP4 File Not Playing [Fixed] with 3 Advanced Solutions
One cause of problems with mp4 files that don't play is media players without proper codecs to run the format. In the case...
Read more >
How to Fix Can't Play Recorded Video? - Wondershare Repairit
The major reason why your recorded videos refuse to play is that they have been corrupted. Corruption, in turn, arise from different causes....
Read more >
Solved! - How to Fix Windows 10 Can't Play MP4
In this post, we will show you how to get rid of the Windows 10 can't play MP4 files/ MP4 files not playing...
Read more >
How To Solve VLC Won't Play MP4 Video Files - YouTube
In this video, we will show you How to Solve VLC Won't Play MP4 Video Files, if you want to convert video without...
Read more >
How do I fix a corrupted MP4 file that doesn't open? - Quora
Most of the time, the problem with a damaged MP4 file is due to data corruption caused by a virus, sudden power loss,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found