Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] 1.0.1 janus-pp-rec convert to mp4 #3037

Closed
barakpp opened this issue Aug 14, 2022 · 4 comments
Closed

[1.x] 1.0.1 janus-pp-rec convert to mp4 #3037

barakpp opened this issue Aug 14, 2022 · 4 comments
Labels
multistream Related to Janus 1.x

Comments

@barakpp
Copy link

barakpp commented Aug 14, 2022

What version of Janus is this happening on?
1.0.1

Have you tested a more recent version of Janus too?
No.

Was this working before?
I did not check it in earlier versions

Is there a gdb or libasan trace of the issue?
No

Additional context
Hi guys,

I have some issue with janus-pp-rec.
I record RTP stream which encoded with h264 codec using janus videoroom plugin. It successfully create MJR file.

When I try to use janus-pp-rec to convert this MJR file to MP4 file I get MP4 which missing some information.
I tried to create a thumbnail from this mp4 but get an error (fluent-ffmpeg using streams), I also used online MP4 analyzer to check the file and it cannot be parsed.

Janus command:
janus-pp-rec input.mjr janus.mp4 - also tried with --format flag.

ffmpeg thumbnail command:
ffmpeg -ss 00:00:01 -i pipe:0 -y -an -vframes 1 -filter:v scale=w=320:h=240 out.png

But when I re create the mp4 without encoding using this command:
ffmpeg -i .\janus.mp4 -c copy -f mp4 out.mp4

the online analyzer works and also the ffmpeg command for creating thumbnail works.

  • After some checks it seems that MP4 analyzer expects to get as a first frame I-Frame and the MP4 which generated by janus-pp-rec starts with P-frame.
  • I compared two MP4 files, one which works with the ffmpeg command of thumbnail creation and janus's MP4.
    and it seems their have different structure:
  1. The MP4 which works has this structure:
    image

  2. Janus's MP4 has this structure:
    image

So I think because I work with pipe ffmpeg cant find the relevant data on the media because the moov part appended after mdat part so I try to use --faststart flag in janus-pp-rec command and got an error.
Janus version: 1001 (1.0.1)
Janus commit: 86cce9f
Compiled on: Wed May 25 08:56:45 UTC 2022

Logging level: 4

Source file: 2022-08-15T18-53-34.322Z-video-0.mjr
Target file: s2.mp4

File is 7677916 bytes
Pre-parsing file to generate ordered index...
This is a video recording:
-- Codec: h264
-- Created: 1660589614342303
-- Written: 1660589615182310
SSRC detected: 3564857702
Counted 6658 RTP packets
Counted 6658 frame packets
-- 1280x720 (fps [2970,11880] ~ 30)
[libx264 @ 0x5586eecdc640] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x5586eecdc640] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x5586eecdc640] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
First keyframe: 56430
[mp4 @ 0x5586eecd9380] Starting second pass: moving the moov atom to the beginning of the file
[mp4 @ 0x5586eecd9380] Unable to re-open output file for the second pass (faststart)
s2.mp4 is 7521227 bytes
Bye!

link to MP4 analyzer: https://lulebo.github.io/

I attach the files so I will be glad if you can try to understand what is the problem in the conversion process.
Thank you very much

janus.mp4
out.mp4
@barakpp barakpp added the multistream Related to Janus 1.x label Aug 14, 2022
@barakpp
Copy link
Author

barakpp commented Aug 14, 2022

@barakpp barakpp changed the title [1.x] 1.0.1 janus-pp-rec wrong PTS in output file (MP4) [1.x] 1.0.1 janus-pp-rec convert to mp4 Aug 14, 2022
@atoppi
Copy link
Member

atoppi commented Aug 22, 2022

It is not clear to me how you are using pipes with ffmpeg and if that plays a role in your issue.

I've done a quick test with the following specs:

  • latest janus master
  • latest Chrome/Linux published in a h264 (profile 42e01f) room

Then started the mjr recording with a configure request and closed the session after a while.

Converted input.mjr to janus.mp4

atoppi@atoppi:/tmp/recordings$ janus-pp-rec input.mjr janus.mp4
Janus version: 1100 (1.1.0)
Janus commit: 4346c1ad387fa0a710a45d978ee980d83a756caa
Compiled on:  lun 22 ago 2022, 10:34:24, CEST

Logging level: 4

Source file: input.mjr
Target file: janus.mp4

File is 10740609 bytes
Pre-parsing file to generate ordered index...
Video orientation extension ID: 13
This is a video recording:
  -- Codec:   h264
  -- Created: 1661158778125644
  -- Written: 1661158778226633
SSRC detected: 1446579215
Counted 9796 RTP packets
Counted 9796 frame packets
[   0.000s] Video rotation: 0 degrees
  -- 640x480 (fps [2340,6210] ~ 38)
[libx264 @ 0x55f268229dc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55f268229dc0] profile High, level 3.1
[libx264 @ 0x55f268229dc0] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
First keyframe: 0
janus.mp4 is 10458188 bytes
Bye!

I'v got a mp4 file that the online tool you linked was able to parse.

Finally I got a thumbnail with the following command (not using pipes)

ffmpeg -ss 00:00:01 -i janus.mp4 -y -an -vframes 1 -filter:v scale=w=320:h=240 out.png

@lminiero
Copy link
Member

The error that's reported is related to faststart:

Unable to re-open output file for the second pass

and I can replicate that one too. Without faststart it does work fine. I'll have a look.

@lminiero
Copy link
Member

The above commit seems to fix it for me, please let me know if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multistream Related to Janus 1.x
Projects
None yet
Development

No branches or pull requests

3 participants