Forum

DVR to MP4

Joël 2016-01-04 21:49:20 UTC in Nimble Streamer

Has anyone experience to convert a recorded dvr stream to a single mp4 file with ffmpeg or some other tool?

I love the new dvr functionality as recording and live stream solution. And now a want to optimize some things for both

as you know a dvr folder contains a lot of subfolders with short m4v video, and audio m4a files. I'm looking for a script or command with ffmpeg to join them together to a single mp4 file for providing it for download in a archive folder.

Alex Pokotilo 2016-01-05 03:33:02 UTC 

you can run ffmpeg like that
ffmpeg -i http://127.0.0.1:8081/live/stream/playlist_dvr.m3u8 -codec copy result.mp4

you can and should use ranges to get exact video chunks you need as described here http://blog.wmspanel.com/2015/11/dvr-time-range-fragments-epg.html

joël 2016-01-06 12:15:56 UTC 

Hi Alex thanks! To convert a complete dvr root folder works perfect and is very easy with this ffmpeg command.
Now i'm trying to convert the dvr video in parts of 2 hours to mp4 files.

Like this:
ffmpeg -i http://127.0.0.1:8081/live/stream01/playlist_dvr_range-1451585528877-7200.m3u8 -bsf:a aac_adtstoasc-codec copy "/mnt/archive/Live-event-31dec15_video-01.mp4"

But ffmpeg gives me an error:

Empty playlist
http://127.0.0.1:8081/live/stream01/playlist_dvr_range-1451585528877-7200.m3u8: End of file

Do I something wrong with the "UTC-starttime" ?
I copy&paste it from the first dvr subfolder

Max 2016-01-06 12:18:41 UTC 

Hi Joël,

DVR subfolder is having UTC time in milliseconds, so you need to remove last 3 digits if requesting the DVR archive fragment with the same timestamp (i.e. it will be http://127.0.0.1:8081/live/stream01/playlist_dvr_range-1451585528-7200.m3u8)

Joël 2016-01-06 16:10:20 UTC 

Again perfect,
Now it converts 2 hours to an MP4 file
I get only a lot of "No trailing CRLF found in HTTP header" errors during the converting with ffmpeg, but the mp4 video looks fine.

I have another question too about DVR live streaming.
The live buffer gets not enough chunks in time, I think.
sound en video stutters many times when the buffer is empty
when you start 1 or 2 minutes in the past, than it is oke for a while, till to buffer is emty again. DVR path to local storage or a mounted samba share makes not a big difference, what I see.
but I will post a new topic about that: optimizing DVR live streaming.

Josh 2016-02-12 20:06:18 UTC 

Hello.

I am trying to to convert a DVRed stream to MP4 using the command from the second post:

ffmpeg -i http://127.0.0.1:8081/live/stream/playlist_dvr.m3u8 -codec copy result.mp4

But replacing the source for the stream path copied from WMSpanel for DVR stuff.

When I run the command, though, I get "Invalid data found when processing input" as an error. I also tried to replace my servers IP to 127.0.0.1 but I get the same error.

Right now I am making sure I have all the ffmpeg stuff I need installed, but is there anything else that could be causing this?

OS is Centos 6.7 on a VPS

Josh 2016-02-12 23:06:35 UTC 

Just wanted to pop in and say I fixed my issue, and to plop it here in case anyone runs into the case I did.

I had just the basic ffmpeg installed from yum, which was an old version (0.6.5).

I went and compiled/installed from ffmpeg's latest git, and I am encoding as I type this :D

Yury Udovichenko 2016-02-13 09:11:18 UTC 

Josh, thanks for the update!

Joël 2016-02-13 13:32:42 UTC 

Hi Josh, thank you also for your comments about recording from dvr to mp4 with ffmpeg.

I have still some issue's with dvr live streaming. The audio stops from time to time. The video keeps running while the audio is silent for about 1 or 2 sec. This have only when playing live the dvr stream, not later when he is recorded
I send nimble support a email about this today.

Joël 2016-02-25 21:59:05 UTC 

Hi
the audio problem is solved now, during dvr live streaming, with the 2.14.0-10 update version of nimble.
Thanks al lot Nimble Team!!

Joompe team 2016-03-01 04:53:31 UTC 

hi supporter ! how to convert dvr to mp4 after stream end ?
i am using wowza, it auto save stream to mp4 after live stream end, can we do like on nimble ?

Yury Udovichenko 2016-03-01 05:33:40 UTC 

Hi,

Please use the ffmpeg-based procedure described above.

chubros 2016-09-21 05:05:50 UTC 

Why i m getting an continuos error when i converting my streams to mp4? The error says "Non-monotonous DTS in output stream 0:0; previous: 410145306, current: 410145306; changing to 410145307. This may result in incorrect timestamps in the output file."
And i m getting an mp4 that cannot seek to the end...

Mike 2016-09-24 02:27:04 UTC 

the dvr function is crazy logic why put everything in tiny folders, madness!. pointless function whole idea of dvr is to make things easy but instead some geek king has to be clever so it cant be used properly

Alex Pokotilo 2016-09-24 03:57:07 UTC 

Hi Mike,
we tried to implement dvr storage based on typical case it should be used in and care more on performance, robust and storage utilization then how it looks like from folder/files perspective.

MIKE 2016-09-25 21:09:47 UTC 

Unable to find a suitable output format for 'copy'
copy: Invalid argument

have tried ffmpeg command and getting error message above
is their no facility to convert these files into mp4 through the gui?

ffmpeg -i http://127.0.0.1:8081/nimble_live/stream01/playlist_dvr_range-1474834201-6360.m3u8 -bsf:a aac_adtstoasc-codec copy "/media/Live-event-250_video-01.mp4"

MIKE 2016-09-25 21:16:14 UTC 

fixed it there was no space between -codec was too close to previous command. please gui;)

Josh 2016-09-25 23:46:04 UTC 

To use a GUI with ffmpeg, you should get a frontend for it. I've used Avanti in the past. There may be a better one out there now, but I remember it being a pretty good ffmpeg GUI frontend

Mike 2016-09-26 01:11:24 UTC 

thanks josh, i mean nimble gui to convert. i got it to convert a selected range first time around but then second time i got error not sure why. with the mpeg4 i did convert ok, i hosted it with the vod streaming setup wizard. but now considering it seems error prone it puts me off fighting with it. need something straight forward like a gui feature in nimble that does it auto since i will be doing the process a lot

cheers

Joël Smit 2016-09-28 20:38:33 UTC 

Hi, when you need a mp4 recording of a live stream, why not doing it by ffmpeg with "server-side-task manager of wmspanel, right away. and you can use date and time variables for your filenames.
Rather then converting dvr files to an MP4 file afterwards.
The recording will start automatically direct when the live feed is available. And the mp4 file is direct available when you stop the live stream.

I use dvr for only live streaming, so the people can rewind the video during the live stream and for direct playback after the live event.
And of course for extra backup if something went wrong during with the primary recording method by ffmpeg.
But for a vod archive, I don't use dvr content. Only when something went wrong.

Alex Pokotilo 2016-09-29 02:23:32 UTC 

Joel,
and probably this is the best you can do with Nimble streamer now.

It's obvious for us that mp4 export from DVR archive as well as mp4 recording for live stream is necessary but absent part of our server. And seeing a lot of request in this field we've hired cool engineer who will improve server in this area.
Thanks everyone for good feedback

Josh 2016-09-29 21:02:37 UTC 

This would be awesome Alex. While I've gotten a bit used to server side tasks and doing things on the dedi box itself, having some more panel options for DVR functions like the ones you mentioned would be fantastic.

Thanks for always working to improve :D

Mike 2016-09-29 21:40:07 UTC 

hi joel thanks, what ffmpeg command would you use to select a date and time eg i want to record and output to mp4 from 8 oclock to 9:30?

that would be much easier than looking for segments

cheers

Majama 2016-10-30 19:40:19 UTC 

Hello there,
I am totally new to this, I had a live stream yesterday and my recording system failed me, but I have dvr and it is still available there, I want to download it. I followed the instructions above but I am get this: "Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x16905f60] Malformed AAC bitstream detected: use audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
av_interleaved_write_frame(): Operation not permitted
[mp4 @ 0x16905f60] Malformed AAC bitstream detected: use audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
frame= 2 fps=0.0 q=-1.0 Lsize= 35kB time=00:00:00.04 bitrate=5880.4kbits/s
video:39kB audio:1kB subtitle:0 data:0 global headers:0kB muxing overhead -10.724595%
root@secure [/home/admin]#"
I don't know what that means and where do I download the stream from if the copy works.

Josh 2016-10-30 21:59:15 UTC 

You are on the right path. Go ahead and add:

-bsf:a aac_adtstoasc

between the DVR path, and the path where you are storing the converted file. So it'll look like:

ffmpeg -i [your DVR webpath]:8081/path/to/dvr.m3u8 -bsf:a aac_adtstoasc -codec copy /path/to/DVR.mp4

Majama 2016-10-30 22:31:50 UTC 

Hello Josh!
Thanks very much for your able. The error I am getting is: /http:/live.xxxxx.tv/dvr/DVR.mp4: No such file or directory
I do not know if the path I provided is in the correct form or not.
the "xxxxx" is replaced with my domain in the actucal code that I put in

Josh 2016-10-30 22:40:35 UTC 

For the right address to put in for the DVR path will be in your WMSpanel area on the site.

Login to the dashboard area, then go to Nimble Streamer at the top. In the menu go to DVR streams. Once there you should hopefully see your DVR thingy listed.

Where your DVR stuff is listed, on the right, there should be a little question mark box. Click that and in the popup you'll be able to see a preview of your DVR, and copy the address to it.

Click copy in the top area above the preview window and you will have the correct path to your streams DVR that you are converting :D

Here are some screenshots for the area I am talking about.

vgy.me/6QlucG.png

vgy.me/rQwJ3Y.png

majama 2016-10-30 22:47:57 UTC 

Thanks again Josh,
I did the DVR path from the area you described, where I am having problem is the "copy" path, as in where I am copying the dvr to .mp4 file.
Thanks

Josh 2016-10-30 23:24:46 UTC 

Ahhh gotcha. Assuming you are running on linux, you just need to specify a path that exists (IE make the directory if its not created already), and then the file name.

So something like:

/home/DVR/file.mp4

And that will convert your stream to a file called file.mp4 inside /home/DVR/ directory

Majama 2016-10-30 23:47:48 UTC 

Hey Josh, you are my hero, it is working right now, encoding the file to mp4. I will let you know when it completes.

Thanks a million!

Martinling 2017-12-14 10:10:40 UTC 

Thanks for your idea about DVR to MP4, it really works on me. And I hear DRmare M4V Converter can convert M4V to MP4, do you know that too?

Denis Slobodskoy 2017-12-15 00:03:41 UTC 

If you want to convert m4v to mp4, there are plenty of free tools to do it - Handbrake, for example. DRmvare converter can deal with DRM protected video - well, if you need it, you may try it, but it doesn't related to the topic.

NicCy 2018-01-16 12:11:40 UTC 

just few tips that may help u :

- use a newer ffmpeg version, 3-4 year old versions may give u trouble

- take tote on time, a quick way to find correct timestamp use https://www.epochconverter.com/ , use the fitst tool"human date to tiemstamp" using local time

- empty playlists/shorter vids mean that your timestamps are wrong or the recorded time requested is missing,

- the aac_adtstoasc-codec as listed above may give u errors depending on the source quality, on some rtmp inputs works on some mpeg ones fails so i found this little gem : h264_mp4toannexb

full code that resolved all my problems (-quit helps not displaying all those non important errors, used it only after you are sure your code works) :

ffmpeg -v quiet -i http://127.0.0.1:8081/path/stream/playlist_dvr_range-1516013940-7400.m3u8 -vcodec copy -vbsf h264_mp4toannexb -acodec copy /outputpath/output.mp4

thanks

Yury Udovichenko 2019-02-21 07:47:38 UTC 

To summarize this discussion, we've introduced DVR export to MP4 using Nimble API.

Read this article for more details:
https://blog.wmspanel.com/2019/02/dvr-export-mp4.html

Sergey 2019-02-27 17:33:59 UTC 

Nice news!
But need check Access-Control-Allow-Origin for export stream.

1. In nimble.conf have
access_control_allow_origin = *

2. curl -o "test.m3u8" -v "h_t_t_p://10.1.101.80:8081/dvr/81/playlist_dvr_range-1551258000-60.m3u8"
< HTTP/1.1 200 OK
< Server: Nimble/3.5.4-7
< Date: Wed, 27 Feb 2019 17:29:39 GMT
< Content-Type: application/vnd.apple.mpegurl
< Content-Length: 157
< Accept-Ranges: bytes
< Cache-Control: no-cache
< Access-Control-Allow-Origin: *
< Connection: Keep-Alive

3. curl -o "test.mp4" -v "h_t_t_p://10.1.101.80:8082/manage/dvr/export_mp4/dvr/81?start=1551243600&end=1551243660"
< HTTP/1.1 200 OK
< Date: Wed, 27 Feb 2019 17:30:37 GMT
< Server: Nimble/3.5.4-7
< Connection: close
< Content-Length: 8572739
< Content-Type: video/mp4

Can fix it?

Denis Slobodskoy 2019-02-28 03:15:23 UTC 

Sorry, I don't get how Access-Control-Allow-Origin related to this. It only affect browser behaviour, restricting domain where you can place links to content.
If you want to provide direct links to DVR content - I wouldn't recommend to do this. Notice that DVR cleanup API is accessible on same interface ( https://wmspanel.com/nimble/api#toggler=8 ), so someone could modify request and wipe out your records.
Instead, I would recommend to allow management API from local host only or at least set token to forbid unauthorized access ( https://wmspanel.com/nimble/api#toggler=1 ), and request DVR from web server script.

Sergey 2019-02-28 05:51:31 UTC 

From javascript download mp4 blocked
Access to XMLHttpRequest ... has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sergey 2019-02-28 07:31:52 UTC 

Another question - error play .mp4 result in Win10 internal player:
"This file isn't playable. That might be because the file type is unsupported, the file extension is incorrect, or the file is corrupt.
0xc00d36c4"

When make by ffmpeg - Win10 internal player work correct.
Codec in both case is equal: H264-MPEG-4-AVC (part 10) (avc1).
VLC play fine always.

Denis Slobodskoy 2019-03-05 05:46:17 UTC 

Sergey,
We have added Access-Control-Allow-Origin header in Nimble 3.5.5.1, see release notes: https://blog.wmspanel.com/p/nimble-streamer-release-notes.html
Issue with playback on Windows 10 internal media player most probably will be fixed on next release.

Sergey 2019-03-05 15:21:14 UTC 

Denis,
Now we can download from javascript, but only as BLOB like XMLHttpRequest. Direct download as simple file not possible. Must be headers like this:

Content-Disposition: attachment; filename="test.mp4"
Content-Length: 417949
Content-Type: application/x-msdownload

As solution - add parameter to URL to generate download headers.

Sergey 2019-03-11 15:44:40 UTC 

Error play exported .mp4 in Win10 internal player now fixed in 3.5.5-2.

Vin Win 2019-10-19 01:32:44 UTC 

Again perfect

Post a reply


Post a new question

Categories:

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the Privacy Policy. If you want to know more or withdraw your consent to all or some of the cookies, please refer to the Privacy Policy.
By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to the use of cookies.