{"action":"created","issue":{"url":"https://api.github.com/repos/bytedeco/javacpp-presets/issues/639","repository_url":"https://api.github.com/repos/bytedeco/javacpp-presets","labels_url":"https://api.github.com/repos/bytedeco/javacpp-presets/issues/639/labels{/name}","comments_url":"https://api.github.com/repos/bytedeco/javacpp-presets/issues/639/comments","events_url":"https://api.github.com/repos/bytedeco/javacpp-presets/issues/639/events","html_url":"https://github.com/bytedeco/javacpp-presets/issues/639","id":373369335,"node_id":"MDU6SXNzdWUzNzMzNjkzMzU=","number":639,"title":"Record a JAVA SE APP","user":{"login":"Tatsukyo","id":32270062,"node_id":"MDQ6VXNlcjMyMjcwMDYy","avatar_url":"https://avatars0.githubusercontent.com/u/32270062?v=4","gravatar_id":"","url":"https://api.github.com/users/Tatsukyo","html_url":"https://github.com/Tatsukyo","followers_url":"https://api.github.com/users/Tatsukyo/followers","following_url":"https://api.github.com/users/Tatsukyo/following{/other_user}","gists_url":"https://api.github.com/users/Tatsukyo/gists{/gist_id}","starred_url":"https://api.github.com/users/Tatsukyo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tatsukyo/subscriptions","organizations_url":"https://api.github.com/users/Tatsukyo/orgs","repos_url":"https://api.github.com/users/Tatsukyo/repos","events_url":"https://api.github.com/users/Tatsukyo/events{/privacy}","received_events_url":"https://api.github.com/users/Tatsukyo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-24T08:43:35Z","updated_at":"2018-10-24T08:48:04Z","closed_at":null,"author_association":"NONE","body":"Hi @saudet\r\n\r\nCurrently trying to create a mp4 file from a java SE app which contains NO sound.\r\n\r\nAt the current time, i'm have just a basic JFrame which contains 2 JButtons and 1 Label which work as a timer to see if the video is working.\r\n\r\nI tried with JAVACV which works pretty good but it's coming with too much dependencies since i'm just using FFmpeg (and potentially openCV).\r\n\r\nRight now i'm just trying to init my \"Recorder\" as a mp4 recorder:\r\n```\r\nprivate void initRecorder()\r\n{\r\n\tavcodec_register_all();\r\n\tav_register_all();\r\n\tmVideoHeight = mPanel.getHeight();\r\n\tmVideoWidth = mPanel.getWidth();\r\n\r\n\tmFormatContext = new AVFormatContext(null);\r\n\tmOutputFormat = av_guess_format(mFileExtension, null, null);\r\n\tavformat_alloc_output_context2(mFormatContext, null, mFileExtension, null);\r\n\r\n\tmFormatContext.oformat(mOutputFormat);\r\n\tmFormatContext.filename().putString(\"C:\\\\Users\\\\A874966\\\\Desktop\\\\TestRecordFrame.mp4\");\r\n\tmFormatContext.max_delay(-1);\r\n\tmInputVideoStream = null;\r\n\tmVideoCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);\r\n\tmOutputFormat.video_codec(AV_CODEC_ID_MPEG4);\r\n\tAVRational lFramerate = av_d2q(mFramerate, 1001000);\r\n\tAVRational lSupportedFramerate = mVideoCodec.supported_framerates();\r\n\tif (lSupportedFramerate != null)\r\n\t{\r\n\t\tint idx = av_find_nearest_q_idx(lFramerate, lSupportedFramerate);\r\n\t\tlFramerate = lSupportedFramerate.position(idx);\r\n\t}\r\n\tmInputVideoStream = avformat_new_stream(mFormatContext, null);\r\n\tmVideoCodecContext = avcodec_alloc_context3(mVideoCodec);\r\n\tmVideoCodecContext.codec_id(mOutputFormat.video_codec());\r\n\tmVideoCodecContext.codec_type(AVMEDIA_TYPE_VIDEO);\r\n\tmVideoCodecContext.bit_rate(mBitrate);\r\n\t/* resolution must be a multiple of two. Scale height to maintain the aspect ratio. */\r\n\tif (mVideoWidth % 2 == 1)\r\n\t{\r\n\t\tint roundedWidth = mVideoWidth + 1;\r\n\t\tmVideoHeight = (roundedWidth * mVideoHeight + mVideoWidth / 2) / mVideoWidth;\r\n\t\tmVideoWidth = roundedWidth;\r\n\t}\r\n\tmVideoCodecContext.width(mVideoWidth);\r\n\tmVideoCodecContext.height(mVideoHeight);\r\n\tAVRational time_base = av_inv_q(lFramerate);\r\n\tmVideoCodecContext.time_base(time_base);\r\n\tmInputVideoStream.time_base(time_base);\r\n\tmInputVideoStream.avg_frame_rate(lFramerate);\r\n\tmVideoCodecContext.pix_fmt(AV_PIX_FMT_YUV420P);\r\n\tif ((mOutputFormat.flags() & AVFMT_GLOBALHEADER) != 0)\r\n\t{\r\n\t\tmVideoCodecContext.flags(mVideoCodecContext.flags() | AV_CODEC_FLAG_GLOBAL_HEADER);\r\n\t}\r\n\tif ((mVideoCodec.capabilities() & AV_CODEC_CAP_EXPERIMENTAL) != 0)\r\n\t{\r\n\t\tmVideoCodecContext.strict_std_compliance(AVCodecContext.FF_COMPLIANCE_EXPERIMENTAL);\r\n\t}\r\n\tavcodec_open2(mVideoCodecContext, mVideoCodec, (AVDictionary) null);\r\n\tmPictureFrame = av_frame_alloc();\r\n\tmTmpPictureFrame = av_frame_alloc();\r\n\tmPictureFrame.pts(0);\r\n\tmPicturePointer = new BytePointer(av_malloc(av_image_get_buffer_size(mVideoCodecContext.pix_fmt(), mVideoCodecContext.width(), mVideoCodecContext.height(), 1)));\r\n\tavcodec_parameters_from_context(mInputVideoStream.codecpar(), mVideoCodecContext);\r\n}\r\n```\r\n\r\nand stoping with\r\n```\r\nprivate void stopRecording() throws Exception\r\n{\r\n\tif (mFormatContext != null)\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tSystem.out.println(av_write_frame(mFormatContext, mVideoPacket));\r\n\t\t}\r\n\t\tfinally\r\n\t\t{\r\n\t\t\tcloseRecorder();\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\ni got a fatal error, and looking at the pid.log it's the av_write_frame which crash the JVM\r\n\r\nAm I missing something? is my init false?\r\n\r\nIf it can help u i'm using the ffmpeg-platform\r\nversion:3.4.1-1.4\r\n\r\nThank u in advance\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bytedeco/javacpp-presets/issues/comments/432569382","html_url":"https://github.com/bytedeco/javacpp-presets/issues/639#issuecomment-432569382","issue_url":"https://api.github.com/repos/bytedeco/javacpp-presets/issues/639","id":432569382,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjU2OTM4Mg==","user":{"login":"saudet","id":3328023,"node_id":"MDQ6VXNlcjMzMjgwMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/3328023?v=4","gravatar_id":"","url":"https://api.github.com/users/saudet","html_url":"https://github.com/saudet","followers_url":"https://api.github.com/users/saudet/followers","following_url":"https://api.github.com/users/saudet/following{/other_user}","gists_url":"https://api.github.com/users/saudet/gists{/gist_id}","starred_url":"https://api.github.com/users/saudet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saudet/subscriptions","organizations_url":"https://api.github.com/users/saudet/orgs","repos_url":"https://api.github.com/users/saudet/repos","events_url":"https://api.github.com/users/saudet/events{/privacy}","received_events_url":"https://api.github.com/users/saudet/received_events","type":"User","site_admin":false},"created_at":"2018-10-24T08:48:04Z","updated_at":"2018-10-24T08:48:04Z","author_association":"MEMBER","body":"Just asking simple questions, that doesn't take too much time :)\r\n\r\nWe don't need to use JavaCV, just copy `FFmpegFrameRecorder.java`, modify it a bit, and put it wherever you need it."}}
{"actor":{"display_login":"saudet"}}