Recommend DAV to MP4 Converter, Please

Arjun

Known around here
Joined
Feb 26, 2017
Messages
9,094
Reaction score
11,137
Location
USA
Dahua should make a default option and change the file type at the time of export, just a suggestion
 

FrankZZ

n3wb
Joined
Apr 1, 2019
Messages
1
Reaction score
2
Location
Netherlands
Typo maybe?

ffmpeg -y -i video.dav .dav -vcodec libx264 -crf 24 -movflags +faststart video.mp4

should read

ffmpeg -y -i video.dav -vcodec libx264 -crf 24 -movflags +faststart video.mp4

Still no audio for me on:


ffmpeg version 4.1.1-0york1~18.04 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
configuration: --prefix=/usr --extra-version='0york1~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
ffmpeg is updated, but might need to update a dependency.


Just tried this, and I can confirm it does not work with ffmpeg version below 4.2.x
#6144 (DHAV demuxer with audio support) – FFmpeg got fixed in 4.2.1

For me it works with ffmpeg 4.2.1. Set audio in the camera to AAC (video is x265/hevc) and added -c:a copy to the ffmpeg command line like so (it copies the audio stream):

Code:
ffmpeg -y -i "16.24.14-16.24.33[M][0@0][0].dav" -c:a copy -vcodec libx264 -crf 24 "16.24.14-16.24.33[M][0@0][0].mp4"

ffmpeg version 4.2.1-0york0~18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --prefix=/usr --extra-version='0york0~18.04.1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, dhav, from '16.24.14-16.24.33[M][0@0][0].dav':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuvj420p(pc, bt470bg/bt470bg/bt709), 2688x1520, 20 fps, 100 tbr, 1k tbn
    Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
 

berba

n3wb
Joined
Dec 12, 2019
Messages
1
Reaction score
0
Location
City
I've tested several .dav files from my dahua camera and all of them convert with one error in log.
Code:
test.dav: Invalid data found when processing input
Although the converted files seem all right. There is sound, the picture is the same as the original video.
Anyone know what to do with it?
Code:
ffmpeg -loglevel debug -y -i test.dav -c:a copy -vcodec libx264 -crf 24 test.mp4
ffmpeg version 4.2.1-2~18.04.sav0 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
...
   Last message repeated 2 times
[hevc @ 0x55619b5440c0] Output frame with POC 374.
[hevc @ 0x55619b5440c0] Decoded frame with POC 374.
test.dav: Invalid data found when processing input
[out_0_0 @ 0x55619bbdf700] EOF on sink link out_0_0:default.bitrate= 287.0kbits/s dup=49 drop=0 speed=0.777x   
No more output streams to write to, finishing.
frame=  579 fps= 20 q=-0.0 Lsize=    1061kB time=00:00:23.04 bitrate= 377.2kbits/s dup=49 drop=0 speed=0.793x   
video:796kB audio:247kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 1.716234%
Input file #0 (test.dav):
  Input stream #0:0 (video): 530 packets read (503353 bytes); 530 frames decoded;
  Input stream #0:1 (audio): 990 packets read (253350 bytes);
  Total: 1520 packets (756703 bytes) demuxed
Output file #0 (test.mp4):
  Output stream #0:0 (video): 579 frames encoded; 579 packets muxed (814686 bytes);
  Output stream #0:1 (audio): 990 packets muxed (253350 bytes);
  Total: 1569 packets (1068036 bytes) muxed
530 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x55619b497540] Statistics: 2 seeks, 8 writeouts
x265 [info]: frame I:      3, Avg QP:18.51  kb/s: 27240.40
x265 [info]: frame P:    121, Avg QP:27.26  kb/s: 472.74 
x265 [info]: frame B:    455, Avg QP:31.63  kb/s: 51.76  
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 3.2% 4.0% 2.4% 3.2% 87.1%

encoded 579 frames in 29.01s (19.96 fps), 280.61 kb/s, Avg QP:30.65
[AVIOContext @ 0x55619b42dfc0] Statistics: 830866 bytes read, 0 seeks
Press [Enter] to quit.
 

Flavoradio

n3wb
Joined
Jan 15, 2020
Messages
1
Reaction score
0
Location
Forest Grove OR
This is a nice-to-(finally)-have, but a rotten performer for routine real-time use: on the quad-core j1900 processor in my file server, the conversion frame rate is lower than the video framerate and the CPU is all but maxed out; although that's with 4K video at 24fps.

Instead, for those of us using NFS file storage, another far more efficient option is to capture the camera's RTSP stream on the file server host, and write it out in whatever package format you like.

Example:

Code:
ffmpeg -i rtsp:/${RTSPURL}  -c copy -flags +global_header -map 0  -f mp4 -movflags frag_keyframe+empty_moov \
  -f segment -segment_time ${DURATION} -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 \
  -segment_format mp4  "${FP}/${DT}/${LOC}_${DT}_${TS}.mp4"
This uses almost no CPU since it doesn't even need to decode, let alone re-encode. The above invocation breaks it up into files of DURATION seconds and writes the files with timestamped filenames. You can add a thumbnailer to this as well -- though bear in mind this forces ffmpeg to decode the video in addition to just repackaging it, so this will use some CPU, perhaps 10-20% of a core on the above system. (That's still a small fraction of what converting DAV takes.) This variant will produce a thumbnail per minute in a separate directory:

Code:
ffmpeg -i rtsp:/${RTSPURL}  -c copy -flags +global_header -map 0  -f mp4 -movflags frag_keyframe+empty_moov \
  -f segment -segment_time ${DURATION} -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 \
  -segment_format mp4  "${FP}/${DT}/${LOC}_${DT}_${TS}.mp4" -f image2 -vf fps=fps=1/60 -strftime 1 \
  "${TFP}/thumbs/${LOC}/${DT}/${LOC}_${DT}_${TS}.jpg"
For reference here's the sample variables I'm using there:
Code:
LOC=frontdoor
FP=/var/site/cameras/${LOC}
TFP=/var/site/cameras
DURATION=600
DT="%Y-%m-%d"
TS="%H-%M-%S"
Hope that benefits somebody.
 
Last edited:

kuzco

Young grasshopper
Joined
Jan 17, 2020
Messages
87
Reaction score
5
Location
Germany
Hello, I want to re-open this thread.
I have bought a Dahua IPC from Andy and now I am playing with the "output" *.jpeg and *.dav.
At the moment I am using no DVR recorder for my old ReoLink cameras. I transfer (via ftp) all *.jpg and *.mp4 from my Reolink to an Apache-Server and create an index.html to see the thumbnails and also the full jpg and mp4 - so far so good.

I am aware that Dahua saves the video as *.dav. Unfortunately these *.dav (motion detection) are not playable with FF or Chrome. Therefore I have started to convert these *.dav to *.mp4. Have tried several commands, but:
with "ffmpeg -y -i $f -vcodec copy -movflags +faststart $fname.mp4" the mp4 is playable with VLC, but not within FF or Chrome. However, the convert process was done in 2 sec. per video.
Have also tried commands like:
  • "ffmpeg -y -i $f -vf "crop=1500:800:460:280" -t 01:00 $fname.mp4"
  • "ffmpeg -y -i $f -vcodec libx264 -crf 25 -movflags +faststart $fname.mp4"
but these commands needs a very long time to convert (a 20 sec. video needs 3 min. for conversion)

I am using "ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers" on an Igel MC340 ThinClient.

Any hint is welcome.
 
Last edited:
Top